perf tools: Set thread->mg.machine in all places

We were setting this only in machine__init(), i.e. for the map_groups that
holds the kernel module maps, not for the one used for a thread's executable
mmaps.

Now we are sure that we can obtain the machine where a thread is by going
via thread->mg->machine, thus we can, in the following patch, make all
codepaths that receive machine _and_ thread, drop the machine one.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-y6zgaqsvhrf04v57u15e4ybm@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7d073b33
...@@ -21,7 +21,7 @@ static void dsos__init(struct dsos *dsos) ...@@ -21,7 +21,7 @@ static void dsos__init(struct dsos *dsos)
int machine__init(struct machine *machine, const char *root_dir, pid_t pid) int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
{ {
map_groups__init(&machine->kmaps); map_groups__init(&machine->kmaps, machine);
RB_CLEAR_NODE(&machine->rb_node); RB_CLEAR_NODE(&machine->rb_node);
dsos__init(&machine->user_dsos); dsos__init(&machine->user_dsos);
dsos__init(&machine->kernel_dsos); dsos__init(&machine->kernel_dsos);
...@@ -32,7 +32,6 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) ...@@ -32,7 +32,6 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
machine->vdso_info = NULL; machine->vdso_info = NULL;
machine->kmaps.machine = machine;
machine->pid = pid; machine->pid = pid;
machine->symbol_filter = NULL; machine->symbol_filter = NULL;
...@@ -319,7 +318,7 @@ static void machine__update_thread_pid(struct machine *machine, ...@@ -319,7 +318,7 @@ static void machine__update_thread_pid(struct machine *machine,
goto out_err; goto out_err;
if (!leader->mg) if (!leader->mg)
leader->mg = map_groups__new(); leader->mg = map_groups__new(machine);
if (!leader->mg) if (!leader->mg)
goto out_err; goto out_err;
......
...@@ -413,14 +413,14 @@ u64 map__objdump_2mem(struct map *map, u64 ip) ...@@ -413,14 +413,14 @@ u64 map__objdump_2mem(struct map *map, u64 ip)
return ip + map->reloc; return ip + map->reloc;
} }
void map_groups__init(struct map_groups *mg) void map_groups__init(struct map_groups *mg, struct machine *machine)
{ {
int i; int i;
for (i = 0; i < MAP__NR_TYPES; ++i) { for (i = 0; i < MAP__NR_TYPES; ++i) {
mg->maps[i] = RB_ROOT; mg->maps[i] = RB_ROOT;
INIT_LIST_HEAD(&mg->removed_maps[i]); INIT_LIST_HEAD(&mg->removed_maps[i]);
} }
mg->machine = NULL; mg->machine = machine;
mg->refcnt = 1; mg->refcnt = 1;
} }
...@@ -471,12 +471,12 @@ bool map_groups__empty(struct map_groups *mg) ...@@ -471,12 +471,12 @@ bool map_groups__empty(struct map_groups *mg)
return true; return true;
} }
struct map_groups *map_groups__new(void) struct map_groups *map_groups__new(struct machine *machine)
{ {
struct map_groups *mg = malloc(sizeof(*mg)); struct map_groups *mg = malloc(sizeof(*mg));
if (mg != NULL) if (mg != NULL)
map_groups__init(mg); map_groups__init(mg, machine);
return mg; return mg;
} }
......
...@@ -64,7 +64,7 @@ struct map_groups { ...@@ -64,7 +64,7 @@ struct map_groups {
int refcnt; int refcnt;
}; };
struct map_groups *map_groups__new(void); struct map_groups *map_groups__new(struct machine *machine);
void map_groups__delete(struct map_groups *mg); void map_groups__delete(struct map_groups *mg);
bool map_groups__empty(struct map_groups *mg); bool map_groups__empty(struct map_groups *mg);
...@@ -150,7 +150,7 @@ void maps__remove(struct rb_root *maps, struct map *map); ...@@ -150,7 +150,7 @@ void maps__remove(struct rb_root *maps, struct map *map);
struct map *maps__find(struct rb_root *maps, u64 addr); struct map *maps__find(struct rb_root *maps, u64 addr);
struct map *maps__first(struct rb_root *maps); struct map *maps__first(struct rb_root *maps);
struct map *maps__next(struct map *map); struct map *maps__next(struct map *map);
void map_groups__init(struct map_groups *mg); void map_groups__init(struct map_groups *mg, struct machine *machine);
void map_groups__exit(struct map_groups *mg); void map_groups__exit(struct map_groups *mg);
int map_groups__clone(struct map_groups *mg, int map_groups__clone(struct map_groups *mg,
struct map_groups *parent, enum map_type type); struct map_groups *parent, enum map_type type);
......
...@@ -15,7 +15,7 @@ int thread__init_map_groups(struct thread *thread, struct machine *machine) ...@@ -15,7 +15,7 @@ int thread__init_map_groups(struct thread *thread, struct machine *machine)
pid_t pid = thread->pid_; pid_t pid = thread->pid_;
if (pid == thread->tid || pid == -1) { if (pid == thread->tid || pid == -1) {
thread->mg = map_groups__new(); thread->mg = map_groups__new(machine);
} else { } else {
leader = machine__findnew_thread(machine, pid, pid); leader = machine__findnew_thread(machine, pid, pid);
if (leader) if (leader)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment