Skip to content

Commit 73c0ca1

Browse files
Jin Yaoacmel
authored andcommitted
perf thread_map: Enumerate all threads from /proc
This patch calls thread_map__new_all_cpus() to enumerate all threads from /proc if per-thread flag is enabled. Signed-off-by: Jin Yao <yao.jin@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1512482591-4646-10-git-send-email-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 14e72a2 commit 73c0ca1

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎tools/perf/tests/thread-map.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int test__thread_map_remove(struct test *test __maybe_unused, int subtest __mayb
105105
TEST_ASSERT_VAL("failed to allocate map string",
106106
asprintf(&str, "%d,%d", getpid(), getppid()) >= 0);
107107

108-
threads = thread_map__new_str(str, NULL, 0);
108+
threads = thread_map__new_str(str, NULL, 0, false);
109109

110110
TEST_ASSERT_VAL("failed to allocate thread_map",
111111
threads);

‎tools/perf/util/evlist.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,8 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
11051105
struct cpu_map *cpus;
11061106
struct thread_map *threads;
11071107

1108-
threads = thread_map__new_str(target->pid, target->tid, target->uid);
1108+
threads = thread_map__new_str(target->pid, target->tid, target->uid,
1109+
target->per_thread);
11091110

11101111
if (!threads)
11111112
return -1;

‎tools/perf/util/thread_map.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,17 @@ struct thread_map *thread_map__new_by_tid_str(const char *tid_str)
323323
}
324324

325325
struct thread_map *thread_map__new_str(const char *pid, const char *tid,
326-
uid_t uid)
326+
uid_t uid, bool per_thread)
327327
{
328328
if (pid)
329329
return thread_map__new_by_pid_str(pid);
330330

331331
if (!tid && uid != UINT_MAX)
332332
return thread_map__new_by_uid(uid);
333333

334+
if (per_thread)
335+
return thread_map__new_all_cpus();
336+
334337
return thread_map__new_by_tid_str(tid);
335338
}
336339

‎tools/perf/util/thread_map.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct thread_map *thread_map__get(struct thread_map *map);
3131
void thread_map__put(struct thread_map *map);
3232

3333
struct thread_map *thread_map__new_str(const char *pid,
34-
const char *tid, uid_t uid);
34+
const char *tid, uid_t uid, bool per_thread);
3535

3636
struct thread_map *thread_map__new_by_tid_str(const char *tid_str);
3737

0 commit comments

Comments
 (0)