linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] perf test workload noploop: Name the noploop process
@ 2025-06-28  1:23 Ian Rogers
  2025-06-28  1:23 ` [PATCH v3 2/2] perf test: Add sched latency and script shell tests Ian Rogers
  2025-07-02 16:43 ` [PATCH v3 1/2] perf test workload noploop: Name the noploop process Namhyung Kim
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Rogers @ 2025-06-28  1:23 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, James Clark, 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>
---
v3: Switch to using pthread_setname_np rather than prctl as glibc and
    musl having conflicting and mutually broken definitions of which
    header files to #include for prctl. Suggested by Namhyung Kim
    <namhyung@kernel.org>.
---
 tools/perf/tests/workloads/noploop.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c
index 940ea5910a84..656e472e6188 100644
--- a/tools/perf/tests/workloads/noploop.c
+++ b/tools/perf/tests/workloads/noploop.c
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <pthread.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <unistd.h>
@@ -16,6 +17,7 @@ static int noploop(int argc, const char **argv)
 {
 	int sec = 1;
 
+	pthread_setname_np(pthread_self(), "perf-noploop");
 	if (argc > 0)
 		sec = atoi(argv[0]);
 
-- 
2.50.0.727.gbf7dc18ff4-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] perf test: Add sched latency and script shell tests
  2025-06-28  1:23 [PATCH v3 1/2] perf test workload noploop: Name the noploop process Ian Rogers
@ 2025-06-28  1:23 ` Ian Rogers
  2025-07-20  8:35   ` kernel test robot
  2025-07-02 16:43 ` [PATCH v3 1/2] perf test workload noploop: Name the noploop process Namhyung Kim
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2025-06-28  1:23 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, James Clark, 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.

Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Ian Rogers <irogers@google.com>
---
v3: Avoid running taskset in the background as suggested by James
    Clark <james.clark@linaro.org>
v2: Skip the test if not root due to permissions.
---
 tools/perf/tests/shell/sched.sh | 93 +++++++++++++++++++++++++++++++++
 1 file changed, 93 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..c030126d1a0c
--- /dev/null
+++ b/tools/perf/tests/shell/sched.sh
@@ -0,0 +1,93 @@
+#!/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.
+  perf test -w noploop 10 &
+  PID1=$!
+  taskset -pc 0 $PID1
+  perf test -w noploop 10 &
+  PID2=$!
+  taskset -pc 0 $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.727.gbf7dc18ff4-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/2] perf test workload noploop: Name the noploop process
  2025-06-28  1:23 [PATCH v3 1/2] perf test workload noploop: Name the noploop process Ian Rogers
  2025-06-28  1:23 ` [PATCH v3 2/2] perf test: Add sched latency and script shell tests Ian Rogers
@ 2025-07-02 16:43 ` Namhyung Kim
  1 sibling, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2025-07-02 16:43 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Kan Liang, James Clark, linux-kernel, linux-perf-users,
	Ian Rogers

On Fri, 27 Jun 2025 18:23:01 -0700, Ian Rogers wrote:
> Name the noploop process "perf-noploop" so that tests can easily check
> for its existence.
> 
> 
Applied to perf-tools-next, thanks!

Best regards,
Namhyung



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 2/2] perf test: Add sched latency and script shell tests
  2025-06-28  1:23 ` [PATCH v3 2/2] perf test: Add sched latency and script shell tests Ian Rogers
@ 2025-07-20  8:35   ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-07-20  8:35 UTC (permalink / raw)
  To: Ian Rogers
  Cc: oe-lkp, lkp, James Clark, linux-perf-users, linux-kernel,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, oliver.sang


Hello,

kernel test robot noticed "kmsg.sanitizer.direct_leak/__interceptor_realloc" on:

commit: 738c34064b92cfb47180911f409e393e78a96818 ("[PATCH v3 2/2] perf test: Add sched latency and script shell tests")
url: https://github.com/intel-lab-lkp/linux/commits/Ian-Rogers/perf-test-Add-sched-latency-and-script-shell-tests/20250628-092510
base: https://git.kernel.org/cgit/linux/kernel/git/perf/perf-tools-next.git perf-tools-next
patch link: https://lore.kernel.org/all/20250628012302.1242532-2-irogers@google.com/
patch subject: [PATCH v3 2/2] perf test: Add sched latency and script shell tests

in testcase: perf-sanity-tests
version: 
with following parameters:

	perf_compiler: clang
	group: group-01



config: x86_64-rhel-9.4-bpf
compiler: gcc-12
test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (Kaby Lake) with 32G memory

(please refer to attached dmesg/kmsg for entire log/backtrace)




If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202507201046.5842fe9a-lkp@intel.com



2025-07-10 21:48:29 sudo /usr/src/linux-perf-x86_64-rhel-9.4-bpf-738c34064b92cfb47180911f409e393e78a96818/tools/perf/perf test 91 -v
 91: perf sched tests                                                : Running (1 active)
--- start ---
test child forked, pid 10659
Sched latency
pid 10663's current affinity list: 0-7
pid 10663's new affinity list: 0
pid 10665's current affinity list: 0-7
pid 10665's new affinity list: 0
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.335 MB /tmp/__perf_test_sched.perf.data.1IqjN (1973 samples) ]

=================================================================
==10672==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 67 byte(s) in 1 object(s) allocated from:
    #0 0x7fdf4ada98d5 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:85
    #1 0x7fdf4a2723e1  (/lib/x86_64-linux-gnu/libc.so.6+0x7e3e1)
    #2 0x4f63ab0b0c0befff  (<unknown module>)

SUMMARY: AddressSanitizer: 67 byte(s) leaked in 1 allocation(s).
Unexpected signal in test_sched_latency
---- end(-1) ----
 91: perf sched tests                                                : FAILED!



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250720/202507201046.5842fe9a-lkp@intel.com



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-20  8:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-28  1:23 [PATCH v3 1/2] perf test workload noploop: Name the noploop process Ian Rogers
2025-06-28  1:23 ` [PATCH v3 2/2] perf test: Add sched latency and script shell tests Ian Rogers
2025-07-20  8:35   ` kernel test robot
2025-07-02 16:43 ` [PATCH v3 1/2] perf test workload noploop: Name the noploop process 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).