* [PATCH v2 1/2] perf test workload noploop: Name the noploop process @ 2025-06-19 0:20 Ian Rogers 2025-06-19 0:20 ` [PATCH v2 2/2] perf test: Add sched latency and script shell tests Ian Rogers ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Ian Rogers @ 2025-06-19 0:20 UTC (permalink / raw) To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users Name the noploop process "perf-noploop" so that tests can easily check for its existence. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/tests/workloads/noploop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c index 940ea5910a84..8b954d466083 100644 --- a/tools/perf/tests/workloads/noploop.c +++ b/tools/perf/tests/workloads/noploop.c @@ -2,6 +2,8 @@ #include <stdlib.h> #include <signal.h> #include <unistd.h> +#include <linux/prctl.h> +#include <sys/prctl.h> #include <linux/compiler.h> #include "../tests.h" @@ -16,6 +18,7 @@ static int noploop(int argc, const char **argv) { int sec = 1; + prctl(PR_SET_NAME, "perf-noploop"); if (argc > 0) sec = atoi(argv[0]); -- 2.50.0.rc2.701.gf1e915cc24-goog ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 2/2] perf test: Add sched latency and script shell tests 2025-06-19 0:20 [PATCH v2 1/2] perf test workload noploop: Name the noploop process Ian Rogers @ 2025-06-19 0:20 ` Ian Rogers 2025-06-20 10:01 ` James Clark 2025-06-20 19:41 ` Namhyung Kim 2025-06-20 10:01 ` [PATCH v2 1/2] perf test workload noploop: Name the noploop process James Clark 2025-06-20 19:36 ` Namhyung Kim 2 siblings, 2 replies; 14+ messages in thread From: Ian Rogers @ 2025-06-19 0:20 UTC (permalink / raw) To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users Add shell tests covering the `perf sched latency` and `perf sched script` commands. The test creates 2 noploop processes on the same forced CPU, it then checks that the process appears in the `perf sched` output. Signed-off-by: Ian Rogers <irogers@google.com> --- v2: Skip the test if not root due to permissions. --- tools/perf/tests/shell/sched.sh | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 tools/perf/tests/shell/sched.sh diff --git a/tools/perf/tests/shell/sched.sh b/tools/perf/tests/shell/sched.sh new file mode 100755 index 000000000000..0a4fe3f414e1 --- /dev/null +++ b/tools/perf/tests/shell/sched.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# perf sched tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +if [ "$(id -u)" != 0 ]; then + echo "[Skip] No root permission" + exit 2 +fi + +err=0 +perfdata=$(mktemp /tmp/__perf_test_sched.perf.data.XXXXX) +PID1=0 +PID2=0 + +cleanup() { + rm -f "${perfdata}" + rm -f "${perfdata}".old + + trap - EXIT TERM INT +} + +trap_cleanup() { + echo "Unexpected signal in ${FUNCNAME[1]}" + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +start_noploops() { + # Start two noploop workloads on CPU0 to trigger scheduling. + taskset -c 0 perf test -w noploop 10 & + PID1=$! + taskset -c 0 perf test -w noploop 10 & + PID2=$! + + if ! grep -q 'Cpus_allowed_list:\s*0$' "/proc/$PID1/status" + then + echo "Sched [Error taskset did not work for the 1st noploop ($PID1)]" + grep Cpus_allowed /proc/$PID1/status + err=1 + fi + + if ! grep -q 'Cpus_allowed_list:\s*0$' "/proc/$PID2/status" + then + echo "Sched [Error taskset did not work for the 2nd noploop ($PID2)]" + grep Cpus_allowed /proc/$PID2/status + err=1 + fi +} + +cleanup_noploops() { + kill "$PID1" "$PID2" +} + +test_sched_latency() { + echo "Sched latency" + + start_noploops + + perf sched record --no-inherit -o "${perfdata}" sleep 1 + if ! perf sched latency -i "${perfdata}" | grep -q perf-noploop + then + echo "Sched latency [Failed missing output]" + err=1 + fi + + cleanup_noploops +} + +test_sched_script() { + echo "Sched script" + + start_noploops + + perf sched record --no-inherit -o "${perfdata}" sleep 1 + if ! perf sched script -i "${perfdata}" | grep -q perf-noploop + then + echo "Sched script [Failed missing output]" + err=1 + fi + + cleanup_noploops +} + +test_sched_latency +test_sched_script + +cleanup +exit $err -- 2.50.0.rc2.701.gf1e915cc24-goog ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/2] perf test: Add sched latency and script shell tests 2025-06-19 0:20 ` [PATCH v2 2/2] perf test: Add sched latency and script shell tests Ian Rogers @ 2025-06-20 10:01 ` James Clark 2025-06-20 19:41 ` Namhyung Kim 1 sibling, 0 replies; 14+ messages in thread From: James Clark @ 2025-06-20 10:01 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On 19/06/2025 1:20 am, Ian Rogers wrote: > Add shell tests covering the `perf sched latency` and `perf sched > script` commands. The test creates 2 noploop processes on the same > forced CPU, it then checks that the process appears in the `perf > sched` output. > > Signed-off-by: Ian Rogers <irogers@google.com> > --- > v2: Skip the test if not root due to permissions. > --- > tools/perf/tests/shell/sched.sh | 91 +++++++++++++++++++++++++++++++++ > 1 file changed, 91 insertions(+) > create mode 100755 tools/perf/tests/shell/sched.sh > > diff --git a/tools/perf/tests/shell/sched.sh b/tools/perf/tests/shell/sched.sh > new file mode 100755 > index 000000000000..0a4fe3f414e1 > --- /dev/null > +++ b/tools/perf/tests/shell/sched.sh > @@ -0,0 +1,91 @@ > +#!/bin/bash > +# perf sched tests > +# SPDX-License-Identifier: GPL-2.0 > + > +set -e > + > +if [ "$(id -u)" != 0 ]; then > + echo "[Skip] No root permission" > + exit 2 > +fi > + > +err=0 > +perfdata=$(mktemp /tmp/__perf_test_sched.perf.data.XXXXX) > +PID1=0 > +PID2=0 > + > +cleanup() { > + rm -f "${perfdata}" > + rm -f "${perfdata}".old > + > + trap - EXIT TERM INT > +} > + > +trap_cleanup() { > + echo "Unexpected signal in ${FUNCNAME[1]}" > + cleanup > + exit 1 > +} > +trap trap_cleanup EXIT TERM INT > + > +start_noploops() { > + # Start two noploop workloads on CPU0 to trigger scheduling. > + taskset -c 0 perf test -w noploop 10 & > + PID1=$! > + taskset -c 0 perf test -w noploop 10 & > + PID2=$! > + > + if ! grep -q 'Cpus_allowed_list:\s*0$' "/proc/$PID1/status" Hi Ian, Because taskset is also run in the background it's possible to grep the proc file before it's managed to re-pin itself. I saw some intermittent failures of the test because of this. I think you'd need to run noploop in the background but taskset in the foreground and give it the pid of noploop to make sure it finishes before grepping. Other than that the test seems ok: Reviewed-by: James Clark <james.clark@linaro.org> Thanks James > + then > + echo "Sched [Error taskset did not work for the 1st noploop ($PID1)]" > + grep Cpus_allowed /proc/$PID1/status > + err=1 > + fi > + > + if ! grep -q 'Cpus_allowed_list:\s*0$' "/proc/$PID2/status" > + then > + echo "Sched [Error taskset did not work for the 2nd noploop ($PID2)]" > + grep Cpus_allowed /proc/$PID2/status > + err=1 > + fi > +} > + > +cleanup_noploops() { > + kill "$PID1" "$PID2" > +} > + > +test_sched_latency() { > + echo "Sched latency" > + > + start_noploops > + > + perf sched record --no-inherit -o "${perfdata}" sleep 1 > + if ! perf sched latency -i "${perfdata}" | grep -q perf-noploop > + then > + echo "Sched latency [Failed missing output]" > + err=1 > + fi > + > + cleanup_noploops > +} > + > +test_sched_script() { > + echo "Sched script" > + > + start_noploops > + > + perf sched record --no-inherit -o "${perfdata}" sleep 1 > + if ! perf sched script -i "${perfdata}" | grep -q perf-noploop > + then > + echo "Sched script [Failed missing output]" > + err=1 > + fi > + > + cleanup_noploops > +} > + > +test_sched_latency > +test_sched_script > + > +cleanup > +exit $err ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/2] perf test: Add sched latency and script shell tests 2025-06-19 0:20 ` [PATCH v2 2/2] perf test: Add sched latency and script shell tests Ian Rogers 2025-06-20 10:01 ` James Clark @ 2025-06-20 19:41 ` Namhyung Kim 2025-06-28 1:25 ` Ian Rogers 1 sibling, 1 reply; 14+ messages in thread From: Namhyung Kim @ 2025-06-20 19:41 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Wed, Jun 18, 2025 at 05:20:34PM -0700, Ian Rogers wrote: > Add shell tests covering the `perf sched latency` and `perf sched > script` commands. The test creates 2 noploop processes on the same > forced CPU, it then checks that the process appears in the `perf > sched` output. > > Signed-off-by: Ian Rogers <irogers@google.com> > --- > v2: Skip the test if not root due to permissions. > --- > tools/perf/tests/shell/sched.sh | 91 +++++++++++++++++++++++++++++++++ > 1 file changed, 91 insertions(+) > create mode 100755 tools/perf/tests/shell/sched.sh > > diff --git a/tools/perf/tests/shell/sched.sh b/tools/perf/tests/shell/sched.sh > new file mode 100755 > index 000000000000..0a4fe3f414e1 > --- /dev/null > +++ b/tools/perf/tests/shell/sched.sh > @@ -0,0 +1,91 @@ > +#!/bin/bash > +# perf sched tests > +# SPDX-License-Identifier: GPL-2.0 > + > +set -e > + > +if [ "$(id -u)" != 0 ]; then > + echo "[Skip] No root permission" > + exit 2 > +fi > + > +err=0 > +perfdata=$(mktemp /tmp/__perf_test_sched.perf.data.XXXXX) > +PID1=0 > +PID2=0 > + > +cleanup() { > + rm -f "${perfdata}" > + rm -f "${perfdata}".old > + > + trap - EXIT TERM INT > +} > + > +trap_cleanup() { > + echo "Unexpected signal in ${FUNCNAME[1]}" > + cleanup > + exit 1 > +} > +trap trap_cleanup EXIT TERM INT > + > +start_noploops() { > + # Start two noploop workloads on CPU0 to trigger scheduling. > + taskset -c 0 perf test -w noploop 10 & > + PID1=$! > + taskset -c 0 perf test -w noploop 10 & > + PID2=$! You can use 'thloop' workload which runs 2 threads at the same time. Then you don't need to handle the background processes and run it directly with perf test. Thanks, Namhyung > + > + if ! grep -q 'Cpus_allowed_list:\s*0$' "/proc/$PID1/status" > + then > + echo "Sched [Error taskset did not work for the 1st noploop ($PID1)]" > + grep Cpus_allowed /proc/$PID1/status > + err=1 > + fi > + > + if ! grep -q 'Cpus_allowed_list:\s*0$' "/proc/$PID2/status" > + then > + echo "Sched [Error taskset did not work for the 2nd noploop ($PID2)]" > + grep Cpus_allowed /proc/$PID2/status > + err=1 > + fi > +} > + > +cleanup_noploops() { > + kill "$PID1" "$PID2" > +} > + > +test_sched_latency() { > + echo "Sched latency" > + > + start_noploops > + > + perf sched record --no-inherit -o "${perfdata}" sleep 1 > + if ! perf sched latency -i "${perfdata}" | grep -q perf-noploop > + then > + echo "Sched latency [Failed missing output]" > + err=1 > + fi > + > + cleanup_noploops > +} > + > +test_sched_script() { > + echo "Sched script" > + > + start_noploops > + > + perf sched record --no-inherit -o "${perfdata}" sleep 1 > + if ! perf sched script -i "${perfdata}" | grep -q perf-noploop > + then > + echo "Sched script [Failed missing output]" > + err=1 > + fi > + > + cleanup_noploops > +} > + > +test_sched_latency > +test_sched_script > + > +cleanup > +exit $err > -- > 2.50.0.rc2.701.gf1e915cc24-goog > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/2] perf test: Add sched latency and script shell tests 2025-06-20 19:41 ` Namhyung Kim @ 2025-06-28 1:25 ` Ian Rogers 0 siblings, 0 replies; 14+ messages in thread From: Ian Rogers @ 2025-06-28 1:25 UTC (permalink / raw) To: Namhyung Kim Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Fri, Jun 20, 2025 at 12:41 PM Namhyung Kim <namhyung@kernel.org> wrote: > You can use 'thloop' workload which runs 2 threads at the same time. > Then you don't need to handle the background processes and run it > directly with perf test. v3 sent. I held off changing noploop to thloop as I think 2 separate processes is a little clearer: https://lore.kernel.org/lkml/20250628012302.1242532-1-irogers@google.com/ Thanks, Ian ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-19 0:20 [PATCH v2 1/2] perf test workload noploop: Name the noploop process Ian Rogers 2025-06-19 0:20 ` [PATCH v2 2/2] perf test: Add sched latency and script shell tests Ian Rogers @ 2025-06-20 10:01 ` James Clark 2025-06-20 19:36 ` Namhyung Kim 2 siblings, 0 replies; 14+ messages in thread From: James Clark @ 2025-06-20 10:01 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On 19/06/2025 1:20 am, Ian Rogers wrote: > Name the noploop process "perf-noploop" so that tests can easily check > for its existence. > > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/perf/tests/workloads/noploop.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c > index 940ea5910a84..8b954d466083 100644 > --- a/tools/perf/tests/workloads/noploop.c > +++ b/tools/perf/tests/workloads/noploop.c > @@ -2,6 +2,8 @@ > #include <stdlib.h> > #include <signal.h> > #include <unistd.h> > +#include <linux/prctl.h> > +#include <sys/prctl.h> > #include <linux/compiler.h> > #include "../tests.h" > > @@ -16,6 +18,7 @@ static int noploop(int argc, const char **argv) > { > int sec = 1; > > + prctl(PR_SET_NAME, "perf-noploop"); > if (argc > 0) > sec = atoi(argv[0]); > Reviewed-by: James Clark <james.clark@linaro.org> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-19 0:20 [PATCH v2 1/2] perf test workload noploop: Name the noploop process Ian Rogers 2025-06-19 0:20 ` [PATCH v2 2/2] perf test: Add sched latency and script shell tests Ian Rogers 2025-06-20 10:01 ` [PATCH v2 1/2] perf test workload noploop: Name the noploop process James Clark @ 2025-06-20 19:36 ` Namhyung Kim 2025-06-23 15:12 ` Ian Rogers 2 siblings, 1 reply; 14+ messages in thread From: Namhyung Kim @ 2025-06-20 19:36 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users Hi Ian, On Wed, Jun 18, 2025 at 05:20:33PM -0700, Ian Rogers wrote: > Name the noploop process "perf-noploop" so that tests can easily check > for its existence. > > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/perf/tests/workloads/noploop.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c > index 940ea5910a84..8b954d466083 100644 > --- a/tools/perf/tests/workloads/noploop.c > +++ b/tools/perf/tests/workloads/noploop.c > @@ -2,6 +2,8 @@ > #include <stdlib.h> > #include <signal.h> > #include <unistd.h> > +#include <linux/prctl.h> > +#include <sys/prctl.h> I'm afraid it'd introduce a build failure on musl. Please see https://lore.kernel.org/linux-perf-users/20250611092542.F4ooE2FL@linutronix.de/ I think <sys/prctl.h> would be enough. Thanks, Namhyung > #include <linux/compiler.h> > #include "../tests.h" > > @@ -16,6 +18,7 @@ static int noploop(int argc, const char **argv) > { > int sec = 1; > > + prctl(PR_SET_NAME, "perf-noploop"); > if (argc > 0) > sec = atoi(argv[0]); > > -- > 2.50.0.rc2.701.gf1e915cc24-goog > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-20 19:36 ` Namhyung Kim @ 2025-06-23 15:12 ` Ian Rogers 2025-06-23 17:45 ` Arnaldo Carvalho de Melo 0 siblings, 1 reply; 14+ messages in thread From: Ian Rogers @ 2025-06-23 15:12 UTC (permalink / raw) To: Namhyung Kim, Sebastian Andrzej Siewior Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Fri, Jun 20, 2025 at 12:36 PM Namhyung Kim <namhyung@kernel.org> wrote: > > Hi Ian, > > On Wed, Jun 18, 2025 at 05:20:33PM -0700, Ian Rogers wrote: > > Name the noploop process "perf-noploop" so that tests can easily check > > for its existence. > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > --- > > tools/perf/tests/workloads/noploop.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c > > index 940ea5910a84..8b954d466083 100644 > > --- a/tools/perf/tests/workloads/noploop.c > > +++ b/tools/perf/tests/workloads/noploop.c > > @@ -2,6 +2,8 @@ > > #include <stdlib.h> > > #include <signal.h> > > #include <unistd.h> > > +#include <linux/prctl.h> > > +#include <sys/prctl.h> > > I'm afraid it'd introduce a build failure on musl. Please see > > https://lore.kernel.org/linux-perf-users/20250611092542.F4ooE2FL@linutronix.de/ > > I think <sys/prctl.h> would be enough. Hi Namhyung, we could do that but in the glibc man page it says: https://man7.org/linux/man-pages/man2/prctl.2.html ``` #include <linux/prctl.h> /* Definition of PR_* constants */ #include <sys/prctl.h> ``` So wouldn't the PR_SET_NAME definition potentially be missing then? We could fill in the missing definition with `#ifndef PR_SET_NAME` it seems sub-optimal - I see this is what was done in the linked to changes. Perhaps we need something like a tools/perf/util/prctl.h, and a feature test, then in that we have something like: ``` /* A header file to work around musl libc breakages caused conflicting definitions in linux/prctl.h . */ #ifndef HAVE_SENSIBLE_PRCTL # include <linux/prctl.h> # include <sys/prctl.h> #else // !HAVE_SENSIBLE_PRCTL # include <sys/prctl.h> # ifndef PR_SET_NAME # define PR_SET_NAME 15 # endif // PR_SET_NAME # ifndef PR_FUTEX_HASH # define PR_FUTEX_HASH 78 # define PR_FUTEX_HASH_SET_SLOTS 1 # define FH_FLAG_IMMUTABLE (1ULL << 0) # define PR_FUTEX_HASH_GET_SLOTS 2 # define PR_FUTEX_HASH_GET_IMMUTABLE 3 # endif // PR_FUTEX_HASH #endif // HAVE_SENSIBLE_PRCTL ``` The feature test would just be to include the two headers and see if the build breaks. It'd be nice to think musl was slowly getting fixed. I notice we're carrying two comments in the code about working around musl, but I suspect we do this kind of thing in a lot of places (just knowing the issues that come up from yourself and Arnaldo when trying to integrate patches). It'd be nice if perf's code could keep close to what the man page, or whatever, is saying the standard should be, rather than doing some kind of adhoc linux/prctl.h rewrite (or if we are doing that, make the code more explicit that it's what we're doing). It'd be nice to think that the perf code could be clean wrt analyses like "include what you use" [1], but strategically removing #includes to try to work around musl issues seems like the opposite of this. Thanks, Ian [1] https://github.com/include-what-you-use/include-what-you-use > Thanks, > Namhyung > > > > #include <linux/compiler.h> > > #include "../tests.h" > > > > @@ -16,6 +18,7 @@ static int noploop(int argc, const char **argv) > > { > > int sec = 1; > > > > + prctl(PR_SET_NAME, "perf-noploop"); > > if (argc > 0) > > sec = atoi(argv[0]); > > > > -- > > 2.50.0.rc2.701.gf1e915cc24-goog > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-23 15:12 ` Ian Rogers @ 2025-06-23 17:45 ` Arnaldo Carvalho de Melo 2025-06-23 18:05 ` Ian Rogers 0 siblings, 1 reply; 14+ messages in thread From: Arnaldo Carvalho de Melo @ 2025-06-23 17:45 UTC (permalink / raw) To: Ian Rogers Cc: Namhyung Kim, Sebastian Andrzej Siewior, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Mon, Jun 23, 2025 at 08:12:47AM -0700, Ian Rogers wrote: > On Fri, Jun 20, 2025 at 12:36 PM Namhyung Kim <namhyung@kernel.org> wrote: > > I'm afraid it'd introduce a build failure on musl. Please see > > https://lore.kernel.org/linux-perf-users/20250611092542.F4ooE2FL@linutronix.de/ > > I think <sys/prctl.h> would be enough. > we could do that but in the glibc man page it says: > https://man7.org/linux/man-pages/man2/prctl.2.html > ``` > #include <linux/prctl.h> /* Definition of PR_* constants */ > #include <sys/prctl.h> > ``` > It'd be nice to think musl was slowly getting fixed. I notice we're Sebastian reported on the musl libc, its maintainer replied: https://www.openwall.com/lists/musl/2025/06/12/11 - ARnaldo ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-23 17:45 ` Arnaldo Carvalho de Melo @ 2025-06-23 18:05 ` Ian Rogers 2025-06-23 18:14 ` Namhyung Kim 0 siblings, 1 reply; 14+ messages in thread From: Ian Rogers @ 2025-06-23 18:05 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Namhyung Kim, Sebastian Andrzej Siewior, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Mon, Jun 23, 2025 at 10:45 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > On Mon, Jun 23, 2025 at 08:12:47AM -0700, Ian Rogers wrote: > > On Fri, Jun 20, 2025 at 12:36 PM Namhyung Kim <namhyung@kernel.org> wrote: > > > I'm afraid it'd introduce a build failure on musl. Please see > > > > https://lore.kernel.org/linux-perf-users/20250611092542.F4ooE2FL@linutronix.de/ > > > > I think <sys/prctl.h> would be enough. > > > we could do that but in the glibc man page it says: > > https://man7.org/linux/man-pages/man2/prctl.2.html > > ``` > > #include <linux/prctl.h> /* Definition of PR_* constants */ > > #include <sys/prctl.h> > > ``` > > > It'd be nice to think musl was slowly getting fixed. I notice we're > > Sebastian reported on the musl libc, its maintainer replied: > > https://www.openwall.com/lists/musl/2025/06/12/11 Ugh. I'm not sure how we're expected to resolve this and have glibc and musl be happy without basically not trusting libc. Thanks, Ian ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-23 18:05 ` Ian Rogers @ 2025-06-23 18:14 ` Namhyung Kim 2025-06-23 19:18 ` Arnaldo Carvalho de Melo 0 siblings, 1 reply; 14+ messages in thread From: Namhyung Kim @ 2025-06-23 18:14 UTC (permalink / raw) To: Ian Rogers Cc: Arnaldo Carvalho de Melo, Sebastian Andrzej Siewior, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Mon, Jun 23, 2025 at 11:05:41AM -0700, Ian Rogers wrote: > On Mon, Jun 23, 2025 at 10:45 AM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > > > On Mon, Jun 23, 2025 at 08:12:47AM -0700, Ian Rogers wrote: > > > On Fri, Jun 20, 2025 at 12:36 PM Namhyung Kim <namhyung@kernel.org> wrote: > > > > I'm afraid it'd introduce a build failure on musl. Please see > > > > > > https://lore.kernel.org/linux-perf-users/20250611092542.F4ooE2FL@linutronix.de/ > > > > > > I think <sys/prctl.h> would be enough. > > > > > we could do that but in the glibc man page it says: > > > https://man7.org/linux/man-pages/man2/prctl.2.html > > > ``` > > > #include <linux/prctl.h> /* Definition of PR_* constants */ > > > #include <sys/prctl.h> > > > ``` > > > > > It'd be nice to think musl was slowly getting fixed. I notice we're > > > > Sebastian reported on the musl libc, its maintainer replied: > > > > https://www.openwall.com/lists/musl/2025/06/12/11 > > Ugh. I'm not sure how we're expected to resolve this and have glibc > and musl be happy without basically not trusting libc. Maybe pthread_setname_np()? It seems musl also implemented it. Thanks, Namhyung ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-23 18:14 ` Namhyung Kim @ 2025-06-23 19:18 ` Arnaldo Carvalho de Melo 2025-06-23 19:41 ` Ian Rogers 0 siblings, 1 reply; 14+ messages in thread From: Arnaldo Carvalho de Melo @ 2025-06-23 19:18 UTC (permalink / raw) To: Namhyung Kim Cc: Ian Rogers, Sebastian Andrzej Siewior, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Mon, Jun 23, 2025 at 11:14:47AM -0700, Namhyung Kim wrote: > On Mon, Jun 23, 2025 at 11:05:41AM -0700, Ian Rogers wrote: > > On Mon, Jun 23, 2025 at 10:45 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > > On Mon, Jun 23, 2025 at 08:12:47AM -0700, Ian Rogers wrote: > > > > On Fri, Jun 20, 2025 at 12:36 PM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > I'm afraid it'd introduce a build failure on musl. Please see > > > > > https://lore.kernel.org/linux-perf-users/20250611092542.F4ooE2FL@linutronix.de/ > > > > > I think <sys/prctl.h> would be enough. > > > > we could do that but in the glibc man page it says: > > > > https://man7.org/linux/man-pages/man2/prctl.2.html > > > > ``` > > > > #include <linux/prctl.h> /* Definition of PR_* constants */ > > > > #include <sys/prctl.h> > > > > ``` > > > > It'd be nice to think musl was slowly getting fixed. I notice we're > > > Sebastian reported on the musl libc, its maintainer replied: > > > https://www.openwall.com/lists/musl/2025/06/12/11 > > Ugh. I'm not sure how we're expected to resolve this and have glibc > > and musl be happy without basically not trusting libc. > Maybe pthread_setname_np()? It seems musl also implemented it. ⬢ [acme@toolbx perf-tools-next]$ git diff diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c index 8b954d4660833a2f..656e472e618822a3 100644 --- a/tools/perf/tests/workloads/noploop.c +++ b/tools/perf/tests/workloads/noploop.c @@ -1,9 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#include <pthread.h> #include <stdlib.h> #include <signal.h> #include <unistd.h> -#include <linux/prctl.h> -#include <sys/prctl.h> #include <linux/compiler.h> #include "../tests.h" @@ -18,7 +17,7 @@ static int noploop(int argc, const char **argv) { int sec = 1; - prctl(PR_SET_NAME, "perf-noploop"); + pthread_setname_np(pthread_self(), "perf-noploop"); if (argc > 0) sec = atoi(argv[0]); ⬢ [acme@toolbx perf-tools-next]$ ⬢ [acme@toolbx perf-tools-next]$ perf test -w noploop & [1] 1179763 ⬢ [acme@toolbx perf-tools-next]$ ps PID TTY TIME CMD 3935 pts/1 00:00:00 bash 4053 pts/1 00:00:00 toolbox 4222 pts/1 00:00:28 podman 971900 pts/1 00:00:00 bash 1100453 pts/1 00:00:00 tail 1160346 pts/1 00:00:00 bash 1179763 pts/1 00:00:00 perf-noploop 1179765 pts/1 00:00:00 ps ⬢ [acme@toolbx perf-tools-next]$ And then on one of the Alpine Linux containers: make: Leaving directory '/tmp/perf-6.16.0-rc3/tools/perf' /tmp/perf-6.16.0-rc3 $ cat /etc/os-release NAME="Alpine Linux" ID=alpine VERSION_ID=3.18.12 PRETTY_NAME="Alpine Linux v3.18" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" /tmp/perf-6.16.0-rc3 $ tools/perf/perf test -w noploop & /tmp/perf-6.16.0-rc3 $ ps PID USER TIME COMMAND 1 toolsbui 0:00 /bin/sh 5693 toolsbui 0:00 {perf-noploop} tools/perf/perf test -w noploop 5694 toolsbui 0:00 ps /tmp/perf-6.16.0-rc3 $ [1]+ Done tools/perf/perf test -w noploop /tmp/perf-6.16.0-rc3 There are more direct use of prctl() to set the name in tools/perf/, using pthread_setname_np() seems cleaner :-) - Arnaldo ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-23 19:18 ` Arnaldo Carvalho de Melo @ 2025-06-23 19:41 ` Ian Rogers 2025-06-23 23:14 ` Namhyung Kim 0 siblings, 1 reply; 14+ messages in thread From: Ian Rogers @ 2025-06-23 19:41 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Namhyung Kim, Sebastian Andrzej Siewior, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Mon, Jun 23, 2025 at 12:19 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > On Mon, Jun 23, 2025 at 11:14:47AM -0700, Namhyung Kim wrote: > > On Mon, Jun 23, 2025 at 11:05:41AM -0700, Ian Rogers wrote: > > > On Mon, Jun 23, 2025 at 10:45 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > > > On Mon, Jun 23, 2025 at 08:12:47AM -0700, Ian Rogers wrote: > > > > > On Fri, Jun 20, 2025 at 12:36 PM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > I'm afraid it'd introduce a build failure on musl. Please see > > > > > > > https://lore.kernel.org/linux-perf-users/20250611092542.F4ooE2FL@linutronix.de/ > > > > > > > I think <sys/prctl.h> would be enough. > > > > > > we could do that but in the glibc man page it says: > > > > > https://man7.org/linux/man-pages/man2/prctl.2.html > > > > > ``` > > > > > #include <linux/prctl.h> /* Definition of PR_* constants */ > > > > > #include <sys/prctl.h> > > > > > ``` > > > > > > It'd be nice to think musl was slowly getting fixed. I notice we're > > > > > Sebastian reported on the musl libc, its maintainer replied: > > > > > https://www.openwall.com/lists/musl/2025/06/12/11 > > > > Ugh. I'm not sure how we're expected to resolve this and have glibc > > > and musl be happy without basically not trusting libc. > > > Maybe pthread_setname_np()? It seems musl also implemented it. > > ⬢ [acme@toolbx perf-tools-next]$ git diff > diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c > index 8b954d4660833a2f..656e472e618822a3 100644 > --- a/tools/perf/tests/workloads/noploop.c > +++ b/tools/perf/tests/workloads/noploop.c > @@ -1,9 +1,8 @@ > /* SPDX-License-Identifier: GPL-2.0 */ > +#include <pthread.h> > #include <stdlib.h> > #include <signal.h> > #include <unistd.h> > -#include <linux/prctl.h> > -#include <sys/prctl.h> > #include <linux/compiler.h> > #include "../tests.h" > > @@ -18,7 +17,7 @@ static int noploop(int argc, const char **argv) > { > int sec = 1; > > - prctl(PR_SET_NAME, "perf-noploop"); > + pthread_setname_np(pthread_self(), "perf-noploop"); > if (argc > 0) > sec = atoi(argv[0]); > > ⬢ [acme@toolbx perf-tools-next]$ > > ⬢ [acme@toolbx perf-tools-next]$ perf test -w noploop & > [1] 1179763 > ⬢ [acme@toolbx perf-tools-next]$ ps > PID TTY TIME CMD > 3935 pts/1 00:00:00 bash > 4053 pts/1 00:00:00 toolbox > 4222 pts/1 00:00:28 podman > 971900 pts/1 00:00:00 bash > 1100453 pts/1 00:00:00 tail > 1160346 pts/1 00:00:00 bash > 1179763 pts/1 00:00:00 perf-noploop > 1179765 pts/1 00:00:00 ps > ⬢ [acme@toolbx perf-tools-next]$ > > And then on one of the Alpine Linux containers: > > make: Leaving directory '/tmp/perf-6.16.0-rc3/tools/perf' > /tmp/perf-6.16.0-rc3 $ cat /etc/os-release > NAME="Alpine Linux" > ID=alpine > VERSION_ID=3.18.12 > PRETTY_NAME="Alpine Linux v3.18" > HOME_URL="https://alpinelinux.org/" > BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" > /tmp/perf-6.16.0-rc3 $ tools/perf/perf test -w noploop & > /tmp/perf-6.16.0-rc3 $ ps > PID USER TIME COMMAND > 1 toolsbui 0:00 /bin/sh > 5693 toolsbui 0:00 {perf-noploop} tools/perf/perf test -w noploop > 5694 toolsbui 0:00 ps > /tmp/perf-6.16.0-rc3 $ > [1]+ Done tools/perf/perf test -w noploop > /tmp/perf-6.16.0-rc3 > > There are more direct use of prctl() to set the name in tools/perf/, > using pthread_setname_np() seems cleaner :-) Yeah, I wanted to set the program name rather than a thread name for the sake of seeing the process name in ps - hence reaching for prctl. PR_SET_NAME is documented as setting the thread name and so no difference to pthread_setname_np. It's still frustrating to get bogged down in working around musl when typing the literal code from the prctl man page. Do you need me to re-send the patch? Thanks, Ian > - Arnaldo ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] perf test workload noploop: Name the noploop process 2025-06-23 19:41 ` Ian Rogers @ 2025-06-23 23:14 ` Namhyung Kim 0 siblings, 0 replies; 14+ messages in thread From: Namhyung Kim @ 2025-06-23 23:14 UTC (permalink / raw) To: Ian Rogers Cc: Arnaldo Carvalho de Melo, Sebastian Andrzej Siewior, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, linux-kernel, linux-perf-users On Mon, Jun 23, 2025 at 12:41:09PM -0700, Ian Rogers wrote: > On Mon, Jun 23, 2025 at 12:19 PM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > > > On Mon, Jun 23, 2025 at 11:14:47AM -0700, Namhyung Kim wrote: > > > On Mon, Jun 23, 2025 at 11:05:41AM -0700, Ian Rogers wrote: > > > > On Mon, Jun 23, 2025 at 10:45 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > > > > On Mon, Jun 23, 2025 at 08:12:47AM -0700, Ian Rogers wrote: > > > > > > On Fri, Jun 20, 2025 at 12:36 PM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > > I'm afraid it'd introduce a build failure on musl. Please see > > > > > > > > > https://lore.kernel.org/linux-perf-users/20250611092542.F4ooE2FL@linutronix.de/ > > > > > > > > > I think <sys/prctl.h> would be enough. > > > > > > > > we could do that but in the glibc man page it says: > > > > > > https://man7.org/linux/man-pages/man2/prctl.2.html > > > > > > ``` > > > > > > #include <linux/prctl.h> /* Definition of PR_* constants */ > > > > > > #include <sys/prctl.h> > > > > > > ``` > > > > > > > > It'd be nice to think musl was slowly getting fixed. I notice we're > > > > > > > Sebastian reported on the musl libc, its maintainer replied: > > > > > > > https://www.openwall.com/lists/musl/2025/06/12/11 > > > > > > Ugh. I'm not sure how we're expected to resolve this and have glibc > > > > and musl be happy without basically not trusting libc. > > > > > Maybe pthread_setname_np()? It seems musl also implemented it. > > > > ⬢ [acme@toolbx perf-tools-next]$ git diff > > diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c > > index 8b954d4660833a2f..656e472e618822a3 100644 > > --- a/tools/perf/tests/workloads/noploop.c > > +++ b/tools/perf/tests/workloads/noploop.c > > @@ -1,9 +1,8 @@ > > /* SPDX-License-Identifier: GPL-2.0 */ > > +#include <pthread.h> > > #include <stdlib.h> > > #include <signal.h> > > #include <unistd.h> > > -#include <linux/prctl.h> > > -#include <sys/prctl.h> > > #include <linux/compiler.h> > > #include "../tests.h" > > > > @@ -18,7 +17,7 @@ static int noploop(int argc, const char **argv) > > { > > int sec = 1; > > > > - prctl(PR_SET_NAME, "perf-noploop"); > > + pthread_setname_np(pthread_self(), "perf-noploop"); > > if (argc > 0) > > sec = atoi(argv[0]); > > > > ⬢ [acme@toolbx perf-tools-next]$ > > > > ⬢ [acme@toolbx perf-tools-next]$ perf test -w noploop & > > [1] 1179763 > > ⬢ [acme@toolbx perf-tools-next]$ ps > > PID TTY TIME CMD > > 3935 pts/1 00:00:00 bash > > 4053 pts/1 00:00:00 toolbox > > 4222 pts/1 00:00:28 podman > > 971900 pts/1 00:00:00 bash > > 1100453 pts/1 00:00:00 tail > > 1160346 pts/1 00:00:00 bash > > 1179763 pts/1 00:00:00 perf-noploop > > 1179765 pts/1 00:00:00 ps > > ⬢ [acme@toolbx perf-tools-next]$ > > > > And then on one of the Alpine Linux containers: > > > > make: Leaving directory '/tmp/perf-6.16.0-rc3/tools/perf' > > /tmp/perf-6.16.0-rc3 $ cat /etc/os-release > > NAME="Alpine Linux" > > ID=alpine > > VERSION_ID=3.18.12 > > PRETTY_NAME="Alpine Linux v3.18" > > HOME_URL="https://alpinelinux.org/" > > BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" > > /tmp/perf-6.16.0-rc3 $ tools/perf/perf test -w noploop & > > /tmp/perf-6.16.0-rc3 $ ps > > PID USER TIME COMMAND > > 1 toolsbui 0:00 /bin/sh > > 5693 toolsbui 0:00 {perf-noploop} tools/perf/perf test -w noploop > > 5694 toolsbui 0:00 ps > > /tmp/perf-6.16.0-rc3 $ > > [1]+ Done tools/perf/perf test -w noploop > > /tmp/perf-6.16.0-rc3 > > > > There are more direct use of prctl() to set the name in tools/perf/, > > using pthread_setname_np() seems cleaner :-) > > Yeah, I wanted to set the program name rather than a thread name for > the sake of seeing the process name in ps - hence reaching for prctl. > PR_SET_NAME is documented as setting the thread name and so no > difference to pthread_setname_np. It's still frustrating to get bogged > down in working around musl when typing the literal code from the > prctl man page. Do you need me to re-send the patch? Yes please. And address comments in the patch 2 as well. Thanks, Namhyung ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-06-28 1:25 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-06-19 0:20 [PATCH v2 1/2] perf test workload noploop: Name the noploop process Ian Rogers 2025-06-19 0:20 ` [PATCH v2 2/2] perf test: Add sched latency and script shell tests Ian Rogers 2025-06-20 10:01 ` James Clark 2025-06-20 19:41 ` Namhyung Kim 2025-06-28 1:25 ` Ian Rogers 2025-06-20 10:01 ` [PATCH v2 1/2] perf test workload noploop: Name the noploop process James Clark 2025-06-20 19:36 ` Namhyung Kim 2025-06-23 15:12 ` Ian Rogers 2025-06-23 17:45 ` Arnaldo Carvalho de Melo 2025-06-23 18:05 ` Ian Rogers 2025-06-23 18:14 ` Namhyung Kim 2025-06-23 19:18 ` Arnaldo Carvalho de Melo 2025-06-23 19:41 ` Ian Rogers 2025-06-23 23:14 ` Namhyung Kim
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).