},
.sample_time = true,
};
- struct thread_map *threads = NULL;
+ struct perf_thread_map *threads = NULL;
struct perf_cpu_map *cpus = NULL;
struct perf_evlist *evlist = NULL;
struct perf_evsel *evsel = NULL;
static int record__synthesize_workload(struct record *rec, bool tail)
{
int err;
- struct thread_map *thread_map;
+ struct perf_thread_map *thread_map;
if (rec->opts.tail_synthesize != tail)
return 0;
DECLARE_BITMAP(comp_cpus_mask, MAX_CPUS);
int *comp_cpus;
bool comp;
- struct thread_map *color_pids;
+ struct perf_thread_map *color_pids;
const char *color_pids_str;
struct perf_cpu_map *color_cpus;
const char *color_cpus_str;
static int setup_color_pids(struct perf_sched *sched)
{
- struct thread_map *map;
+ struct perf_thread_map *map;
if (!sched->map.color_pids_str)
return 0;
bool allocated;
bool per_event_dump;
struct perf_cpu_map *cpus;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
int name_width;
const char *time_str;
struct perf_time_interval *ptime_range;
struct perf_tool tool;
bool maps_allocated;
struct perf_cpu_map *cpus;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
enum aggr_mode aggr_mode;
};
}
static bool is_target_alive(struct target *_target,
- struct thread_map *threads)
+ struct perf_thread_map *threads)
{
struct stat st;
int i;
struct state state = {
.done_cnt = 0,
};
- struct thread_map *threads = NULL;
+ struct perf_thread_map *threads = NULL;
struct perf_cpu_map *cpus = NULL;
struct perf_evlist *evlist = NULL;
struct perf_evsel *evsel = NULL;
static int attach__current_disabled(struct perf_evlist *evlist)
{
struct perf_evsel *evsel = perf_evlist__last(evlist);
- struct thread_map *threads;
+ struct perf_thread_map *threads;
int err;
pr_debug("attaching to current thread as disabled\n");
static int attach__current_enabled(struct perf_evlist *evlist)
{
struct perf_evsel *evsel = perf_evlist__last(evlist);
- struct thread_map *threads;
+ struct perf_thread_map *threads;
int err;
pr_debug("attaching to current thread as enabled\n");
.uses_mmap = true,
},
};
- struct thread_map *threads = NULL;
+ struct perf_thread_map *threads = NULL;
struct perf_cpu_map *cpus = NULL;
struct perf_evlist *evlist = NULL;
struct perf_evsel *evsel = NULL;
{
int err = -1;
union perf_event *event;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
struct perf_cpu_map *cpus;
struct perf_evlist *evlist;
cpu_set_t cpu_set;
static int synth_process(struct machine *machine)
{
- struct thread_map *map;
+ struct perf_thread_map *map;
int err;
map = thread_map__new_by_pid(getpid());
struct perf_evsel *evsel;
unsigned int nr_openat_calls = 111, i;
cpu_set_t cpu_set;
- struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
+ struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
char sbuf[STRERR_BUFSIZE];
char errbuf[BUFSIZ];
int err = -1, fd;
struct perf_evsel *evsel;
unsigned int nr_openat_calls = 111, i;
- struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
+ struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
char sbuf[STRERR_BUFSIZE];
char errbuf[BUFSIZ];
.freq = 1,
};
struct perf_cpu_map *cpus;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
struct perf_mmap *md;
attr.sample_freq = 500;
.uses_mmap = true,
},
};
- struct thread_map *threads = NULL;
+ struct perf_thread_map *threads = NULL;
struct perf_cpu_map *cpus = NULL;
struct perf_evlist *evlist = NULL;
struct perf_evsel *evsel, *cpu_clocks_evsel, *cycles_evsel;
const char *argv[] = { "true", NULL };
char sbuf[STRERR_BUFSIZE];
struct perf_cpu_map *cpus;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
struct perf_mmap *md;
signal(SIGCHLD, sig_handler);
int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unused)
{
- struct thread_map *map;
+ struct perf_thread_map *map;
TEST_ASSERT_VAL("failed to set process name",
!prctl(PR_SET_NAME, NAMEUL, 0, 0, 0));
struct machine *machine __maybe_unused)
{
struct thread_map_event *map = &event->thread_map;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
TEST_ASSERT_VAL("wrong nr", map->nr == 1);
TEST_ASSERT_VAL("wrong pid", map->entries[0].pid == (u64) getpid());
int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
{
- struct thread_map *threads;
+ struct perf_thread_map *threads;
TEST_ASSERT_VAL("failed to set process name",
!prctl(PR_SET_NAME, NAMEUL, 0, 0, 0));
int test__thread_map_remove(struct test *test __maybe_unused, int subtest __maybe_unused)
{
- struct thread_map *threads;
+ struct perf_thread_map *threads;
char *str;
int i;
}
int perf_event__synthesize_thread_map(struct perf_tool *tool,
- struct thread_map *threads,
+ struct perf_thread_map *threads,
perf_event__handler_t process,
struct machine *machine,
bool mmap_data)
}
int perf_event__synthesize_thread_map2(struct perf_tool *tool,
- struct thread_map *threads,
+ struct perf_thread_map *threads,
perf_event__handler_t process,
struct machine *machine)
{
size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp)
{
- struct thread_map *threads = thread_map__new_event(&event->thread_map);
+ struct perf_thread_map *threads = thread_map__new_event(&event->thread_map);
size_t ret;
ret = fprintf(fp, " nr: ");
void perf_event__print_totals(void);
struct perf_tool;
-struct thread_map;
+struct perf_thread_map;
struct perf_cpu_map;
struct perf_stat_config;
struct perf_counts_values;
struct machine *machine);
int perf_event__synthesize_thread_map(struct perf_tool *tool,
- struct thread_map *threads,
+ struct perf_thread_map *threads,
perf_event__handler_t process,
struct machine *machine, bool mmap_data);
int perf_event__synthesize_thread_map2(struct perf_tool *tool,
- struct thread_map *threads,
+ struct perf_thread_map *threads,
perf_event__handler_t process,
struct machine *machine);
int perf_event__synthesize_cpu_map(struct perf_tool *tool,
#define SID(e, x, y) xyarray__entry(e->sample_id, x, y)
void perf_evlist__init(struct perf_evlist *evlist, struct perf_cpu_map *cpus,
- struct thread_map *threads)
+ struct perf_thread_map *threads)
{
int i;
{
struct perf_evsel *evsel;
const struct perf_cpu_map *cpus = evlist->cpus;
- const struct thread_map *threads = evlist->threads;
+ const struct perf_thread_map *threads = evlist->threads;
/*
* Delay setting mp.prot: set it before calling perf_mmap__mmap.
* Its value is decided by evsel's write_backward.
{
bool all_threads = (target->per_thread && target->system_wide);
struct perf_cpu_map *cpus;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
/*
* If specify '-a' and '--per-thread' to perf record, perf record
}
void perf_evlist__set_maps(struct perf_evlist *evlist, struct perf_cpu_map *cpus,
- struct thread_map *threads)
+ struct perf_thread_map *threads)
{
/*
* Allow for the possibility that one or another of the maps isn't being
static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist)
{
struct perf_cpu_map *cpus;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
int err = -ENOMEM;
/*
struct fdarray pollfd;
struct perf_mmap *mmap;
struct perf_mmap *overwrite_mmap;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
struct perf_cpu_map *cpus;
struct perf_evsel *selected;
struct events_stats stats;
struct perf_evlist *perf_evlist__new_default(void);
struct perf_evlist *perf_evlist__new_dummy(void);
void perf_evlist__init(struct perf_evlist *evlist, struct perf_cpu_map *cpus,
- struct thread_map *threads);
+ struct perf_thread_map *threads);
void perf_evlist__exit(struct perf_evlist *evlist);
void perf_evlist__delete(struct perf_evlist *evlist);
struct perf_evsel *evsel);
void perf_evlist__set_maps(struct perf_evlist *evlist, struct perf_cpu_map *cpus,
- struct thread_map *threads);
+ struct perf_thread_map *threads);
int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target);
int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel);
static bool ignore_missing_thread(struct perf_evsel *evsel,
int nr_cpus, int cpu,
- struct thread_map *threads,
+ struct perf_thread_map *threads,
int thread, int err)
{
pid_t ignore_pid = thread_map__pid(threads, thread);
}
int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
- struct thread_map *threads)
+ struct perf_thread_map *threads)
{
int cpu, thread, nthreads;
unsigned long flags = PERF_FLAG_FD_CLOEXEC;
}
if (threads == NULL) {
- static struct thread_map *empty_thread_map;
+ static struct perf_thread_map *empty_thread_map;
if (empty_thread_map == NULL) {
empty_thread_map = thread_map__new_by_tid(-1);
}
int perf_evsel__open_per_thread(struct perf_evsel *evsel,
- struct thread_map *threads)
+ struct perf_thread_map *threads)
{
return perf_evsel__open(evsel, NULL, threads);
}
int perf_evsel__store_ids(struct perf_evsel *evsel, struct perf_evlist *evlist)
{
struct perf_cpu_map *cpus = evsel->cpus;
- struct thread_map *threads = evsel->threads;
+ struct perf_thread_map *threads = evsel->threads;
if (perf_evsel__alloc_id(evsel, cpus->nr, threads->nr))
return -ENOMEM;
void *handler;
struct perf_cpu_map *cpus;
struct perf_cpu_map *own_cpus;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
unsigned int sample_size;
int id_pos;
int is_pos;
int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
struct perf_cpu_map *cpus);
int perf_evsel__open_per_thread(struct perf_evsel *evsel,
- struct thread_map *threads);
+ struct perf_thread_map *threads);
int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
- struct thread_map *threads);
+ struct perf_thread_map *threads);
void perf_evsel__close(struct perf_evsel *evsel);
struct perf_sample;
}
int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
- struct target *target, struct thread_map *threads,
+ struct target *target, struct perf_thread_map *threads,
perf_event__handler_t process, bool data_mmap,
unsigned int nr_threads_synthesize)
{
void *priv);
int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
- struct target *target, struct thread_map *threads,
+ struct target *target, struct perf_thread_map *threads,
perf_event__handler_t process, bool data_mmap,
unsigned int nr_threads_synthesize);
static inline
int machine__synthesize_threads(struct machine *machine, struct target *target,
- struct thread_map *threads, bool data_mmap,
+ struct perf_thread_map *threads, bool data_mmap,
unsigned int nr_threads_synthesize)
{
return __machine__synthesize_threads(machine, NULL, target, threads,
.config = config,
.disabled = 1,
};
- struct thread_map *tmap = thread_map__new_by_tid(0);
+ struct perf_thread_map *tmap = thread_map__new_by_tid(0);
if (tmap == NULL)
return false;
struct pyrf_thread_map {
PyObject_HEAD
- struct thread_map *threads;
+ struct perf_thread_map *threads;
};
static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads,
{
struct perf_evsel *evsel = &pevsel->evsel;
struct perf_cpu_map *cpus = NULL;
- struct thread_map *threads = NULL;
+ struct perf_thread_map *threads = NULL;
PyObject *pcpus = NULL, *pthreads = NULL;
int group = 0, inherit = 0;
static char *kwlist[] = { "cpus", "threads", "group", "inherit", NULL };
{
PyObject *pcpus = NULL, *pthreads = NULL;
struct perf_cpu_map *cpus;
- struct thread_map *threads;
+ struct perf_thread_map *threads;
if (!PyArg_ParseTuple(args, "OO", &pcpus, &pthreads))
return -1;
static void python_process_stat(struct perf_stat_config *config,
struct perf_evsel *counter, u64 tstamp)
{
- struct thread_map *threads = counter->threads;
+ struct perf_thread_map *threads = counter->threads;
struct perf_cpu_map *cpus = counter->cpus;
int cpu, thread;
return 1;
}
-static void thread_map__reset(struct thread_map *map, int start, int nr)
+static void thread_map__reset(struct perf_thread_map *map, int start, int nr)
{
size_t size = (nr - start) * sizeof(map->map[0]);
map->err_thread = -1;
}
-static struct thread_map *thread_map__realloc(struct thread_map *map, int nr)
+static struct perf_thread_map *thread_map__realloc(struct perf_thread_map *map, int nr)
{
size_t size = sizeof(*map) + sizeof(map->map[0]) * nr;
int start = map ? map->nr : 0;
#define thread_map__alloc(__nr) thread_map__realloc(NULL, __nr)
-struct thread_map *thread_map__new_by_pid(pid_t pid)
+struct perf_thread_map *thread_map__new_by_pid(pid_t pid)
{
- struct thread_map *threads;
+ struct perf_thread_map *threads;
char name[256];
int items;
struct dirent **namelist = NULL;
return threads;
}
-struct thread_map *thread_map__new_by_tid(pid_t tid)
+struct perf_thread_map *thread_map__new_by_tid(pid_t tid)
{
- struct thread_map *threads = thread_map__alloc(1);
+ struct perf_thread_map *threads = thread_map__alloc(1);
if (threads != NULL) {
thread_map__set_pid(threads, 0, tid);
return threads;
}
-static struct thread_map *__thread_map__new_all_cpus(uid_t uid)
+static struct perf_thread_map *__thread_map__new_all_cpus(uid_t uid)
{
DIR *proc;
int max_threads = 32, items, i;
char path[NAME_MAX + 1 + 6];
struct dirent *dirent, **namelist = NULL;
- struct thread_map *threads = thread_map__alloc(max_threads);
+ struct perf_thread_map *threads = thread_map__alloc(max_threads);
if (threads == NULL)
goto out;
}
if (grow) {
- struct thread_map *tmp;
+ struct perf_thread_map *tmp;
tmp = thread_map__realloc(threads, max_threads);
if (tmp == NULL)
goto out_closedir;
}
-struct thread_map *thread_map__new_all_cpus(void)
+struct perf_thread_map *thread_map__new_all_cpus(void)
{
return __thread_map__new_all_cpus(UINT_MAX);
}
-struct thread_map *thread_map__new_by_uid(uid_t uid)
+struct perf_thread_map *thread_map__new_by_uid(uid_t uid)
{
return __thread_map__new_all_cpus(uid);
}
-struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid)
+struct perf_thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid)
{
if (pid != -1)
return thread_map__new_by_pid(pid);
return thread_map__new_by_tid(tid);
}
-static struct thread_map *thread_map__new_by_pid_str(const char *pid_str)
+static struct perf_thread_map *thread_map__new_by_pid_str(const char *pid_str)
{
- struct thread_map *threads = NULL, *nt;
+ struct perf_thread_map *threads = NULL, *nt;
char name[256];
int items, total_tasks = 0;
struct dirent **namelist = NULL;
goto out;
}
-struct thread_map *thread_map__new_dummy(void)
+struct perf_thread_map *thread_map__new_dummy(void)
{
- struct thread_map *threads = thread_map__alloc(1);
+ struct perf_thread_map *threads = thread_map__alloc(1);
if (threads != NULL) {
thread_map__set_pid(threads, 0, -1);
return threads;
}
-struct thread_map *thread_map__new_by_tid_str(const char *tid_str)
+struct perf_thread_map *thread_map__new_by_tid_str(const char *tid_str)
{
- struct thread_map *threads = NULL, *nt;
+ struct perf_thread_map *threads = NULL, *nt;
int ntasks = 0;
pid_t tid, prev_tid = INT_MAX;
char *end_ptr;
goto out;
}
-struct thread_map *thread_map__new_str(const char *pid, const char *tid,
+struct perf_thread_map *thread_map__new_str(const char *pid, const char *tid,
uid_t uid, bool all_threads)
{
if (pid)
return thread_map__new_by_tid_str(tid);
}
-static void thread_map__delete(struct thread_map *threads)
+static void thread_map__delete(struct perf_thread_map *threads)
{
if (threads) {
int i;
}
}
-struct thread_map *thread_map__get(struct thread_map *map)
+struct perf_thread_map *thread_map__get(struct perf_thread_map *map)
{
if (map)
refcount_inc(&map->refcnt);
return map;
}
-void thread_map__put(struct thread_map *map)
+void thread_map__put(struct perf_thread_map *map)
{
if (map && refcount_dec_and_test(&map->refcnt))
thread_map__delete(map);
}
-size_t thread_map__fprintf(struct thread_map *threads, FILE *fp)
+size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp)
{
int i;
size_t printed = fprintf(fp, "%d thread%s: ",
return err;
}
-static void comm_init(struct thread_map *map, int i)
+static void comm_init(struct perf_thread_map *map, int i)
{
pid_t pid = thread_map__pid(map, i);
char *comm = NULL;
map->map[i].comm = comm;
}
-void thread_map__read_comms(struct thread_map *threads)
+void thread_map__read_comms(struct perf_thread_map *threads)
{
int i;
comm_init(threads, i);
}
-static void thread_map__copy_event(struct thread_map *threads,
+static void thread_map__copy_event(struct perf_thread_map *threads,
struct thread_map_event *event)
{
unsigned i;
refcount_set(&threads->refcnt, 1);
}
-struct thread_map *thread_map__new_event(struct thread_map_event *event)
+struct perf_thread_map *thread_map__new_event(struct thread_map_event *event)
{
- struct thread_map *threads;
+ struct perf_thread_map *threads;
threads = thread_map__alloc(event->nr);
if (threads)
return threads;
}
-bool thread_map__has(struct thread_map *threads, pid_t pid)
+bool thread_map__has(struct perf_thread_map *threads, pid_t pid)
{
int i;
return false;
}
-int thread_map__remove(struct thread_map *threads, int idx)
+int thread_map__remove(struct perf_thread_map *threads, int idx)
{
int i;
char *comm;
};
-struct thread_map {
+struct perf_thread_map {
refcount_t refcnt;
int nr;
int err_thread;
struct thread_map_event;
-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_tid(pid_t tid);
-struct thread_map *thread_map__new_by_uid(uid_t uid);
-struct thread_map *thread_map__new_all_cpus(void);
-struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid);
-struct thread_map *thread_map__new_event(struct thread_map_event *event);
+struct perf_thread_map *thread_map__new_dummy(void);
+struct perf_thread_map *thread_map__new_by_pid(pid_t pid);
+struct perf_thread_map *thread_map__new_by_tid(pid_t tid);
+struct perf_thread_map *thread_map__new_by_uid(uid_t uid);
+struct perf_thread_map *thread_map__new_all_cpus(void);
+struct perf_thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid);
+struct perf_thread_map *thread_map__new_event(struct thread_map_event *event);
-struct thread_map *thread_map__get(struct thread_map *map);
-void thread_map__put(struct thread_map *map);
+struct perf_thread_map *thread_map__get(struct perf_thread_map *map);
+void thread_map__put(struct perf_thread_map *map);
-struct thread_map *thread_map__new_str(const char *pid,
+struct perf_thread_map *thread_map__new_str(const char *pid,
const char *tid, uid_t uid, bool all_threads);
-struct thread_map *thread_map__new_by_tid_str(const char *tid_str);
+struct perf_thread_map *thread_map__new_by_tid_str(const char *tid_str);
-size_t thread_map__fprintf(struct thread_map *threads, FILE *fp);
+size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp);
-static inline int thread_map__nr(struct thread_map *threads)
+static inline int thread_map__nr(struct perf_thread_map *threads)
{
return threads ? threads->nr : 1;
}
-static inline pid_t thread_map__pid(struct thread_map *map, int thread)
+static inline pid_t thread_map__pid(struct perf_thread_map *map, int thread)
{
return map->map[thread].pid;
}
static inline void
-thread_map__set_pid(struct thread_map *map, int thread, pid_t pid)
+thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid)
{
map->map[thread].pid = pid;
}
-static inline char *thread_map__comm(struct thread_map *map, int thread)
+static inline char *thread_map__comm(struct perf_thread_map *map, int thread)
{
return map->map[thread].comm;
}
-void thread_map__read_comms(struct thread_map *threads);
-bool thread_map__has(struct thread_map *threads, pid_t pid);
-int thread_map__remove(struct thread_map *threads, int idx);
+void thread_map__read_comms(struct perf_thread_map *threads);
+bool thread_map__has(struct perf_thread_map *threads, pid_t pid);
+int thread_map__remove(struct perf_thread_map *threads, int idx);
#endif /* __PERF_THREAD_MAP_H */