• Home
  • Raw
  • Download

Lines Matching +full:path +full:- +full:map

1 // SPDX-License-Identifier: GPL-2.0
25 if (dir->d_name[0] == '.') in filter()
49 perf_thread_map__set_pid(threads, i, atoi(namelist[i]->d_name)); in thread_map__new_by_pid()
50 threads->nr = items; in thread_map__new_by_pid()
51 refcount_set(&threads->refcnt, 1); in thread_map__new_by_pid()
67 threads->nr = 1; in thread_map__new_by_tid()
68 refcount_set(&threads->refcnt, 1); in thread_map__new_by_tid()
78 char path[NAME_MAX + 1 + 6]; in __thread_map__new_all_cpus() local
89 threads->nr = 0; in __thread_map__new_all_cpus()
90 refcount_set(&threads->refcnt, 1); in __thread_map__new_all_cpus()
95 pid_t pid = strtol(dirent->d_name, &end, 10); in __thread_map__new_all_cpus()
100 snprintf(path, sizeof(path), "/proc/%s", dirent->d_name); in __thread_map__new_all_cpus()
105 if (stat(path, &st) != 0 || st.st_uid != uid) in __thread_map__new_all_cpus()
109 snprintf(path, sizeof(path), "/proc/%d/task", pid); in __thread_map__new_all_cpus()
110 items = scandir(path, &namelist, filter, NULL); in __thread_map__new_all_cpus()
114 while (threads->nr + items >= max_threads) { in __thread_map__new_all_cpus()
130 perf_thread_map__set_pid(threads, threads->nr + i, in __thread_map__new_all_cpus()
131 atoi(namelist[i]->d_name)); in __thread_map__new_all_cpus()
138 threads->nr += items; in __thread_map__new_all_cpus()
172 if (pid != -1) in thread_map__new()
175 if (tid == -1 && uid != UINT_MAX) in thread_map__new()
198 pid = strtol(pos->s, &end_ptr, 10); in thread_map__new_by_pid_str()
220 perf_thread_map__set_pid(threads, j++, atoi(namelist[i]->d_name)); in thread_map__new_by_pid_str()
223 threads->nr = total_tasks; in thread_map__new_by_pid_str()
230 refcount_set(&threads->refcnt, 1); in thread_map__new_by_pid_str()
253 /* perf-stat expects threads to be generated even if tid not given */ in thread_map__new_by_tid_str()
262 tid = strtol(pos->s, &end_ptr, 10); in thread_map__new_by_tid_str()
278 perf_thread_map__set_pid(threads, ntasks - 1, tid); in thread_map__new_by_tid_str()
279 threads->nr = ntasks; in thread_map__new_by_tid_str()
283 refcount_set(&threads->refcnt, 1); in thread_map__new_by_tid_str()
311 threads->nr, threads->nr > 1 ? "s" : ""); in thread_map__fprintf()
312 for (i = 0; i < threads->nr; ++i) in thread_map__fprintf()
320 char *path; in get_comm() local
324 if (asprintf(&path, "%s/%d/comm", procfs__mountpoint(), pid) == -1) in get_comm()
325 return -ENOMEM; in get_comm()
327 err = filename__read_str(path, comm, &size); in get_comm()
338 free(path); in get_comm()
342 static void comm_init(struct perf_thread_map *map, int i) in comm_init() argument
344 pid_t pid = perf_thread_map__pid(map, i); in comm_init()
348 if (pid == -1) { in comm_init()
349 map->map[i].comm = strdup("dummy"); in comm_init()
354 * The comm name is like extra bonus ;-), in comm_init()
360 map->map[i].comm = comm; in comm_init()
367 for (i = 0; i < threads->nr; ++i) in thread_map__read_comms()
376 threads->nr = (int) event->nr; in thread_map__copy_event()
378 for (i = 0; i < event->nr; i++) { in thread_map__copy_event()
379 perf_thread_map__set_pid(threads, i, (pid_t) event->entries[i].pid); in thread_map__copy_event()
380 threads->map[i].comm = strndup(event->entries[i].comm, 16); in thread_map__copy_event()
383 refcount_set(&threads->refcnt, 1); in thread_map__copy_event()
390 threads = thread_map__alloc(event->nr); in thread_map__new_event()
401 for (i = 0; i < threads->nr; ++i) { in thread_map__has()
402 if (threads->map[i].pid == pid) in thread_map__has()
413 if (threads->nr < 1) in thread_map__remove()
414 return -EINVAL; in thread_map__remove()
416 if (idx >= threads->nr) in thread_map__remove()
417 return -EINVAL; in thread_map__remove()
422 zfree(&threads->map[idx].comm); in thread_map__remove()
424 for (i = idx; i < threads->nr - 1; i++) in thread_map__remove()
425 threads->map[i] = threads->map[i + 1]; in thread_map__remove()
427 threads->nr--; in thread_map__remove()