perf thread: Rename thread->mg to thread->maps

One more step on the merge of 'struct maps' with 'struct map_groups'.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-69vcr8pubpym90skxhmbwhiw@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 79b6bb73
...@@ -26,7 +26,7 @@ static int sample_ustack(struct perf_sample *sample, ...@@ -26,7 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
sp = (unsigned long) regs[PERF_REG_ARM_SP]; sp = (unsigned long) regs[PERF_REG_ARM_SP];
map = maps__find(thread->mg, (u64)sp); map = maps__find(thread->maps, (u64)sp);
if (!map) { if (!map) {
pr_debug("failed to get stack map\n"); pr_debug("failed to get stack map\n");
free(buf); free(buf);
......
...@@ -26,7 +26,7 @@ static int sample_ustack(struct perf_sample *sample, ...@@ -26,7 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
sp = (unsigned long) regs[PERF_REG_ARM64_SP]; sp = (unsigned long) regs[PERF_REG_ARM64_SP];
map = maps__find(thread->mg, (u64)sp); map = maps__find(thread->maps, (u64)sp);
if (!map) { if (!map) {
pr_debug("failed to get stack map\n"); pr_debug("failed to get stack map\n");
free(buf); free(buf);
......
...@@ -27,7 +27,7 @@ static int sample_ustack(struct perf_sample *sample, ...@@ -27,7 +27,7 @@ static int sample_ustack(struct perf_sample *sample,
sp = (unsigned long) regs[PERF_REG_POWERPC_R1]; sp = (unsigned long) regs[PERF_REG_POWERPC_R1];
map = maps__find(thread->mg, (u64)sp); map = maps__find(thread->maps, (u64)sp);
if (!map) { if (!map) {
pr_debug("failed to get stack map\n"); pr_debug("failed to get stack map\n");
free(buf); free(buf);
......
...@@ -27,7 +27,7 @@ static int sample_ustack(struct perf_sample *sample, ...@@ -27,7 +27,7 @@ static int sample_ustack(struct perf_sample *sample,
sp = (unsigned long) regs[PERF_REG_X86_SP]; sp = (unsigned long) regs[PERF_REG_X86_SP];
map = maps__find(thread->mg, (u64)sp); map = maps__find(thread->maps, (u64)sp);
if (!map) { if (!map) {
pr_debug("failed to get stack map\n"); pr_debug("failed to get stack map\n");
free(buf); free(buf);
......
...@@ -790,7 +790,7 @@ static void task__print_level(struct task *task, FILE *fp, int level) ...@@ -790,7 +790,7 @@ static void task__print_level(struct task *task, FILE *fp, int level)
fprintf(fp, "%s\n", thread__comm_str(thread)); fprintf(fp, "%s\n", thread__comm_str(thread));
maps__fprintf_task(thread->mg, comm_indent, fp); maps__fprintf_task(thread->maps, comm_indent, fp);
if (!list_empty(&task->children)) { if (!list_empty(&task->children)) {
list_for_each_entry(child, &task->children, list) list_for_each_entry(child, &task->children, list)
......
...@@ -276,7 +276,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, ...@@ -276,7 +276,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
len = al.map->end - addr; len = al.map->end - addr;
/* Read the object code using perf */ /* Read the object code using perf */
ret_len = dso__data_read_offset(al.map->dso, thread->mg->machine, ret_len = dso__data_read_offset(al.map->dso, thread->maps->machine,
al.addr, buf1, len); al.addr, buf1, len);
if (ret_len != len) { if (ret_len != len) {
pr_debug("dso__data_read_offset failed\n"); pr_debug("dso__data_read_offset failed\n");
......
...@@ -42,13 +42,13 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_ ...@@ -42,13 +42,13 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_
TEST_ASSERT_VAL("failed to create threads", TEST_ASSERT_VAL("failed to create threads",
leader && t1 && t2 && t3 && other); leader && t1 && t2 && t3 && other);
mg = leader->mg; mg = leader->maps;
TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&mg->refcnt), 4); TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&mg->refcnt), 4);
/* test the map groups pointer is shared */ /* test the map groups pointer is shared */
TEST_ASSERT_VAL("map groups don't match", mg == t1->mg); TEST_ASSERT_VAL("map groups don't match", mg == t1->maps);
TEST_ASSERT_VAL("map groups don't match", mg == t2->mg); TEST_ASSERT_VAL("map groups don't match", mg == t2->maps);
TEST_ASSERT_VAL("map groups don't match", mg == t3->mg); TEST_ASSERT_VAL("map groups don't match", mg == t3->maps);
/* /*
* Verify the other leader was created by previous call. * Verify the other leader was created by previous call.
...@@ -70,10 +70,10 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_ ...@@ -70,10 +70,10 @@ int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_
machine__remove_thread(machine, other); machine__remove_thread(machine, other);
machine__remove_thread(machine, other_leader); machine__remove_thread(machine, other_leader);
other_mg = other->mg; other_mg = other->maps;
TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&other_mg->refcnt), 2); TEST_ASSERT_EQUAL("wrong refcnt", refcount_read(&other_mg->refcnt), 2);
TEST_ASSERT_VAL("map groups don't match", other_mg == other_leader->mg); TEST_ASSERT_VAL("map groups don't match", other_mg == other_leader->maps);
/* release thread group */ /* release thread group */
thread__put(leader); thread__put(leader);
......
...@@ -885,7 +885,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, ...@@ -885,7 +885,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
} }
if (h->ms.map == NULL && verbose > 1) { if (h->ms.map == NULL && verbose > 1) {
maps__fprintf(h->thread->mg, fp); maps__fprintf(h->thread->maps, fp);
fprintf(fp, "%.10s end\n", graph_dotted_line); fprintf(fp, "%.10s end\n", graph_dotted_line);
} }
} }
......
...@@ -251,7 +251,7 @@ static struct call_path *call_path_from_sample(struct db_export *dbe, ...@@ -251,7 +251,7 @@ static struct call_path *call_path_from_sample(struct db_export *dbe,
*/ */
al.sym = node->ms.sym; al.sym = node->ms.sym;
al.map = node->ms.map; al.map = node->ms.map;
al.mg = thread->mg; al.mg = thread->maps;
al.addr = node->ip; al.addr = node->ip;
if (al.map && !al.sym) if (al.map && !al.sym)
......
...@@ -457,7 +457,7 @@ int perf_event__process(struct perf_tool *tool __maybe_unused, ...@@ -457,7 +457,7 @@ int perf_event__process(struct perf_tool *tool __maybe_unused,
struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr, struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
struct addr_location *al) struct addr_location *al)
{ {
struct maps *mg = thread->mg; struct maps *mg = thread->maps;
struct machine *machine = mg->machine; struct machine *machine = mg->machine;
bool load_map = false; bool load_map = false;
...@@ -523,7 +523,7 @@ struct map *thread__find_map_fb(struct thread *thread, u8 cpumode, u64 addr, ...@@ -523,7 +523,7 @@ struct map *thread__find_map_fb(struct thread *thread, u8 cpumode, u64 addr,
struct addr_location *al) struct addr_location *al)
{ {
struct map *map = thread__find_map(thread, cpumode, addr, al); struct map *map = thread__find_map(thread, cpumode, addr, al);
struct machine *machine = thread->mg->machine; struct machine *machine = thread->maps->machine;
u8 addr_cpumode = machine__addr_cpumode(machine, cpumode, addr); u8 addr_cpumode = machine__addr_cpumode(machine, cpumode, addr);
if (map || addr_cpumode == cpumode) if (map || addr_cpumode == cpumode)
......
...@@ -412,28 +412,28 @@ static void machine__update_thread_pid(struct machine *machine, ...@@ -412,28 +412,28 @@ static void machine__update_thread_pid(struct machine *machine,
if (!leader) if (!leader)
goto out_err; goto out_err;
if (!leader->mg) if (!leader->maps)
leader->mg = maps__new(machine); leader->maps = maps__new(machine);
if (!leader->mg) if (!leader->maps)
goto out_err; goto out_err;
if (th->mg == leader->mg) if (th->maps == leader->maps)
return; return;
if (th->mg) { if (th->maps) {
/* /*
* Maps are created from MMAP events which provide the pid and * Maps are created from MMAP events which provide the pid and
* tid. Consequently there never should be any maps on a thread * tid. Consequently there never should be any maps on a thread
* with an unknown pid. Just print an error if there are. * with an unknown pid. Just print an error if there are.
*/ */
if (!maps__empty(th->mg)) if (!maps__empty(th->maps))
pr_err("Discarding thread maps for %d:%d\n", pr_err("Discarding thread maps for %d:%d\n",
th->pid_, th->tid); th->pid_, th->tid);
maps__put(th->mg); maps__put(th->maps);
} }
th->mg = maps__get(leader->mg); th->maps = maps__get(leader->maps);
out_put: out_put:
thread__put(leader); thread__put(leader);
return; return;
......
...@@ -819,7 +819,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) ...@@ -819,7 +819,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
*/ */
int maps__clone(struct thread *thread, struct maps *parent) int maps__clone(struct thread *thread, struct maps *parent)
{ {
struct maps *mg = thread->mg; struct maps *mg = thread->maps;
int err = -ENOMEM; int err = -ENOMEM;
struct map *map; struct map *map;
......
...@@ -134,8 +134,8 @@ static int thread_stack__init(struct thread_stack *ts, struct thread *thread, ...@@ -134,8 +134,8 @@ static int thread_stack__init(struct thread_stack *ts, struct thread *thread,
if (err) if (err)
return err; return err;
if (thread->mg && thread->mg->machine) { if (thread->maps && thread->maps->machine) {
struct machine *machine = thread->mg->machine; struct machine *machine = thread->maps->machine;
const char *arch = perf_env__arch(machine->env); const char *arch = perf_env__arch(machine->env);
ts->kernel_start = machine__kernel_start(machine); ts->kernel_start = machine__kernel_start(machine);
......
...@@ -24,16 +24,16 @@ int thread__init_maps(struct thread *thread, struct machine *machine) ...@@ -24,16 +24,16 @@ int thread__init_maps(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 = maps__new(machine); thread->maps = maps__new(machine);
} else { } else {
struct thread *leader = __machine__findnew_thread(machine, pid, pid); struct thread *leader = __machine__findnew_thread(machine, pid, pid);
if (leader) { if (leader) {
thread->mg = maps__get(leader->mg); thread->maps = maps__get(leader->maps);
thread__put(leader); thread__put(leader);
} }
} }
return thread->mg ? 0 : -1; return thread->maps ? 0 : -1;
} }
struct thread *thread__new(pid_t pid, pid_t tid) struct thread *thread__new(pid_t pid, pid_t tid)
...@@ -86,9 +86,9 @@ void thread__delete(struct thread *thread) ...@@ -86,9 +86,9 @@ void thread__delete(struct thread *thread)
thread_stack__free(thread); thread_stack__free(thread);
if (thread->mg) { if (thread->maps) {
maps__put(thread->mg); maps__put(thread->maps);
thread->mg = NULL; thread->maps = NULL;
} }
down_write(&thread->namespaces_lock); down_write(&thread->namespaces_lock);
list_for_each_entry_safe(namespaces, tmp_namespaces, list_for_each_entry_safe(namespaces, tmp_namespaces,
...@@ -251,7 +251,7 @@ static int ____thread__set_comm(struct thread *thread, const char *str, ...@@ -251,7 +251,7 @@ static int ____thread__set_comm(struct thread *thread, const char *str,
list_add(&new->list, &thread->comm_list); list_add(&new->list, &thread->comm_list);
if (exec) if (exec)
unwind__flush_access(thread->mg); unwind__flush_access(thread->maps);
} }
thread->comm_set = true; thread->comm_set = true;
...@@ -324,19 +324,19 @@ int thread__comm_len(struct thread *thread) ...@@ -324,19 +324,19 @@ int thread__comm_len(struct thread *thread)
size_t thread__fprintf(struct thread *thread, FILE *fp) size_t thread__fprintf(struct thread *thread, FILE *fp)
{ {
return fprintf(fp, "Thread %d %s\n", thread->tid, thread__comm_str(thread)) + return fprintf(fp, "Thread %d %s\n", thread->tid, thread__comm_str(thread)) +
maps__fprintf(thread->mg, fp); maps__fprintf(thread->maps, fp);
} }
int thread__insert_map(struct thread *thread, struct map *map) int thread__insert_map(struct thread *thread, struct map *map)
{ {
int ret; int ret;
ret = unwind__prepare_access(thread->mg, map, NULL); ret = unwind__prepare_access(thread->maps, map, NULL);
if (ret) if (ret)
return ret; return ret;
maps__fixup_overlappings(thread->mg, map, stderr); maps__fixup_overlappings(thread->maps, map, stderr);
maps__insert(thread->mg, map); maps__insert(thread->maps, map);
return 0; return 0;
} }
...@@ -345,13 +345,13 @@ static int __thread__prepare_access(struct thread *thread) ...@@ -345,13 +345,13 @@ static int __thread__prepare_access(struct thread *thread)
{ {
bool initialized = false; bool initialized = false;
int err = 0; int err = 0;
struct maps *maps = thread->mg; struct maps *maps = thread->maps;
struct map *map; struct map *map;
down_read(&maps->lock); down_read(&maps->lock);
maps__for_each_entry(maps, map) { maps__for_each_entry(maps, map) {
err = unwind__prepare_access(thread->mg, map, &initialized); err = unwind__prepare_access(thread->maps, map, &initialized);
if (err || initialized) if (err || initialized)
break; break;
} }
...@@ -377,13 +377,13 @@ static int thread__clone_maps(struct thread *thread, struct thread *parent, bool ...@@ -377,13 +377,13 @@ static int thread__clone_maps(struct thread *thread, struct thread *parent, bool
if (thread->pid_ == parent->pid_) if (thread->pid_ == parent->pid_)
return thread__prepare_access(thread); return thread__prepare_access(thread);
if (thread->mg == parent->mg) { if (thread->maps == parent->maps) {
pr_debug("broken map groups on thread %d/%d parent %d/%d\n", pr_debug("broken map groups on thread %d/%d parent %d/%d\n",
thread->pid_, thread->tid, parent->pid_, parent->tid); thread->pid_, thread->tid, parent->pid_, parent->tid);
return 0; return 0;
} }
/* But this one is new process, copy maps. */ /* But this one is new process, copy maps. */
return do_maps_clone ? maps__clone(thread, parent->mg) : 0; return do_maps_clone ? maps__clone(thread, parent->maps) : 0;
} }
int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone) int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone)
......
...@@ -25,7 +25,7 @@ struct thread { ...@@ -25,7 +25,7 @@ struct thread {
struct rb_node rb_node; struct rb_node rb_node;
struct list_head node; struct list_head node;
}; };
struct maps *mg; struct maps *maps;
pid_t pid_; /* Not all tools update this */ pid_t pid_; /* Not all tools update this */
pid_t tid; pid_t tid;
pid_t ppid; pid_t ppid;
......
...@@ -200,7 +200,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, ...@@ -200,7 +200,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct unwind_info *ui, ui_buf = { struct unwind_info *ui, ui_buf = {
.sample = data, .sample = data,
.thread = thread, .thread = thread,
.machine = thread->mg->machine, .machine = thread->maps->machine,
.cb = cb, .cb = cb,
.arg = arg, .arg = arg,
.max_stack = max_stack, .max_stack = max_stack,
......
...@@ -660,7 +660,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, ...@@ -660,7 +660,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
*/ */
if (max_stack - 1 > 0) { if (max_stack - 1 > 0) {
WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL"); WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL");
addr_space = ui->thread->mg->addr_space; addr_space = ui->thread->maps->addr_space;
if (addr_space == NULL) if (addr_space == NULL)
return -1; return -1;
...@@ -709,7 +709,7 @@ static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg, ...@@ -709,7 +709,7 @@ static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct unwind_info ui = { struct unwind_info ui = {
.sample = data, .sample = data,
.thread = thread, .thread = thread,
.machine = thread->mg->machine, .machine = thread->maps->machine,
}; };
if (!data->user_regs.regs) if (!data->user_regs.regs)
......
...@@ -82,7 +82,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, ...@@ -82,7 +82,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct thread *thread, struct thread *thread,
struct perf_sample *data, int max_stack) struct perf_sample *data, int max_stack)
{ {
if (thread->mg->unwind_libunwind_ops) if (thread->maps->unwind_libunwind_ops)
return thread->mg->unwind_libunwind_ops->get_entries(cb, arg, thread, data, max_stack); return thread->maps->unwind_libunwind_ops->get_entries(cb, arg, thread, data, max_stack);
return 0; return 0;
} }
...@@ -144,7 +144,7 @@ static enum dso_type machine__thread_dso_type(struct machine *machine, ...@@ -144,7 +144,7 @@ static enum dso_type machine__thread_dso_type(struct machine *machine,
enum dso_type dso_type = DSO__TYPE_UNKNOWN; enum dso_type dso_type = DSO__TYPE_UNKNOWN;
struct map *map; struct map *map;
maps__for_each_entry(thread->mg, map) { maps__for_each_entry(thread->maps, map) {
struct dso *dso = map->dso; struct dso *dso = map->dso;
if (!dso || dso->long_name[0] != '/') if (!dso || dso->long_name[0] != '/')
continue; continue;
......
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