perf test workload noploop: Name the noploop process
Ian Rogers
reviewerPATCH v3 1/2 perf test workload noploop: Name the noploop process
Name the noploop process "perf-noploop" so that tests can easily check for its existence.
---
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 <[email protected]>.
--- tools/perf/tests/workloads/noploop.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/tests/workloads/noploop.c +2 -0
@@ -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 ]);
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v3 2/2 perf test: Add sched latency and script shell tests
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.
---
v3: Avoid running taskset in the background as suggested by James
Clark <[email protected]>
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
tools/perf/tests/shell/sched.sh new file +93 -0
@@ -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
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
kernel test robot
build botRe: [PATCH v3 2/2] perf test: Add sched latency and script shell tests
kernel test robot noticed "kmsg.sanitizer.direct_leak/__interceptor_realloc" on:
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/[email protected]/
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 <[email protected]>
| Closes: https://lore.kernel.org/oe-lkp/[email protected]
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/[email protected]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 4 lines · Ian Rogers
Name the noploop process "perf-noploop" so that tests can easily check for its existence.
Applied to perf-tools-next, thanks!
Best regards,
Namhyung