]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf thread_map: Remove uid options
authorIan Rogers <irogers@google.com>
Wed, 4 Jun 2025 17:45:44 +0000 (10:45 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 9 Jun 2025 18:18:18 +0000 (11:18 -0700)
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>
12 files changed:
tools/perf/tests/event-times.c
tools/perf/tests/keep-tracking.c
tools/perf/tests/mmap-basic.c
tools/perf/tests/openat-syscall-all-cpus.c
tools/perf/tests/openat-syscall.c
tools/perf/tests/perf-time-to-tsc.c
tools/perf/tests/switch-tracking.c
tools/perf/tests/thread-map.c
tools/perf/util/evlist.c
tools/perf/util/python.c
tools/perf/util/thread_map.c
tools/perf/util/thread_map.h

index 2148024b4f4af96aa39fed2cdaa04a4c5cdd401d..ae3b98bb42cf8c5c227e6dd7dd36a9caa0779b62 100644 (file)
@@ -62,7 +62,7 @@ static int attach__current_disabled(struct evlist *evlist)
 
        pr_debug("attaching to current thread as disabled\n");
 
-       threads = thread_map__new(-1, getpid(), UINT_MAX);
+       threads = thread_map__new_by_tid(getpid());
        if (threads == NULL) {
                pr_debug("thread_map__new\n");
                return -1;
@@ -88,7 +88,7 @@ static int attach__current_enabled(struct evlist *evlist)
 
        pr_debug("attaching to current thread as enabled\n");
 
-       threads = thread_map__new(-1, getpid(), UINT_MAX);
+       threads = thread_map__new_by_tid(getpid());
        if (threads == NULL) {
                pr_debug("failed to call thread_map__new\n");
                return -1;
index 5a3b2bed07f327e1806766a5bdf0c61792673c75..eafb49eb0b56b778b0332bbc372ff66218799dff 100644 (file)
@@ -78,7 +78,7 @@ static int test__keep_tracking(struct test_suite *test __maybe_unused, int subte
        int found, err = -1;
        const char *comm;
 
-       threads = thread_map__new(-1, getpid(), UINT_MAX);
+       threads = thread_map__new_by_tid(getpid());
        CHECK_NOT_NULL__(threads);
 
        cpus = perf_cpu_map__new_online_cpus();
index bd2106628b3457fa7712bfcd64ecbcd7ecdb8a95..04b547c6bdbeda5a020d4d322744eb04aeb7024d 100644 (file)
@@ -46,7 +46,7 @@ static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest
        char sbuf[STRERR_BUFSIZE];
        struct mmap *md;
 
-       threads = thread_map__new(-1, getpid(), UINT_MAX);
+       threads = thread_map__new_by_tid(getpid());
        if (threads == NULL) {
                pr_debug("thread_map__new\n");
                return -1;
index fb114118c87640b848bbd0243a7810cc2877b032..3644d6f52c07d0ab494bfd29f30a009837cce861 100644 (file)
@@ -28,7 +28,7 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __mayb
        struct evsel *evsel;
        unsigned int nr_openat_calls = 111, i;
        cpu_set_t cpu_set;
-       struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
+       struct perf_thread_map *threads = thread_map__new_by_tid(getpid());
        char sbuf[STRERR_BUFSIZE];
        char errbuf[BUFSIZ];
 
index 131b62271bfa270bdc1ad44fd58783bc2d0d20d0..b54cbe5f18085eaa69b1e7d3af3235b0c0281d25 100644 (file)
@@ -20,7 +20,7 @@ static int test__openat_syscall_event(struct test_suite *test __maybe_unused,
        int err = TEST_FAIL, fd;
        struct evsel *evsel;
        unsigned int nr_openat_calls = 111, i;
-       struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
+       struct perf_thread_map *threads = thread_map__new_by_tid(getpid());
        char sbuf[STRERR_BUFSIZE];
        char errbuf[BUFSIZ];
 
index d3e40fa5482ce546bbe8d0d595d95a59886823e7..d4437410c99f45a08e79a77584809dd0878917c3 100644 (file)
@@ -90,7 +90,7 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su
        struct mmap *md;
 
 
-       threads = thread_map__new(-1, getpid(), UINT_MAX);
+       threads = thread_map__new_by_tid(getpid());
        CHECK_NOT_NULL__(threads);
 
        cpus = perf_cpu_map__new_online_cpus();
index 6b3aac283c371cdb34346e207680d316798e4ee7..5be294014d3b5ab289fadb2a76297bf21d6936fe 100644 (file)
@@ -351,7 +351,7 @@ static int test__switch_tracking(struct test_suite *test __maybe_unused, int sub
        const char *comm;
        int err = -1;
 
-       threads = thread_map__new(-1, getpid(), UINT_MAX);
+       threads = thread_map__new_by_tid(getpid());
        if (!threads) {
                pr_debug("thread_map__new failed!\n");
                goto out_err;
index 1fe521466bf445e83534de11663323083ec101a7..54209592168d8aaf01de031eac82f02ea61349ed 100644 (file)
@@ -115,7 +115,7 @@ static int test__thread_map_remove(struct test_suite *test __maybe_unused, int s
        TEST_ASSERT_VAL("failed to allocate map string",
                        asprintf(&str, "%d,%d", getpid(), getppid()) >= 0);
 
-       threads = thread_map__new_str(str, NULL, 0, false);
+       threads = thread_map__new_str(str, /*tid=*/NULL, /*all_threads=*/false);
        free(str);
 
        TEST_ASSERT_VAL("failed to allocate thread_map",
index bed91bc88510340183500f1bc5e392bed33f40ad..5664ebf6bbc66b75fcc3b852ddcf70378b09a07a 100644 (file)
@@ -1006,7 +1006,7 @@ int evlist__create_maps(struct evlist *evlist, struct target *target)
         * per-thread data. thread_map__new_str will call
         * thread_map__new_all_cpus to enumerate all threads.
         */
-       threads = thread_map__new_str(target->pid, target->tid, UINT_MAX, all_threads);
+       threads = thread_map__new_str(target->pid, target->tid, all_threads);
 
        if (!threads)
                return -1;
index 321c333877fa708854aed1955af0132312b8d66a..82666bcd2edadd6e4087b0ea45b72b823d6ac8d3 100644 (file)
@@ -566,14 +566,14 @@ struct pyrf_thread_map {
 static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads,
                                 PyObject *args, PyObject *kwargs)
 {
-       static char *kwlist[] = { "pid", "tid", "uid", NULL };
-       int pid = -1, tid = -1, uid = UINT_MAX;
+       static char *kwlist[] = { "pid", "tid", NULL };
+       int pid = -1, tid = -1;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iii",
-                                        kwlist, &pid, &tid, &uid))
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii",
+                                        kwlist, &pid, &tid))
                return -1;
 
-       pthreads->threads = thread_map__new(pid, tid, uid);
+       pthreads->threads = thread_map__new(pid, tid);
        if (pthreads->threads == NULL)
                return -1;
        return 0;
index b5f12390c3558016499b9dded1bf7d409c1738cc..ca193c1374ed4823dde3594d9013d992e94d6d68 100644 (file)
@@ -72,7 +72,7 @@ struct perf_thread_map *thread_map__new_by_tid(pid_t tid)
        return threads;
 }
 
-static struct perf_thread_map *__thread_map__new_all_cpus(uid_t uid)
+static struct perf_thread_map *thread_map__new_all_cpus(void)
 {
        DIR *proc;
        int max_threads = 32, items, i;
@@ -98,15 +98,6 @@ static struct perf_thread_map *__thread_map__new_all_cpus(uid_t uid)
                if (*end) /* only interested in proper numerical dirents */
                        continue;
 
-               snprintf(path, sizeof(path), "/proc/%s", dirent->d_name);
-
-               if (uid != UINT_MAX) {
-                       struct stat st;
-
-                       if (stat(path, &st) != 0 || st.st_uid != uid)
-                               continue;
-               }
-
                snprintf(path, sizeof(path), "/proc/%d/task", pid);
                items = scandir(path, &namelist, filter, NULL);
                if (items <= 0) {
@@ -157,24 +148,11 @@ out_free_namelist:
        goto out_closedir;
 }
 
-struct perf_thread_map *thread_map__new_all_cpus(void)
-{
-       return __thread_map__new_all_cpus(UINT_MAX);
-}
-
-struct perf_thread_map *thread_map__new_by_uid(uid_t uid)
-{
-       return __thread_map__new_all_cpus(uid);
-}
-
-struct perf_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)
 {
        if (pid != -1)
                return thread_map__new_by_pid(pid);
 
-       if (tid == -1 && uid != UINT_MAX)
-               return thread_map__new_by_uid(uid);
-
        return thread_map__new_by_tid(tid);
 }
 
@@ -289,15 +267,11 @@ out_free_threads:
        goto out;
 }
 
-struct perf_thread_map *thread_map__new_str(const char *pid, const char *tid,
-                                      uid_t uid, bool all_threads)
+struct perf_thread_map *thread_map__new_str(const char *pid, const char *tid, bool all_threads)
 {
        if (pid)
                return thread_map__new_by_pid_str(pid);
 
-       if (!tid && uid != UINT_MAX)
-               return thread_map__new_by_uid(uid);
-
        if (all_threads)
                return thread_map__new_all_cpus();
 
index 00ec05fc1656dbe6559450b1d1521e2a9e6c0f76..fc16d87f32fb87e27216038cc7625915db13b018 100644 (file)
@@ -11,13 +11,11 @@ struct perf_record_thread_map;
 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(pid_t pid, pid_t tid);
 struct perf_thread_map *thread_map__new_event(struct perf_record_thread_map *event);
 
 struct perf_thread_map *thread_map__new_str(const char *pid,
-               const char *tid, uid_t uid, bool all_threads);
+               const char *tid, bool all_threads);
 
 struct perf_thread_map *thread_map__new_by_tid_str(const char *tid_str);