Lines Matching +full:path +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0
26 if (dir->d_name[0] == '.') in filter()
50 perf_thread_map__set_pid(threads, i, atoi(namelist[i]->d_name)); in thread_map__new_by_pid()
51 threads->nr = items; in thread_map__new_by_pid()
52 refcount_set(&threads->refcnt, 1); in thread_map__new_by_pid()
68 threads->nr = 1; in thread_map__new_by_tid()
69 refcount_set(&threads->refcnt, 1); in thread_map__new_by_tid()
79 char path[NAME_MAX + 1 + 6]; in __thread_map__new_all_cpus() local
90 threads->nr = 0; in __thread_map__new_all_cpus()
91 refcount_set(&threads->refcnt, 1); in __thread_map__new_all_cpus()
96 pid_t pid = strtol(dirent->d_name, &end, 10); in __thread_map__new_all_cpus()
101 snprintf(path, sizeof(path), "/proc/%s", dirent->d_name); in __thread_map__new_all_cpus()
106 if (stat(path, &st) != 0 || st.st_uid != uid) in __thread_map__new_all_cpus()
110 snprintf(path, sizeof(path), "/proc/%d/task", pid); in __thread_map__new_all_cpus()
111 items = scandir(path, &namelist, filter, NULL); in __thread_map__new_all_cpus()
115 while (threads->nr + items >= max_threads) { in __thread_map__new_all_cpus()
131 perf_thread_map__set_pid(threads, threads->nr + i, in __thread_map__new_all_cpus()
132 atoi(namelist[i]->d_name)); in __thread_map__new_all_cpus()
139 threads->nr += items; in __thread_map__new_all_cpus()
173 if (pid != -1) in thread_map__new()
176 if (tid == -1 && uid != UINT_MAX) in thread_map__new()
199 pid = strtol(pos->s, &end_ptr, 10); in thread_map__new_by_pid_str()
221 perf_thread_map__set_pid(threads, j++, atoi(namelist[i]->d_name)); in thread_map__new_by_pid_str()
224 threads->nr = total_tasks; in thread_map__new_by_pid_str()
231 refcount_set(&threads->refcnt, 1); in thread_map__new_by_pid_str()
254 /* perf-stat expects threads to be generated even if tid not given */ in thread_map__new_by_tid_str()
263 tid = strtol(pos->s, &end_ptr, 10); in thread_map__new_by_tid_str()
279 perf_thread_map__set_pid(threads, ntasks - 1, tid); in thread_map__new_by_tid_str()
280 threads->nr = ntasks; in thread_map__new_by_tid_str()
285 refcount_set(&threads->refcnt, 1); in thread_map__new_by_tid_str()
312 threads->nr, threads->nr > 1 ? "s" : ""); in thread_map__fprintf()
313 for (i = 0; i < threads->nr; ++i) in thread_map__fprintf()
321 char *path; in get_comm() local
325 if (asprintf(&path, "%s/%d/comm", procfs__mountpoint(), pid) == -1) in get_comm()
326 return -ENOMEM; in get_comm()
328 err = filename__read_str(path, comm, &size); in get_comm()
339 free(path); in get_comm()
343 static void comm_init(struct perf_thread_map *map, int i) in comm_init() argument
345 pid_t pid = perf_thread_map__pid(map, i); in comm_init()
349 if (pid == -1) { in comm_init()
350 map->map[i].comm = strdup("dummy"); in comm_init()
355 * The comm name is like extra bonus ;-), in comm_init()
361 map->map[i].comm = comm; in comm_init()
368 for (i = 0; i < threads->nr; ++i) in thread_map__read_comms()
377 threads->nr = (int) event->nr; in thread_map__copy_event()
379 for (i = 0; i < event->nr; i++) { in thread_map__copy_event()
380 perf_thread_map__set_pid(threads, i, (pid_t) event->entries[i].pid); in thread_map__copy_event()
381 threads->map[i].comm = strndup(event->entries[i].comm, 16); in thread_map__copy_event()
384 refcount_set(&threads->refcnt, 1); in thread_map__copy_event()
391 threads = thread_map__alloc(event->nr); in thread_map__new_event()
402 for (i = 0; i < threads->nr; ++i) { in thread_map__has()
403 if (threads->map[i].pid == pid) in thread_map__has()
414 if (threads->nr < 1) in thread_map__remove()
415 return -EINVAL; in thread_map__remove()
417 if (idx >= threads->nr) in thread_map__remove()
418 return -EINVAL; in thread_map__remove()
423 zfree(&threads->map[idx].comm); in thread_map__remove()
425 for (i = idx; i < threads->nr - 1; i++) in thread_map__remove()
426 threads->map[i] = threads->map[i + 1]; in thread_map__remove()
428 threads->nr--; in thread_map__remove()