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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a635fc51
...@@ -214,6 +214,17 @@ static struct thread_map *thread_map__new_by_pid_str(const char *pid_str) ...@@ -214,6 +214,17 @@ static struct thread_map *thread_map__new_by_pid_str(const char *pid_str)
goto out; goto out;
} }
struct thread_map *thread_map__new_dummy(void)
{
struct thread_map *threads = malloc(sizeof(*threads) + sizeof(pid_t));
if (threads != NULL) {
threads->map[0] = -1;
threads->nr = 1;
}
return threads;
}
static struct thread_map *thread_map__new_by_tid_str(const char *tid_str) static struct thread_map *thread_map__new_by_tid_str(const char *tid_str)
{ {
struct thread_map *threads = NULL, *nt; 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,14 +235,8 @@ static struct thread_map *thread_map__new_by_tid_str(const char *tid_str)
struct strlist *slist; struct strlist *slist;
/* perf-stat expects threads to be generated even if tid not given */ /* perf-stat expects threads to be generated even if tid not given */
if (!tid_str) { if (!tid_str)
threads = malloc(sizeof(*threads) + sizeof(pid_t)); return thread_map__new_dummy();
if (threads != NULL) {
threads->map[0] = -1;
threads->nr = 1;
}
return threads;
}
slist = strlist__new(false, tid_str); slist = strlist__new(false, tid_str);
if (!slist) if (!slist)
......
...@@ -9,6 +9,7 @@ struct thread_map { ...@@ -9,6 +9,7 @@ struct thread_map {
pid_t map[]; pid_t map[];
}; };
struct thread_map *thread_map__new_dummy(void);
struct thread_map *thread_map__new_by_pid(pid_t pid); struct thread_map *thread_map__new_by_pid(pid_t pid);
struct thread_map *thread_map__new_by_tid(pid_t tid); struct thread_map *thread_map__new_by_tid(pid_t tid);
struct thread_map *thread_map__new_by_uid(uid_t uid); struct thread_map *thread_map__new_by_uid(uid_t uid);
......
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