From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796325474; b=a4EZBkH3cDICif1++ozXaPV2cScGeSaEsTZJD/joDmcw2PBAQ7uXzXiJ1WDSWJcK5EPI CxCZ3JTvNYtaprASsIK5KasECjHkP8QBGRqUfrd89q7uNIJL6Mc+/a78h6YzEf9A5ketN qEMJB3WMvby8H8m8sta1faH7PNO8JuCbPGsIOIaKpoPOQPzmyoBByArREpdGi3EcbCAcK E3RREnDRsWGfr1NsoHGZgjdOTPA7VTQULaJN+fQ2jhB4nK096uaXR7Ozp/1NcOcir3A8j Pcbi3H/H5UcDruQNdwF7WQSC1eeyOe/icFe5NVJvsf1jJINbRCeolOV+o5eG+k9eagw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796325474; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=fJTLhrdKFnL18NRwYFcHYKehdBvUBDGmL9KcQZPNqhw=; b=3d35btRfo6fwcMG6SA0nEqnUrKoiHgxlnwkc84twVvgI2UOJsU9jqqpIlNrkaM+W+Lpp l0n1hZydnMvKTZn4xb7RAbJfi0LuE9Ie6NQ8FQQFFY3DbxmG/pso8CSBkVpwBAvXvVvV1 9pQMUIvNR04QodqkWhpcSNEZN0XG5Mr+k8bNi44Bk/0BkLGkeTvJ/ToM/ZkxOmyNlQWRi ZwOzFLJlZIYA2/hLo97bRb+Iz2dYLkBmFQTR+EV5OxbP4R7CXq5ZHfNeHoKufzyl64FdO 1WMjlGPFSvVn8xE1ZSQ6jZBb7ZoGlClZnc28GN+vD6aPZq9GgzYd/rN+PWaIDH7ax6Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=abpxCUJr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F2D0606A32F; Thu, 3 Dec 2026 19:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=abpxCUJr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B5A11F000C2; Thu, 3 Dec 2026 19:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796325474; bh=fJTLhrdKFnL18NRwYFcHYKehdBvUBDGmL9KcQZPNqhw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=abpxCUJrYcl3C4bs3Z56sTSsYOEW2/8VFExgAJPPn8rPeQdub4V0fvvcfpl69bEAV R1yPGPo5rGFTqgwll4jGjJkCbaqhMrYAP6j6nGjX5H+HEDYTxIuedCqSG86WH8hf3x ciIiS9t7pDF9pRBtkPIfzIfUpElkEK+FaGVqBMtJlHApoGMa+8PgQDHcXPJXj/3s5M cchQb2yvDPgsXFzN8ychsJ5voCVVRReIva3Aiwwzg9usEUrL8wL1g+XakyMuiiY1fB Usr9gpypgQbrzdrsBX3uhNchVuIH79s2ZIPm+ZqnxHBIzmrPjw8xBJ+cAqzyvZiydM j7PuCFQg3OCGw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 2/2] perf test: Add filtered event enabled time tests to event-times Reply-To: sashiko-reviews@lists.linux.dev To: "Ian Rogers" Cc: linux-perf-users@vger.kernel.org, bpf@vger.kernel.org In-Reply-To: <77db7c446d31285aef889a726055489f8f1f2c10.1796323635.git.irogers@google.com> References: <6e0c4ab555fda856605bd818854a6ef8ced4fcbd.1796323635.git.irogers@google.com> <77db7c446d31285aef889a726055489f8f1f2c10.1796323635.git.irogers@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 19:17:54 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] perf test: missing exclusive flag for pinned PMU event-times subtests - [Low] perf test: uninitialized rt_child read on read_times() failure - [Low] perf tools: zfree() may clobber errno before EINVAL check in affinity__setup() - [Low] perf test: suite__event_times omits needs_mlock while mmapping perf fd -- commit d7c83c2e6723a4a0fc8b63cdeef1ea6d8a997d9d Author: Ian Rogers perf test: Add filtered event enabled time tests to event-times This commit adds four filtered event enabled time subtests to the event-times perf test suite and hardens tools/perf/util/affinity.{c,h} to retry on EINVAL for large cpumasks, check CPU membership, and return an error status from affinity__set(). > diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-time= s.c > index 56dd37ca760ec..7068be72e3471 100644 > --- a/tools/perf/tests/event-times.c > +++ b/tools/perf/tests/event-times.c [ ... ] > @@ -239,4 +252,842 @@ static int test__event_times(struct test_suite *tes= t __maybe_unused, int subtest > return ret; > } [ ... ] > + if (read_times(fd, &rt_child) < 0 || > + rt_child.run <=3D rt_after.run || rt_child.ena !=3D rt_child.run) { > + pr_debug("FAILED: inherited task+CPU mismatch: ena=3D%" PRIu64 " run= =3D%" PRIu64 "\n", > + rt_child.ena, rt_child.run); > + goto out; > + } [Severity: Low] Can pr_debug() read uninitialized stack memory here when read_times() fails? rt_child is declared uninitialized on the stack in test__event_times_task_and_cpu(), so if read_times(fd, &rt_child) returns -1 the short-circuit enters this block and prints uninitialized rt_child.ena and rt_child.run. Checking read_times() separately, as done earlier in the same function, avoids the uninitialized read. [ ... ] > +static struct test_case tests__event_times[] =3D { > + TEST_CASE("Basic event times", event_times), > + TEST_CASE_REASON("Task and CPU filtered event times", > + event_times_task_and_cpu, > + "permissions or <2 allowed CPUs"), > + TEST_CASE_REASON("Hybrid PMU filtered event times", > + event_times_hybrid, > + "not hybrid or permissions"), > + TEST_CASE_REASON("Multiplexed and group filtered event times", > + event_times_mux_migration, > + "no hardware PMU or <2 allowed CPUs"), > + TEST_CASE_REASON("Pinned-blocked and group rollback event times", > + event_times_pinned_rollback, > + "no hardware PMU or <2 allowed CPUs"), > + { .name =3D NULL, } > +}; [Severity: Medium] Should event_times_pinned_rollback and event_times_mux_migration use TEST_CASE_REASON_EXCLUSIVE instead of TEST_CASE_REASON? Default parallel perf test runs non-exclusive cases concurrently in pass 1 and only serializes exclusive ones in pass 2. test_one_pmu_pinned_blocked_and_rollback() holds a pinned, exclusive PMU event on cpu0 for 45 ms, setting cpc->exclusive and blocking other events. Concurrent pass-1 hardware PMU tests can either be starved or compete with pin_fd and force it into PERF_EVENT_STATE_ERROR, causing spurious TEST_FAIL or TEST_SKIP results. test_one_pmu_mux_migration() similarly opens 15 hardware PMU events on cpu0 while other pass-1 PMU tests are running. > + > +struct test_suite suite__event_times =3D { > + .desc =3D "Event times", > + .test_cases =3D tests__event_times, > +}; [Severity: Low] Does suite__event_times need .needs_mlock =3D true? test__event_times_task_and_cpu() mmaps the perf event userpage for the duration of the subtest, which charges one page against current_user()->perf_mlock in perf_mmap_rb(). Without .needs_mlock =3D tru= e, it runs concurrently with needs_mlock suites holding mlock_budget->lock. In an unprivileged parallel perf test run with no spare RLIMIT_MEMLOCK, this can cause a concurrent needs_mlock test to fail with EPERM, or cause mmap() here to return MAP_FAILED and silently skip the userpage check. > diff --git a/tools/perf/util/affinity.c b/tools/perf/util/affinity.c > index 6c64b5f69a4e0..e610eb959347d 100644 > --- a/tools/perf/util/affinity.c > +++ b/tools/perf/util/affinity.c [ ... ] > @@ -10,73 +11,98 @@ > #include "cpumap.h" > #include "affinity.h" [ ... ] > int affinity__setup(struct affinity *a) > { > - int cpu_set_size =3D get_cpu_set_size(); > + size_t bits =3D get_cpu_set_bits(); > =20 > - a->orig_cpus =3D bitmap_zalloc(cpu_set_size * 8); > - if (!a->orig_cpus) > - return -1; > - sched_getaffinity(0, cpu_set_size, (cpu_set_t *)a->orig_cpus); > - a->sched_cpus =3D bitmap_zalloc(cpu_set_size * 8); > + *a =3D (struct affinity){}; > + for (;;) { > + unsigned long *orig =3D bitmap_zalloc(bits); > + > + if (!orig) > + return -1; > + if (sched_getaffinity(0, bits / 8, (cpu_set_t *)orig) =3D=3D 0) { > + a->orig_cpus =3D orig; > + break; > + } > + zfree(&orig); > + if (errno !=3D EINVAL || bits >=3D (1U << 20)) > + return -1; > + bits <<=3D 1; > + } [Severity: Low] Can zfree(&orig) clobber errno before the errno !=3D EINVAL check? zfree() calls free(), which is not guaranteed to preserve errno under POSIX.1-2008 or older glibc. If free() modifies errno on a large-cpumask system, affinity__setup() returns -1 instead of retrying with a larger buffer. Saving errno before calling zfree(&orig) avoids this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/6e0c4ab555fda856605= bd818854a6ef8ced4fcbd.1796323635.git.irogers@google.com?part=3D2