From nobody Fri Dec 19 09:44:45 2025 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 683CC293B48 for ; Thu, 10 Apr 2025 17:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744306630; cv=none; b=GmEoBiz2wNKOwY320fZb69H13NfscEoDNGvANC7mT1ATcAQfIpOm9YLKNKlVapZ4EG09bUAWGI/DA+g1iBcGGZnwnKULhYzfVEbqD5zgTIOaUKtAC+p1z8sTuaxiKWt7DyWcgjXpLroJsrEFhrmDZHc5D23o/9BnwObfCnFcSmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744306630; c=relaxed/simple; bh=+ixP1qHJBFjj59ZtGOMdYOK7HgE7wWblrGVYMQO0l7I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=C/fyD3rfRN1pIP0UHeB3jdj3Dn8pmCXKprQjEvl0YOXtxySr/DGqUHb283rpw3UJgGLReOh9QQYx+JotMzeKm8WIQTeGOBrsvZ9VjkIdY2+84xT1vRIqeO6a4aIV1MH2Hbea7m5HYoRrwClQgrB6XOY+fprFq/dOv5m2tb+9eNA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UAtJe1sx; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UAtJe1sx" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ff8340d547so962286a91.2 for ; Thu, 10 Apr 2025 10:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1744306627; x=1744911427; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ckBZYcyyJUN9FjcUaUL5/ekJZ+dJKWbrJB0EF0qu50A=; b=UAtJe1sxMef7RiCPyfLSDNtLGATsM0Zgoa/S3eZypn5bvgWP9IVrPzgfcWy2BYVeQB BlRF0eCcVLGWKv3Mu4bJd3xc6vR5pr1ywEl9dRYsHMcEO3XyKYAbdtJWMHBDvZC7YVtC cuYNxqOJi6f+GoeZcPHNtr4P2qAJbVNqOi+ygO7OENKW3VJ/wEP6zFGrNiX0hGxlt8Lp OkD37m1uD1vWLniDg5qzj9rna+fRRZ86dCRD5CdgDhj2AIEwtJSeRMW5CQinVeue77hZ gHqBMmp56Am7HrXl8z+PXRkBQaM/6w90Jccz7SdEf8zCCu9G8VxZXYt0VDuankWRITSo vjuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744306627; x=1744911427; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ckBZYcyyJUN9FjcUaUL5/ekJZ+dJKWbrJB0EF0qu50A=; b=d02C1yMbTwiMgnFAfLXki6vQRdA9nMEFeADYbuaVpvKlLGE7+l/4QiCDoM+KjO8y+A RrcCltF+wMLcVZ85WhmLJGtxbb7WnlFVBykKLgZUUZne74XsEl7U3XnwzqpmEvUkMXXa Lqv/vW+bGBuWgKXTQnG7VgPiMHrQ8bk2xgPo7rQqv+L1IqcYo7ON7f0MNmqxeDlwb0Lf uycPJSXwdquDwH0koUNWy/RDasr+BPXlS20liNyxTtfrm4DnAhwvEkL6qXs4h5kz+/rC BrcmSB9wlZ7DqQ3kqsm3X5K1b42I6zbxbf51CIV7uA1Cj3s6gSiraYrO0HAPuW+yfEdh yxyg== X-Forwarded-Encrypted: i=1; AJvYcCWY3YCA8iX31Ra23BMbgThymGMOBWM+tx3QQVY7j47UL9Emp8fMZx6+GA8yCLpLdCVTC4cuN9TLNH+sN4Q=@vger.kernel.org X-Gm-Message-State: AOJu0YxxrJMF2M0bO+cx51k3wAgUZhZq6zlmJfOLv5i1f/Kp7gvvzGMe QSMqon8D3g1MNeNXrfBTbRyhagD0L6dep8ApclqIAgFBNHqxV0Jc4KqNdWJ1H82W38C/wilkMPx 3yti87A== X-Google-Smtp-Source: AGHT+IG1qOFPzSDf9Ewl3xwJO7ONlzQPJXL9CVsc0lXzOmGKPKFYYwMJamiZf+cuyQopWHvr1ogG7wLUF1hJ X-Received: from pjbsd3.prod.google.com ([2002:a17:90b:5143:b0:2ea:3a1b:f493]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3a46:b0:2ee:af31:a7bd with SMTP id 98e67ed59e1d1-30718b547a9mr5165280a91.5.1744306627554; Thu, 10 Apr 2025 10:37:07 -0700 (PDT) Date: Thu, 10 Apr 2025 10:36:31 -0700 In-Reply-To: <20250410173631.1713627-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250410173631.1713627-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog Message-ID: <20250410173631.1713627-13-irogers@google.com> Subject: [PATCH v2 12/12] perf thread_map: Remove uid options From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Dapeng Mi , Thomas Richter , Veronika Molnarova , Hao Ge , Howard Chu , Weilin Wang , Levi Yun , "Dr. David Alan Gilbert" , Dominique Martinet , Xu Yang , Tengda Wu , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- tools/perf/tests/event-times.c | 4 +-- tools/perf/tests/keep-tracking.c | 2 +- tools/perf/tests/mmap-basic.c | 2 +- tools/perf/tests/openat-syscall-all-cpus.c | 2 +- tools/perf/tests/openat-syscall.c | 2 +- tools/perf/tests/perf-time-to-tsc.c | 2 +- tools/perf/tests/switch-tracking.c | 2 +- tools/perf/tests/thread-map.c | 2 +- tools/perf/util/evlist.c | 2 +- tools/perf/util/python.c | 10 +++---- tools/perf/util/thread_map.c | 32 ++-------------------- tools/perf/util/thread_map.h | 6 ++-- 12 files changed, 20 insertions(+), 48 deletions(-) diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 2148024b4f4a..ae3b98bb42cf 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c @@ -62,7 +62,7 @@ static int attach__current_disabled(struct evlist *evlist) =20 pr_debug("attaching to current thread as disabled\n"); =20 - threads =3D thread_map__new(-1, getpid(), UINT_MAX); + threads =3D thread_map__new_by_tid(getpid()); if (threads =3D=3D NULL) { pr_debug("thread_map__new\n"); return -1; @@ -88,7 +88,7 @@ static int attach__current_enabled(struct evlist *evlist) =20 pr_debug("attaching to current thread as enabled\n"); =20 - threads =3D thread_map__new(-1, getpid(), UINT_MAX); + threads =3D thread_map__new_by_tid(getpid()); if (threads =3D=3D NULL) { pr_debug("failed to call thread_map__new\n"); return -1; diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-track= ing.c index 5a3b2bed07f3..eafb49eb0b56 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c @@ -78,7 +78,7 @@ static int test__keep_tracking(struct test_suite *test __= maybe_unused, int subte int found, err =3D -1; const char *comm; =20 - threads =3D thread_map__new(-1, getpid(), UINT_MAX); + threads =3D thread_map__new_by_tid(getpid()); CHECK_NOT_NULL__(threads); =20 cpus =3D perf_cpu_map__new_online_cpus(); diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index bd2106628b34..04b547c6bdbe 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -46,7 +46,7 @@ static int test__basic_mmap(struct test_suite *test __may= be_unused, int subtest char sbuf[STRERR_BUFSIZE]; struct mmap *md; =20 - threads =3D thread_map__new(-1, getpid(), UINT_MAX); + threads =3D thread_map__new_by_tid(getpid()); if (threads =3D=3D NULL) { pr_debug("thread_map__new\n"); return -1; diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/= openat-syscall-all-cpus.c index fb114118c876..3644d6f52c07 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -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 =3D 111, i; cpu_set_t cpu_set; - struct perf_thread_map *threads =3D thread_map__new(-1, getpid(), UINT_MA= X); + struct perf_thread_map *threads =3D thread_map__new_by_tid(getpid()); char sbuf[STRERR_BUFSIZE]; char errbuf[BUFSIZ]; =20 diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-sy= scall.c index 131b62271bfa..b54cbe5f1808 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c @@ -20,7 +20,7 @@ static int test__openat_syscall_event(struct test_suite *= test __maybe_unused, int err =3D TEST_FAIL, fd; struct evsel *evsel; unsigned int nr_openat_calls =3D 111, i; - struct perf_thread_map *threads =3D thread_map__new(-1, getpid(), UINT_MA= X); + struct perf_thread_map *threads =3D thread_map__new_by_tid(getpid()); char sbuf[STRERR_BUFSIZE]; char errbuf[BUFSIZ]; =20 diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-ti= me-to-tsc.c index d3e40fa5482c..d4437410c99f 100644 --- a/tools/perf/tests/perf-time-to-tsc.c +++ b/tools/perf/tests/perf-time-to-tsc.c @@ -90,7 +90,7 @@ static int test__perf_time_to_tsc(struct test_suite *test= __maybe_unused, int su struct mmap *md; =20 =20 - threads =3D thread_map__new(-1, getpid(), UINT_MAX); + threads =3D thread_map__new_by_tid(getpid()); CHECK_NOT_NULL__(threads); =20 cpus =3D perf_cpu_map__new_online_cpus(); diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-t= racking.c index 8df3f9d9ffd2..96f880c922d1 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -351,7 +351,7 @@ static int test__switch_tracking(struct test_suite *tes= t __maybe_unused, int sub const char *comm; int err =3D -1; =20 - threads =3D thread_map__new(-1, getpid(), UINT_MAX); + threads =3D thread_map__new_by_tid(getpid()); if (!threads) { pr_debug("thread_map__new failed!\n"); goto out_err; diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c index 1fe521466bf4..54209592168d 100644 --- a/tools/perf/tests/thread-map.c +++ b/tools/perf/tests/thread-map.c @@ -115,7 +115,7 @@ static int test__thread_map_remove(struct test_suite *t= est __maybe_unused, int s TEST_ASSERT_VAL("failed to allocate map string", asprintf(&str, "%d,%d", getpid(), getppid()) >=3D 0); =20 - threads =3D thread_map__new_str(str, NULL, 0, false); + threads =3D thread_map__new_str(str, /*tid=3D*/NULL, /*all_threads=3D*/fa= lse); free(str); =20 TEST_ASSERT_VAL("failed to allocate thread_map", diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 2e1f14bc8461..8a7ec845a611 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -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 =3D thread_map__new_str(target->pid, target->tid, UINT_MAX, all_t= hreads); + threads =3D thread_map__new_str(target->pid, target->tid, all_threads); =20 if (!threads) return -1; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index f3c05da25b4a..56f8ae4cebf7 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -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[] =3D { "pid", "tid", "uid", NULL }; - int pid =3D -1, tid =3D -1, uid =3D UINT_MAX; + static char *kwlist[] =3D { "pid", "tid", NULL }; + int pid =3D -1, tid =3D -1; =20 - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iii", - kwlist, &pid, &tid, &uid)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", + kwlist, &pid, &tid)) return -1; =20 - pthreads->threads =3D thread_map__new(pid, tid, uid); + pthreads->threads =3D thread_map__new(pid, tid); if (pthreads->threads =3D=3D NULL) return -1; return 0; diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index b5f12390c355..ca193c1374ed 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c @@ -72,7 +72,7 @@ struct perf_thread_map *thread_map__new_by_tid(pid_t tid) return threads; } =20 -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 =3D 32, items, i; @@ -98,15 +98,6 @@ static struct perf_thread_map *__thread_map__new_all_cpu= s(uid_t uid) if (*end) /* only interested in proper numerical dirents */ continue; =20 - snprintf(path, sizeof(path), "/proc/%s", dirent->d_name); - - if (uid !=3D UINT_MAX) { - struct stat st; - - if (stat(path, &st) !=3D 0 || st.st_uid !=3D uid) - continue; - } - snprintf(path, sizeof(path), "/proc/%d/task", pid); items =3D scandir(path, &namelist, filter, NULL); if (items <=3D 0) { @@ -157,24 +148,11 @@ static struct perf_thread_map *__thread_map__new_all_= cpus(uid_t uid) goto out_closedir; } =20 -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 !=3D -1) return thread_map__new_by_pid(pid); =20 - if (tid =3D=3D -1 && uid !=3D UINT_MAX) - return thread_map__new_by_uid(uid); - return thread_map__new_by_tid(tid); } =20 @@ -289,15 +267,11 @@ struct perf_thread_map *thread_map__new_by_tid_str(co= nst char *tid_str) goto out; } =20 -struct perf_thread_map *thread_map__new_str(const char *pid, const char *t= id, - uid_t uid, bool all_threads) +struct perf_thread_map *thread_map__new_str(const char *pid, const char *t= id, bool all_threads) { if (pid) return thread_map__new_by_pid_str(pid); =20 - if (!tid && uid !=3D UINT_MAX) - return thread_map__new_by_uid(uid); - if (all_threads) return thread_map__new_all_cpus(); =20 diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h index 00ec05fc1656..fc16d87f32fb 100644 --- a/tools/perf/util/thread_map.h +++ b/tools/perf/util/thread_map.h @@ -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_ma= p *event); =20 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); =20 struct perf_thread_map *thread_map__new_by_tid_str(const char *tid_str); =20 --=20 2.49.0.604.gff1f9ca942-goog