Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf thread_map: Remove uid options

Now the target doesn't have a uid, it is handled through BPF filters,
remove the uid options to thread_map creation. Tidy up the functions
used in tests to avoid passing unused arguments.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250604174545.2853620-11-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
5128492b b4c658d4

+20 -48
+2 -2
tools/perf/tests/event-times.c
··· 62 62 63 63 pr_debug("attaching to current thread as disabled\n"); 64 64 65 - threads = thread_map__new(-1, getpid(), UINT_MAX); 65 + threads = thread_map__new_by_tid(getpid()); 66 66 if (threads == NULL) { 67 67 pr_debug("thread_map__new\n"); 68 68 return -1; ··· 88 88 89 89 pr_debug("attaching to current thread as enabled\n"); 90 90 91 - threads = thread_map__new(-1, getpid(), UINT_MAX); 91 + threads = thread_map__new_by_tid(getpid()); 92 92 if (threads == NULL) { 93 93 pr_debug("failed to call thread_map__new\n"); 94 94 return -1;
+1 -1
tools/perf/tests/keep-tracking.c
··· 78 78 int found, err = -1; 79 79 const char *comm; 80 80 81 - threads = thread_map__new(-1, getpid(), UINT_MAX); 81 + threads = thread_map__new_by_tid(getpid()); 82 82 CHECK_NOT_NULL__(threads); 83 83 84 84 cpus = perf_cpu_map__new_online_cpus();
+1 -1
tools/perf/tests/mmap-basic.c
··· 46 46 char sbuf[STRERR_BUFSIZE]; 47 47 struct mmap *md; 48 48 49 - threads = thread_map__new(-1, getpid(), UINT_MAX); 49 + threads = thread_map__new_by_tid(getpid()); 50 50 if (threads == NULL) { 51 51 pr_debug("thread_map__new\n"); 52 52 return -1;
+1 -1
tools/perf/tests/openat-syscall-all-cpus.c
··· 28 28 struct evsel *evsel; 29 29 unsigned int nr_openat_calls = 111, i; 30 30 cpu_set_t cpu_set; 31 - struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); 31 + struct perf_thread_map *threads = thread_map__new_by_tid(getpid()); 32 32 char sbuf[STRERR_BUFSIZE]; 33 33 char errbuf[BUFSIZ]; 34 34
+1 -1
tools/perf/tests/openat-syscall.c
··· 20 20 int err = TEST_FAIL, fd; 21 21 struct evsel *evsel; 22 22 unsigned int nr_openat_calls = 111, i; 23 - struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); 23 + struct perf_thread_map *threads = thread_map__new_by_tid(getpid()); 24 24 char sbuf[STRERR_BUFSIZE]; 25 25 char errbuf[BUFSIZ]; 26 26
+1 -1
tools/perf/tests/perf-time-to-tsc.c
··· 90 90 struct mmap *md; 91 91 92 92 93 - threads = thread_map__new(-1, getpid(), UINT_MAX); 93 + threads = thread_map__new_by_tid(getpid()); 94 94 CHECK_NOT_NULL__(threads); 95 95 96 96 cpus = perf_cpu_map__new_online_cpus();
+1 -1
tools/perf/tests/switch-tracking.c
··· 351 351 const char *comm; 352 352 int err = -1; 353 353 354 - threads = thread_map__new(-1, getpid(), UINT_MAX); 354 + threads = thread_map__new_by_tid(getpid()); 355 355 if (!threads) { 356 356 pr_debug("thread_map__new failed!\n"); 357 357 goto out_err;
+1 -1
tools/perf/tests/thread-map.c
··· 115 115 TEST_ASSERT_VAL("failed to allocate map string", 116 116 asprintf(&str, "%d,%d", getpid(), getppid()) >= 0); 117 117 118 - threads = thread_map__new_str(str, NULL, 0, false); 118 + threads = thread_map__new_str(str, /*tid=*/NULL, /*all_threads=*/false); 119 119 free(str); 120 120 121 121 TEST_ASSERT_VAL("failed to allocate thread_map",
+1 -1
tools/perf/util/evlist.c
··· 1006 1006 * per-thread data. thread_map__new_str will call 1007 1007 * thread_map__new_all_cpus to enumerate all threads. 1008 1008 */ 1009 - threads = thread_map__new_str(target->pid, target->tid, UINT_MAX, all_threads); 1009 + threads = thread_map__new_str(target->pid, target->tid, all_threads); 1010 1010 1011 1011 if (!threads) 1012 1012 return -1;
+5 -5
tools/perf/util/python.c
··· 566 566 static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads, 567 567 PyObject *args, PyObject *kwargs) 568 568 { 569 - static char *kwlist[] = { "pid", "tid", "uid", NULL }; 570 - int pid = -1, tid = -1, uid = UINT_MAX; 569 + static char *kwlist[] = { "pid", "tid", NULL }; 570 + int pid = -1, tid = -1; 571 571 572 - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iii", 573 - kwlist, &pid, &tid, &uid)) 572 + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", 573 + kwlist, &pid, &tid)) 574 574 return -1; 575 575 576 - pthreads->threads = thread_map__new(pid, tid, uid); 576 + pthreads->threads = thread_map__new(pid, tid); 577 577 if (pthreads->threads == NULL) 578 578 return -1; 579 579 return 0;
+3 -29
tools/perf/util/thread_map.c
··· 72 72 return threads; 73 73 } 74 74 75 - static struct perf_thread_map *__thread_map__new_all_cpus(uid_t uid) 75 + static struct perf_thread_map *thread_map__new_all_cpus(void) 76 76 { 77 77 DIR *proc; 78 78 int max_threads = 32, items, i; ··· 97 97 98 98 if (*end) /* only interested in proper numerical dirents */ 99 99 continue; 100 - 101 - snprintf(path, sizeof(path), "/proc/%s", dirent->d_name); 102 - 103 - if (uid != UINT_MAX) { 104 - struct stat st; 105 - 106 - if (stat(path, &st) != 0 || st.st_uid != uid) 107 - continue; 108 - } 109 100 110 101 snprintf(path, sizeof(path), "/proc/%d/task", pid); 111 102 items = scandir(path, &namelist, filter, NULL); ··· 148 157 goto out_closedir; 149 158 } 150 159 151 - struct perf_thread_map *thread_map__new_all_cpus(void) 152 - { 153 - return __thread_map__new_all_cpus(UINT_MAX); 154 - } 155 - 156 - struct perf_thread_map *thread_map__new_by_uid(uid_t uid) 157 - { 158 - return __thread_map__new_all_cpus(uid); 159 - } 160 - 161 - struct perf_thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid) 160 + struct perf_thread_map *thread_map__new(pid_t pid, pid_t tid) 162 161 { 163 162 if (pid != -1) 164 163 return thread_map__new_by_pid(pid); 165 - 166 - if (tid == -1 && uid != UINT_MAX) 167 - return thread_map__new_by_uid(uid); 168 164 169 165 return thread_map__new_by_tid(tid); 170 166 } ··· 267 289 goto out; 268 290 } 269 291 270 - struct perf_thread_map *thread_map__new_str(const char *pid, const char *tid, 271 - uid_t uid, bool all_threads) 292 + struct perf_thread_map *thread_map__new_str(const char *pid, const char *tid, bool all_threads) 272 293 { 273 294 if (pid) 274 295 return thread_map__new_by_pid_str(pid); 275 - 276 - if (!tid && uid != UINT_MAX) 277 - return thread_map__new_by_uid(uid); 278 296 279 297 if (all_threads) 280 298 return thread_map__new_all_cpus();
+2 -4
tools/perf/util/thread_map.h
··· 11 11 struct perf_thread_map *thread_map__new_dummy(void); 12 12 struct perf_thread_map *thread_map__new_by_pid(pid_t pid); 13 13 struct perf_thread_map *thread_map__new_by_tid(pid_t tid); 14 - struct perf_thread_map *thread_map__new_by_uid(uid_t uid); 15 - struct perf_thread_map *thread_map__new_all_cpus(void); 16 - struct perf_thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid); 14 + struct perf_thread_map *thread_map__new(pid_t pid, pid_t tid); 17 15 struct perf_thread_map *thread_map__new_event(struct perf_record_thread_map *event); 18 16 19 17 struct perf_thread_map *thread_map__new_str(const char *pid, 20 - const char *tid, uid_t uid, bool all_threads); 18 + const char *tid, bool all_threads); 21 19 22 20 struct perf_thread_map *thread_map__new_by_tid_str(const char *tid_str); 23 21