diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-10-10 11:03:46 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-10-14 16:32:52 -0400 |
| commit | 641556c98c821922a9a2121247b5fa25e4407d11 (patch) | |
| tree | dadcb5fb2cceb02388bf62b5025f6b23eb07aefe /tools | |
| parent | a635fc511e05774298153e3ddfef7c4cd51a1bb4 (diff) | |
perf thread_map: Create dummy constructor out of open coded equivalent
Create a dummy thread_map, one that has just one entry and it is -1,
meaning 'all threads', as this ends up going down to perf_event_open().
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-8av26cz8uxmbnihl5mmrygp9@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/util/thread_map.c | 21 | ||||
| -rw-r--r-- | tools/perf/util/thread_map.h | 1 |
2 files changed, 14 insertions, 8 deletions
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index 5d3215912105..f93b9734735b 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c | |||
| @@ -214,6 +214,17 @@ out_free_threads: | |||
| 214 | goto out; | 214 | goto out; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | struct thread_map *thread_map__new_dummy(void) | ||
| 218 | { | ||
| 219 | struct thread_map *threads = malloc(sizeof(*threads) + sizeof(pid_t)); | ||
| 220 | |||
| 221 | if (threads != NULL) { | ||
| 222 | threads->map[0] = -1; | ||
| 223 | threads->nr = 1; | ||
| 224 | } | ||
| 225 | return threads; | ||
| 226 | } | ||
| 227 | |||
| 217 | static struct thread_map *thread_map__new_by_tid_str(const char *tid_str) | 228 | static struct thread_map *thread_map__new_by_tid_str(const char *tid_str) |
| 218 | { | 229 | { |
| 219 | struct thread_map *threads = NULL, *nt; | 230 | struct thread_map *threads = NULL, *nt; |
| @@ -224,14 +235,8 @@ static struct thread_map *thread_map__new_by_tid_str(const char *tid_str) | |||
| 224 | struct strlist *slist; | 235 | struct strlist *slist; |
| 225 | 236 | ||
| 226 | /* perf-stat expects threads to be generated even if tid not given */ | 237 | /* perf-stat expects threads to be generated even if tid not given */ |
| 227 | if (!tid_str) { | 238 | if (!tid_str) |
| 228 | threads = malloc(sizeof(*threads) + sizeof(pid_t)); | 239 | return thread_map__new_dummy(); |
| 229 | if (threads != NULL) { | ||
| 230 | threads->map[0] = -1; | ||
| 231 | threads->nr = 1; | ||
| 232 | } | ||
| 233 | return threads; | ||
| 234 | } | ||
| 235 | 240 | ||
| 236 | slist = strlist__new(false, tid_str); | 241 | slist = strlist__new(false, tid_str); |
| 237 | if (!slist) | 242 | if (!slist) |
diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h index 0cd8b3108084..95313f43cc0f 100644 --- a/tools/perf/util/thread_map.h +++ b/tools/perf/util/thread_map.h | |||
| @@ -9,6 +9,7 @@ struct thread_map { | |||
| 9 | pid_t map[]; | 9 | pid_t map[]; |
| 10 | }; | 10 | }; |
| 11 | 11 | ||
| 12 | struct thread_map *thread_map__new_dummy(void); | ||
| 12 | struct thread_map *thread_map__new_by_pid(pid_t pid); | 13 | struct thread_map *thread_map__new_by_pid(pid_t pid); |
| 13 | struct thread_map *thread_map__new_by_tid(pid_t tid); | 14 | struct thread_map *thread_map__new_by_tid(pid_t tid); |
| 14 | struct thread_map *thread_map__new_by_uid(uid_t uid); | 15 | struct thread_map *thread_map__new_by_uid(uid_t uid); |
