Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jin Yao and committed by
Arnaldo Carvalho de Melo
73c0ca1e 14e72a21

+8 -4
+1 -1
tools/perf/tests/thread-map.c
··· 105 105 TEST_ASSERT_VAL("failed to allocate map string", 106 106 asprintf(&str, "%d,%d", getpid(), getppid()) >= 0); 107 107 108 - threads = thread_map__new_str(str, NULL, 0); 108 + threads = thread_map__new_str(str, NULL, 0, false); 109 109 110 110 TEST_ASSERT_VAL("failed to allocate thread_map", 111 111 threads);
+2 -1
tools/perf/util/evlist.c
··· 1105 1105 struct cpu_map *cpus; 1106 1106 struct thread_map *threads; 1107 1107 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); 1109 1110 1110 1111 if (!threads) 1111 1112 return -1;
+4 -1
tools/perf/util/thread_map.c
··· 323 323 } 324 324 325 325 struct thread_map *thread_map__new_str(const char *pid, const char *tid, 326 - uid_t uid) 326 + uid_t uid, bool per_thread) 327 327 { 328 328 if (pid) 329 329 return thread_map__new_by_pid_str(pid); 330 330 331 331 if (!tid && uid != UINT_MAX) 332 332 return thread_map__new_by_uid(uid); 333 + 334 + if (per_thread) 335 + return thread_map__new_all_cpus(); 333 336 334 337 return thread_map__new_by_tid_str(tid); 335 338 }
+1 -1
tools/perf/util/thread_map.h
··· 31 31 void thread_map__put(struct thread_map *map); 32 32 33 33 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); 35 35 36 36 struct thread_map *thread_map__new_by_tid_str(const char *tid_str); 37 37