All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET 0/8] perf test: Improve perf record tests (v2)
@ 2022-10-20 17:26 Namhyung Kim
  2022-10-20 17:26 ` [PATCH 1/8] perf test: Do not use instructions:u explicitly Namhyung Kim
                   ` (8 more replies)
  0 siblings, 9 replies; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

Hello,

This patchset improves the perf record tests to check more cases so that it
can find problems early.  The motivation was a failure per-thread mmap with
multi-threaded targets which Adrian is working on the fix.

Changes in v2)
 * fix shellcheck issues
 * drop unsupported --per-thread and --threads combination
 * do not use initial delay (-D option); instead it runs the target
   and wait for it separately using the recent waiting.sh library
 * add Adrian's Reviewed-by tags

I added a custom test program and more combinations like system-wide and
command line workload (in per-process mode) testing with multi-threaded
recording mode.

Currently it succeeds every tests when running as root!

  $ sudo ./perf test -v 91
   91: perf record tests                                               :
  --- start ---
  test child forked, pid 108975
  Build a test program
  Basic --per-thread mode test
  Basic --per-thread mode test [Success]
  Register capture test
  Register capture test [Success]
  Basic --system-wide mode test
  Basic --system-wide mode test [Success]
  Basic target workload test
  Basic target workload test [Success]
  test child finished with 0
  ---- end ----
  perf record tests: Ok

You can find it in 'perf/record-test-v2' branch in

  git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks,
Namhyung


Namhyung Kim (8):
  perf test: Do not use instructions:u explicitly
  perf test: Fix shellcheck issues in the record test
  perf test: Use a test program in perf record tests
  perf test: Wait for a new thread when testing --per-thread record
  perf test: Add system-wide mode in perf record tests
  perf test: Add target workload test in perf record tests
  perf test: Test record with --threads option
  perf test: Do not set TEST_SKIP for record subtests

 tools/perf/tests/shell/record.sh | 180 +++++++++++++++++++++++++++----
 1 file changed, 158 insertions(+), 22 deletions(-)


base-commit: a3a365655a28f12f07eddf4f3fd596987b175e1d
-- 
2.38.0.135.g90850a2211-goog


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

* [PATCH 1/8] perf test: Do not use instructions:u explicitly
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
@ 2022-10-20 17:26 ` Namhyung Kim
  2022-10-20 23:47   ` Ian Rogers
  2022-10-20 17:26 ` [PATCH 2/8] perf test: Fix shellcheck issues in the record test Namhyung Kim
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

I think it's to support non-root user tests.  But perf record can handle
the case and fall back to a software event (cpu-clock).  Practically this
would affect when it's run on a VM, but it seems no reason to prevent running
the test in the guest.

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 301f95427159..747c33a1ec45 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -21,18 +21,18 @@ trap trap_cleanup exit term int
 
 test_per_thread() {
   echo "Basic --per-thread mode test"
-  if ! perf record -e instructions:u -o ${perfdata} --quiet true 2> /dev/null
+  if ! perf record -o /dev/null --quiet true 2> /dev/null
   then
-    echo "Per-thread record [Skipped instructions:u not supported]"
+    echo "Per-thread record [Skipped event not supported]"
     if [ $err -ne 1 ]
     then
       err=2
     fi
     return
   fi
-  if ! perf record -e instructions:u --per-thread -o ${perfdata} true 2> /dev/null
+  if ! perf record --per-thread -o ${perfdata} true 2> /dev/null
   then
-    echo "Per-thread record of instructions:u [Failed]"
+    echo "Per-thread record [Failed record]"
     err=1
     return
   fi
@@ -49,7 +49,7 @@ test_register_capture() {
   echo "Register capture test"
   if ! perf list | egrep -q 'br_inst_retired.near_call'
   then
-    echo "Register capture test [Skipped missing instruction]"
+    echo "Register capture test [Skipped missing event]"
     if [ $err -ne 1 ]
     then
       err=2
-- 
2.38.0.135.g90850a2211-goog


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

* [PATCH 2/8] perf test: Fix shellcheck issues in the record test
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
  2022-10-20 17:26 ` [PATCH 1/8] perf test: Do not use instructions:u explicitly Namhyung Kim
@ 2022-10-20 17:26 ` Namhyung Kim
  2022-10-20 23:48   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  2022-10-20 17:26 ` [PATCH 3/8] perf test: Use a test program in perf record tests Namhyung Kim
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

Basically there are 3 issues:

 1. quote shell expansion
 2. do not use egrep
 3. use upper case letters for signal names

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 747c33a1ec45..464071462809 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -8,16 +8,16 @@ err=0
 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
 
 cleanup() {
-  rm -f ${perfdata}
-  rm -f ${perfdata}.old
-  trap - exit term int
+  rm -f "${perfdata}"
+  rm -f "${perfdata}".old
+  trap - EXIT TERM INT
 }
 
 trap_cleanup() {
   cleanup
   exit 1
 }
-trap trap_cleanup exit term int
+trap trap_cleanup EXIT TERM INT
 
 test_per_thread() {
   echo "Basic --per-thread mode test"
@@ -30,13 +30,13 @@ test_per_thread() {
     fi
     return
   fi
-  if ! perf record --per-thread -o ${perfdata} true 2> /dev/null
+  if ! perf record --per-thread -o "${perfdata}" true 2> /dev/null
   then
     echo "Per-thread record [Failed record]"
     err=1
     return
   fi
-  if ! perf report -i ${perfdata} -q | egrep -q true
+  if ! perf report -i "${perfdata}" -q | grep -q true
   then
     echo "Per-thread record [Failed missing output]"
     err=1
@@ -47,7 +47,7 @@ test_per_thread() {
 
 test_register_capture() {
   echo "Register capture test"
-  if ! perf list | egrep -q 'br_inst_retired.near_call'
+  if ! perf list | grep -q 'br_inst_retired.near_call'
   then
     echo "Register capture test [Skipped missing event]"
     if [ $err -ne 1 ]
@@ -56,7 +56,7 @@ test_register_capture() {
     fi
     return
   fi
-  if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
+  if ! perf record --intr-regs=\? 2>&1 | grep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
   then
     echo "Register capture test [Skipped missing registers]"
     return
@@ -64,7 +64,7 @@ test_register_capture() {
   if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
     -c 1000 --per-thread true 2> /dev/null \
     | perf script -F ip,sym,iregs -i - 2> /dev/null \
-    | egrep -q "DI:"
+    | grep -q "DI:"
   then
     echo "Register capture test [Failed missing output]"
     err=1
-- 
2.38.0.135.g90850a2211-goog


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

* [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
  2022-10-20 17:26 ` [PATCH 1/8] perf test: Do not use instructions:u explicitly Namhyung Kim
  2022-10-20 17:26 ` [PATCH 2/8] perf test: Fix shellcheck issues in the record test Namhyung Kim
@ 2022-10-20 17:26 ` Namhyung Kim
  2022-10-20 23:52   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  2022-10-20 17:26 ` [PATCH 4/8] perf test: Wait for a new thread when testing --per-thread record Namhyung Kim
                   ` (5 subsequent siblings)
  8 siblings, 2 replies; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

If the system has cc it could build a test program with two threads
and then use it for more detailed testing.  Also it accepts an option
to run a thread forever to ensure multi-thread runs.

If cc is not found, it falls back to use the default value 'true'.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 64 ++++++++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 464071462809..952981481239 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -6,10 +6,17 @@ set -e
 
 err=0
 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
+testsym="test_loop"
 
 cleanup() {
   rm -f "${perfdata}"
   rm -f "${perfdata}".old
+
+  if [ "${testprog}" != "true" ]; then
+    rm -f "${testprog}"
+  fi
+
   trap - EXIT TERM INT
 }
 
@@ -19,9 +26,56 @@ trap_cleanup() {
 }
 trap trap_cleanup EXIT TERM INT
 
+build_test_program() {
+  if ! [ -x "$(command -v cc)" ]; then
+    # No CC found. Fall back to 'true'
+    testprog=true
+    testsym=true
+    return
+  fi
+
+  echo "Build a test program"
+  cat <<EOF | cc -o ${testprog} -xc - -pthread
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+void test_loop(void) {
+  volatile int count = 1000000;
+
+  while (count--)
+    continue;
+}
+
+void *thfunc(void *arg) {
+  int forever = *(int *)arg;
+
+  do {
+    test_loop();
+  } while (forever);
+
+  return NULL;
+}
+
+int main(int argc, char *argv[]) {
+  pthread_t th;
+  int forever = 0;
+
+  if (argc > 1)
+    forever = atoi(argv[1]);
+
+  pthread_create(&th, NULL, thfunc, &forever);
+  test_loop();
+  pthread_join(th, NULL);
+
+  return 0;
+}
+EOF
+}
+
 test_per_thread() {
   echo "Basic --per-thread mode test"
-  if ! perf record -o /dev/null --quiet true 2> /dev/null
+  if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
   then
     echo "Per-thread record [Skipped event not supported]"
     if [ $err -ne 1 ]
@@ -30,13 +84,13 @@ test_per_thread() {
     fi
     return
   fi
-  if ! perf record --per-thread -o "${perfdata}" true 2> /dev/null
+  if ! perf record --per-thread -o "${perfdata}" ${testprog} 2> /dev/null
   then
     echo "Per-thread record [Failed record]"
     err=1
     return
   fi
-  if ! perf report -i "${perfdata}" -q | grep -q true
+  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
   then
     echo "Per-thread record [Failed missing output]"
     err=1
@@ -62,7 +116,7 @@ test_register_capture() {
     return
   fi
   if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
-    -c 1000 --per-thread true 2> /dev/null \
+    -c 1000 --per-thread ${testprog} 2> /dev/null \
     | perf script -F ip,sym,iregs -i - 2> /dev/null \
     | grep -q "DI:"
   then
@@ -73,6 +127,8 @@ test_register_capture() {
   echo "Register capture test [Success]"
 }
 
+build_test_program
+
 test_per_thread
 test_register_capture
 
-- 
2.38.0.135.g90850a2211-goog


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

* [PATCH 4/8] perf test: Wait for a new thread when testing --per-thread record
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
                   ` (2 preceding siblings ...)
  2022-10-20 17:26 ` [PATCH 3/8] perf test: Use a test program in perf record tests Namhyung Kim
@ 2022-10-20 17:26 ` Namhyung Kim
  2022-10-20 23:57   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  2022-10-20 17:26 ` [PATCH 5/8] perf test: Add system-wide mode in perf record tests Namhyung Kim
                   ` (4 subsequent siblings)
  8 siblings, 2 replies; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

Just running the target program is not enough to test multi-thread
target because it'd be racy perf vs target startup.  I used the
initial delay but it cannot guarantee for perf to see the thread.

Instead, use wait_for_threads helper from shell/lib/waiting.sh to make
sure it starts the sibling thread first.  Then perf record can use -p
option to profile the target process.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 952981481239..d1640d1daf2e 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -4,6 +4,9 @@
 
 set -e
 
+shelldir=$(dirname "$0")
+. "${shelldir}"/lib/waiting.sh
+
 err=0
 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
 testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
@@ -96,6 +99,30 @@ test_per_thread() {
     err=1
     return
   fi
+
+  # run the test program in background (forever)
+  ${testprog} 1 &
+  TESTPID=$!
+
+  rm -f "${perfdata}"
+
+  wait_for_threads ${TESTPID} 2
+  perf record -p "${TESTPID}" --per-thread -o "${perfdata}" sleep 1 2> /dev/null
+  kill ${TESTPID}
+
+  if [ ! -e "${perfdata}" ]
+  then
+    echo "Per-thread record [Failed record -p]"
+    err=1
+    return
+  fi
+  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
+  then
+    echo "Per-thread record [Failed -p missing output]"
+    err=1
+    return
+  fi
+
   echo "Basic --per-thread mode test [Success]"
 }
 
-- 
2.38.0.135.g90850a2211-goog


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

* [PATCH 5/8] perf test: Add system-wide mode in perf record tests
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
                   ` (3 preceding siblings ...)
  2022-10-20 17:26 ` [PATCH 4/8] perf test: Wait for a new thread when testing --per-thread record Namhyung Kim
@ 2022-10-20 17:26 ` Namhyung Kim
  2022-10-21  0:00   ` Ian Rogers
  2022-10-20 17:26 ` [PATCH 6/8] perf test: Add target workload test " Namhyung Kim
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

Add system wide recording test with the same pattern.  It'd skip the
test when it failes to run perf record.  For system-wide mode, it needs
to avoid build-id collection and synthesis because the test only cares
about the test program and kernel would generates necessary events as
the process starts.

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index d1640d1daf2e..345764afb745 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -154,10 +154,31 @@ test_register_capture() {
   echo "Register capture test [Success]"
 }
 
+test_system_wide() {
+  echo "Basic --system-wide mode test"
+  if ! perf record -aB --synth=no -o "${perfdata}" ${testprog} 2> /dev/null
+  then
+    echo "System-wide record [Skipped not supported]"
+    if [ $err -ne 1 ]
+    then
+      err=2
+    fi
+    return
+  fi
+  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
+  then
+    echo "System-wide record [Failed missing output]"
+    err=1
+    return
+  fi
+  echo "Basic --system-wide mode test [Success]"
+}
+
 build_test_program
 
 test_per_thread
 test_register_capture
+test_system_wide
 
 cleanup
 exit $err
-- 
2.38.0.135.g90850a2211-goog


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

* [PATCH 6/8] perf test: Add target workload test in perf record tests
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
                   ` (4 preceding siblings ...)
  2022-10-20 17:26 ` [PATCH 5/8] perf test: Add system-wide mode in perf record tests Namhyung Kim
@ 2022-10-20 17:26 ` Namhyung Kim
  2022-10-21  0:01   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  2022-10-20 17:26 ` [PATCH 7/8] perf test: Test record with --threads option Namhyung Kim
                   ` (2 subsequent siblings)
  8 siblings, 2 replies; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

Add a subtest which profiles the given workload on the command line.
As it's a minimal requirement, test should run ok so it doesn't skip
the test even if it failed to run the perf record.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 345764afb745..c59d1459c960 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -174,11 +174,29 @@ test_system_wide() {
   echo "Basic --system-wide mode test [Success]"
 }
 
+test_workload() {
+  echo "Basic target workload test"
+  if ! perf record -o "${perfdata}" ${testprog} 2> /dev/null
+  then
+    echo "Workload record [Failed record]"
+    err=1
+    return
+  fi
+  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
+  then
+    echo "Workload record [Failed missing output]"
+    err=1
+    return
+  fi
+  echo "Basic target workload test [Success]"
+}
+
 build_test_program
 
 test_per_thread
 test_register_capture
 test_system_wide
+test_workload
 
 cleanup
 exit $err
-- 
2.38.0.135.g90850a2211-goog


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

* [PATCH 7/8] perf test: Test record with --threads option
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
                   ` (5 preceding siblings ...)
  2022-10-20 17:26 ` [PATCH 6/8] perf test: Add target workload test " Namhyung Kim
@ 2022-10-20 17:26 ` Namhyung Kim
  2022-10-21  0:02   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  2022-10-20 17:26 ` [PATCH 8/8] perf test: Do not set TEST_SKIP for record subtests Namhyung Kim
  2022-10-26 14:15 ` [PATCHSET 0/8] perf test: Improve perf record tests (v2) Arnaldo Carvalho de Melo
  8 siblings, 2 replies; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

The --threads option changed the perf record behavior significantly, so
it'd be nice if we test it separately.  Add --threads options with
different argument in each test supported and check the result.

Also update the cleanup routine because threads recording produces data
in a directory.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index c59d1459c960..01aa9531b369 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -13,8 +13,8 @@ testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
 testsym="test_loop"
 
 cleanup() {
-  rm -f "${perfdata}"
-  rm -f "${perfdata}".old
+  rm -rf "${perfdata}"
+  rm -rf "${perfdata}".old
 
   if [ "${testprog}" != "true" ]; then
     rm -f "${testprog}"
@@ -171,6 +171,19 @@ test_system_wide() {
     err=1
     return
   fi
+  if ! perf record -aB --synth=no -e cpu-clock,cs --threads=cpu \
+    -o "${perfdata}" ${testprog} 2> /dev/null
+  then
+    echo "System-wide record [Failed record --threads option]"
+    err=1
+    return
+  fi
+  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
+  then
+    echo "System-wide record [Failed --threads missing output]"
+    err=1
+    return
+  fi
   echo "Basic --system-wide mode test [Success]"
 }
 
@@ -188,6 +201,19 @@ test_workload() {
     err=1
     return
   fi
+  if ! perf record -e cpu-clock,cs --threads=package \
+    -o "${perfdata}" ${testprog} 2> /dev/null
+  then
+    echo "Workload record [Failed record --threads option]"
+    err=1
+    return
+  fi
+  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
+  then
+    echo "Workload record [Failed --threads missing output]"
+    err=1
+    return
+  fi
   echo "Basic target workload test [Success]"
 }
 
-- 
2.38.0.135.g90850a2211-goog


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

* [PATCH 8/8] perf test: Do not set TEST_SKIP for record subtests
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
                   ` (6 preceding siblings ...)
  2022-10-20 17:26 ` [PATCH 7/8] perf test: Test record with --threads option Namhyung Kim
@ 2022-10-20 17:26 ` Namhyung Kim
  2022-10-21  0:05   ` Ian Rogers
  2022-10-26 14:15 ` [PATCHSET 0/8] perf test: Improve perf record tests (v2) Arnaldo Carvalho de Melo
  8 siblings, 1 reply; 32+ messages in thread
From: Namhyung Kim @ 2022-10-20 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
	linux-perf-users

It now has 4 sub tests and one of them should run at least.
But once TEST_SKIP (= 2) return value is set, it won't be overwritten
unless there's a failure.  I think we should return success when one
or more tested are skipped but the remaining subtests are passed.

So update the test code not to set the err variable when it skips
the test.

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 01aa9531b369..e93b3a8871fe 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -81,10 +81,6 @@ test_per_thread() {
   if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
   then
     echo "Per-thread record [Skipped event not supported]"
-    if [ $err -ne 1 ]
-    then
-      err=2
-    fi
     return
   fi
   if ! perf record --per-thread -o "${perfdata}" ${testprog} 2> /dev/null
@@ -131,10 +127,6 @@ test_register_capture() {
   if ! perf list | grep -q 'br_inst_retired.near_call'
   then
     echo "Register capture test [Skipped missing event]"
-    if [ $err -ne 1 ]
-    then
-      err=2
-    fi
     return
   fi
   if ! perf record --intr-regs=\? 2>&1 | grep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
@@ -159,10 +151,6 @@ test_system_wide() {
   if ! perf record -aB --synth=no -o "${perfdata}" ${testprog} 2> /dev/null
   then
     echo "System-wide record [Skipped not supported]"
-    if [ $err -ne 1 ]
-    then
-      err=2
-    fi
     return
   fi
   if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
-- 
2.38.0.135.g90850a2211-goog


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

* Re: [PATCH 1/8] perf test: Do not use instructions:u explicitly
  2022-10-20 17:26 ` [PATCH 1/8] perf test: Do not use instructions:u explicitly Namhyung Kim
@ 2022-10-20 23:47   ` Ian Rogers
  0 siblings, 0 replies; 32+ messages in thread
From: Ian Rogers @ 2022-10-20 23:47 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, Adrian Hunter, linux-perf-users

On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> I think it's to support non-root user tests.  But perf record can handle
> the case and fall back to a software event (cpu-clock).  Practically this
> would affect when it's run on a VM, but it seems no reason to prevent running
> the test in the guest.
>
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 301f95427159..747c33a1ec45 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -21,18 +21,18 @@ trap trap_cleanup exit term int
>
>  test_per_thread() {
>    echo "Basic --per-thread mode test"
> -  if ! perf record -e instructions:u -o ${perfdata} --quiet true 2> /dev/null
> +  if ! perf record -o /dev/null --quiet true 2> /dev/null
>    then
> -    echo "Per-thread record [Skipped instructions:u not supported]"
> +    echo "Per-thread record [Skipped event not supported]"
>      if [ $err -ne 1 ]
>      then
>        err=2
>      fi
>      return
>    fi
> -  if ! perf record -e instructions:u --per-thread -o ${perfdata} true 2> /dev/null
> +  if ! perf record --per-thread -o ${perfdata} true 2> /dev/null
>    then
> -    echo "Per-thread record of instructions:u [Failed]"
> +    echo "Per-thread record [Failed record]"
>      err=1
>      return
>    fi
> @@ -49,7 +49,7 @@ test_register_capture() {
>    echo "Register capture test"
>    if ! perf list | egrep -q 'br_inst_retired.near_call'
>    then
> -    echo "Register capture test [Skipped missing instruction]"
> +    echo "Register capture test [Skipped missing event]"
>      if [ $err -ne 1 ]
>      then
>        err=2
> --
> 2.38.0.135.g90850a2211-goog
>

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

* Re: [PATCH 2/8] perf test: Fix shellcheck issues in the record test
  2022-10-20 17:26 ` [PATCH 2/8] perf test: Fix shellcheck issues in the record test Namhyung Kim
@ 2022-10-20 23:48   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Ian Rogers @ 2022-10-20 23:48 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, Adrian Hunter, linux-perf-users

On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Basically there are 3 issues:
>
>  1. quote shell expansion
>  2. do not use egrep
>  3. use upper case letters for signal names
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 747c33a1ec45..464071462809 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -8,16 +8,16 @@ err=0
>  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
>
>  cleanup() {
> -  rm -f ${perfdata}
> -  rm -f ${perfdata}.old
> -  trap - exit term int
> +  rm -f "${perfdata}"
> +  rm -f "${perfdata}".old
> +  trap - EXIT TERM INT
>  }
>
>  trap_cleanup() {
>    cleanup
>    exit 1
>  }
> -trap trap_cleanup exit term int
> +trap trap_cleanup EXIT TERM INT
>
>  test_per_thread() {
>    echo "Basic --per-thread mode test"
> @@ -30,13 +30,13 @@ test_per_thread() {
>      fi
>      return
>    fi
> -  if ! perf record --per-thread -o ${perfdata} true 2> /dev/null
> +  if ! perf record --per-thread -o "${perfdata}" true 2> /dev/null
>    then
>      echo "Per-thread record [Failed record]"
>      err=1
>      return
>    fi
> -  if ! perf report -i ${perfdata} -q | egrep -q true
> +  if ! perf report -i "${perfdata}" -q | grep -q true
>    then
>      echo "Per-thread record [Failed missing output]"
>      err=1
> @@ -47,7 +47,7 @@ test_per_thread() {
>
>  test_register_capture() {
>    echo "Register capture test"
> -  if ! perf list | egrep -q 'br_inst_retired.near_call'
> +  if ! perf list | grep -q 'br_inst_retired.near_call'
>    then
>      echo "Register capture test [Skipped missing event]"
>      if [ $err -ne 1 ]
> @@ -56,7 +56,7 @@ test_register_capture() {
>      fi
>      return
>    fi
> -  if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
> +  if ! perf record --intr-regs=\? 2>&1 | grep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
>    then
>      echo "Register capture test [Skipped missing registers]"
>      return
> @@ -64,7 +64,7 @@ test_register_capture() {
>    if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
>      -c 1000 --per-thread true 2> /dev/null \
>      | perf script -F ip,sym,iregs -i - 2> /dev/null \
> -    | egrep -q "DI:"
> +    | grep -q "DI:"
>    then
>      echo "Register capture test [Failed missing output]"
>      err=1
> --
> 2.38.0.135.g90850a2211-goog
>

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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-20 17:26 ` [PATCH 3/8] perf test: Use a test program in perf record tests Namhyung Kim
@ 2022-10-20 23:52   ` Ian Rogers
  2022-10-24 11:33     ` Arnaldo Carvalho de Melo
  2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 1 reply; 32+ messages in thread
From: Ian Rogers @ 2022-10-20 23:52 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, Adrian Hunter, linux-perf-users

On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> If the system has cc it could build a test program with two threads
> and then use it for more detailed testing.  Also it accepts an option
> to run a thread forever to ensure multi-thread runs.
>
> If cc is not found, it falls back to use the default value 'true'.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

I wonder if these utilities should just be built into perf to avoid
the cc dependency. Perhaps we can have a hidden option built into perf
test.

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 64 ++++++++++++++++++++++++++++++--
>  1 file changed, 60 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 464071462809..952981481239 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -6,10 +6,17 @@ set -e
>
>  err=0
>  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> +testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
> +testsym="test_loop"
>
>  cleanup() {
>    rm -f "${perfdata}"
>    rm -f "${perfdata}".old
> +
> +  if [ "${testprog}" != "true" ]; then
> +    rm -f "${testprog}"
> +  fi
> +
>    trap - EXIT TERM INT
>  }
>
> @@ -19,9 +26,56 @@ trap_cleanup() {
>  }
>  trap trap_cleanup EXIT TERM INT
>
> +build_test_program() {
> +  if ! [ -x "$(command -v cc)" ]; then
> +    # No CC found. Fall back to 'true'
> +    testprog=true
> +    testsym=true
> +    return
> +  fi
> +
> +  echo "Build a test program"
> +  cat <<EOF | cc -o ${testprog} -xc - -pthread
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <pthread.h>
> +
> +void test_loop(void) {
> +  volatile int count = 1000000;
> +
> +  while (count--)
> +    continue;
> +}
> +
> +void *thfunc(void *arg) {
> +  int forever = *(int *)arg;
> +
> +  do {
> +    test_loop();
> +  } while (forever);
> +
> +  return NULL;
> +}
> +
> +int main(int argc, char *argv[]) {
> +  pthread_t th;
> +  int forever = 0;
> +
> +  if (argc > 1)
> +    forever = atoi(argv[1]);
> +
> +  pthread_create(&th, NULL, thfunc, &forever);
> +  test_loop();
> +  pthread_join(th, NULL);
> +
> +  return 0;
> +}
> +EOF
> +}
> +
>  test_per_thread() {
>    echo "Basic --per-thread mode test"
> -  if ! perf record -o /dev/null --quiet true 2> /dev/null
> +  if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
>    then
>      echo "Per-thread record [Skipped event not supported]"
>      if [ $err -ne 1 ]
> @@ -30,13 +84,13 @@ test_per_thread() {
>      fi
>      return
>    fi
> -  if ! perf record --per-thread -o "${perfdata}" true 2> /dev/null
> +  if ! perf record --per-thread -o "${perfdata}" ${testprog} 2> /dev/null
>    then
>      echo "Per-thread record [Failed record]"
>      err=1
>      return
>    fi
> -  if ! perf report -i "${perfdata}" -q | grep -q true
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
>    then
>      echo "Per-thread record [Failed missing output]"
>      err=1
> @@ -62,7 +116,7 @@ test_register_capture() {
>      return
>    fi
>    if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
> -    -c 1000 --per-thread true 2> /dev/null \
> +    -c 1000 --per-thread ${testprog} 2> /dev/null \
>      | perf script -F ip,sym,iregs -i - 2> /dev/null \
>      | grep -q "DI:"
>    then
> @@ -73,6 +127,8 @@ test_register_capture() {
>    echo "Register capture test [Success]"
>  }
>
> +build_test_program
> +
>  test_per_thread
>  test_register_capture
>
> --
> 2.38.0.135.g90850a2211-goog
>

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

* Re: [PATCH 4/8] perf test: Wait for a new thread when testing --per-thread record
  2022-10-20 17:26 ` [PATCH 4/8] perf test: Wait for a new thread when testing --per-thread record Namhyung Kim
@ 2022-10-20 23:57   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Ian Rogers @ 2022-10-20 23:57 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, Adrian Hunter, linux-perf-users

On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Just running the target program is not enough to test multi-thread
> target because it'd be racy perf vs target startup.  I used the
> initial delay but it cannot guarantee for perf to see the thread.
>
> Instead, use wait_for_threads helper from shell/lib/waiting.sh to make
> sure it starts the sibling thread first.  Then perf record can use -p
> option to profile the target process.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 952981481239..d1640d1daf2e 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -4,6 +4,9 @@
>
>  set -e
>
> +shelldir=$(dirname "$0")
> +. "${shelldir}"/lib/waiting.sh
> +
>  err=0
>  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
>  testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
> @@ -96,6 +99,30 @@ test_per_thread() {
>      err=1
>      return
>    fi
> +
> +  # run the test program in background (forever)
> +  ${testprog} 1 &
> +  TESTPID=$!
> +
> +  rm -f "${perfdata}"
> +
> +  wait_for_threads ${TESTPID} 2
> +  perf record -p "${TESTPID}" --per-thread -o "${perfdata}" sleep 1 2> /dev/null
> +  kill ${TESTPID}
> +
> +  if [ ! -e "${perfdata}" ]
> +  then
> +    echo "Per-thread record [Failed record -p]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "Per-thread record [Failed -p missing output]"
> +    err=1
> +    return
> +  fi
> +
>    echo "Basic --per-thread mode test [Success]"
>  }
>
> --
> 2.38.0.135.g90850a2211-goog
>

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

* Re: [PATCH 5/8] perf test: Add system-wide mode in perf record tests
  2022-10-20 17:26 ` [PATCH 5/8] perf test: Add system-wide mode in perf record tests Namhyung Kim
@ 2022-10-21  0:00   ` Ian Rogers
  2022-10-26 14:11     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 32+ messages in thread
From: Ian Rogers @ 2022-10-21  0:00 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, Adrian Hunter, linux-perf-users

On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Add system wide recording test with the same pattern.  It'd skip the
> test when it failes to run perf record.  For system-wide mode, it needs

nit: s/failes/fails/

> to avoid build-id collection and synthesis because the test only cares
> about the test program and kernel would generates necessary events as

nit: s/generates/generate the/

> the process starts.
>
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index d1640d1daf2e..345764afb745 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -154,10 +154,31 @@ test_register_capture() {
>    echo "Register capture test [Success]"
>  }
>
> +test_system_wide() {
> +  echo "Basic --system-wide mode test"
> +  if ! perf record -aB --synth=no -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "System-wide record [Skipped not supported]"
> +    if [ $err -ne 1 ]
> +    then
> +      err=2
> +    fi
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "System-wide record [Failed missing output]"
> +    err=1
> +    return
> +  fi
> +  echo "Basic --system-wide mode test [Success]"
> +}
> +
>  build_test_program
>
>  test_per_thread
>  test_register_capture
> +test_system_wide
>
>  cleanup
>  exit $err
> --
> 2.38.0.135.g90850a2211-goog
>

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

* Re: [PATCH 6/8] perf test: Add target workload test in perf record tests
  2022-10-20 17:26 ` [PATCH 6/8] perf test: Add target workload test " Namhyung Kim
@ 2022-10-21  0:01   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Ian Rogers @ 2022-10-21  0:01 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, Adrian Hunter, linux-perf-users

On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Add a subtest which profiles the given workload on the command line.
> As it's a minimal requirement, test should run ok so it doesn't skip
> the test even if it failed to run the perf record.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 345764afb745..c59d1459c960 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -174,11 +174,29 @@ test_system_wide() {
>    echo "Basic --system-wide mode test [Success]"
>  }
>
> +test_workload() {
> +  echo "Basic target workload test"
> +  if ! perf record -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "Workload record [Failed record]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "Workload record [Failed missing output]"
> +    err=1
> +    return
> +  fi
> +  echo "Basic target workload test [Success]"
> +}
> +
>  build_test_program
>
>  test_per_thread
>  test_register_capture
>  test_system_wide
> +test_workload
>
>  cleanup
>  exit $err
> --
> 2.38.0.135.g90850a2211-goog
>

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

* Re: [PATCH 7/8] perf test: Test record with --threads option
  2022-10-20 17:26 ` [PATCH 7/8] perf test: Test record with --threads option Namhyung Kim
@ 2022-10-21  0:02   ` Ian Rogers
  2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Ian Rogers @ 2022-10-21  0:02 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, Adrian Hunter, linux-perf-users

On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> The --threads option changed the perf record behavior significantly, so
> it'd be nice if we test it separately.  Add --threads options with
> different argument in each test supported and check the result.
>
> Also update the cleanup routine because threads recording produces data
> in a directory.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 30 ++++++++++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index c59d1459c960..01aa9531b369 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -13,8 +13,8 @@ testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
>  testsym="test_loop"
>
>  cleanup() {
> -  rm -f "${perfdata}"
> -  rm -f "${perfdata}".old
> +  rm -rf "${perfdata}"
> +  rm -rf "${perfdata}".old
>
>    if [ "${testprog}" != "true" ]; then
>      rm -f "${testprog}"
> @@ -171,6 +171,19 @@ test_system_wide() {
>      err=1
>      return
>    fi
> +  if ! perf record -aB --synth=no -e cpu-clock,cs --threads=cpu \
> +    -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "System-wide record [Failed record --threads option]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "System-wide record [Failed --threads missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic --system-wide mode test [Success]"
>  }
>
> @@ -188,6 +201,19 @@ test_workload() {
>      err=1
>      return
>    fi
> +  if ! perf record -e cpu-clock,cs --threads=package \
> +    -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "Workload record [Failed record --threads option]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "Workload record [Failed --threads missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic target workload test [Success]"
>  }
>
> --
> 2.38.0.135.g90850a2211-goog
>

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

* Re: [PATCH 8/8] perf test: Do not set TEST_SKIP for record subtests
  2022-10-20 17:26 ` [PATCH 8/8] perf test: Do not set TEST_SKIP for record subtests Namhyung Kim
@ 2022-10-21  0:05   ` Ian Rogers
  2022-10-24 11:34     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 32+ messages in thread
From: Ian Rogers @ 2022-10-21  0:05 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, Adrian Hunter, linux-perf-users

On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> It now has 4 sub tests and one of them should run at least.
> But once TEST_SKIP (= 2) return value is set, it won't be overwritten
> unless there's a failure.  I think we should return success when one
> or more tested are skipped but the remaining subtests are passed.
>
> So update the test code not to set the err variable when it skips
> the test.
>
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Perhaps we can have proper sub-tests in shell tests like we do for the C ones.

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 12 ------------
>  1 file changed, 12 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 01aa9531b369..e93b3a8871fe 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -81,10 +81,6 @@ test_per_thread() {
>    if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
>    then
>      echo "Per-thread record [Skipped event not supported]"
> -    if [ $err -ne 1 ]
> -    then
> -      err=2
> -    fi
>      return
>    fi
>    if ! perf record --per-thread -o "${perfdata}" ${testprog} 2> /dev/null
> @@ -131,10 +127,6 @@ test_register_capture() {
>    if ! perf list | grep -q 'br_inst_retired.near_call'
>    then
>      echo "Register capture test [Skipped missing event]"
> -    if [ $err -ne 1 ]
> -    then
> -      err=2
> -    fi
>      return
>    fi
>    if ! perf record --intr-regs=\? 2>&1 | grep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
> @@ -159,10 +151,6 @@ test_system_wide() {
>    if ! perf record -aB --synth=no -o "${perfdata}" ${testprog} 2> /dev/null
>    then
>      echo "System-wide record [Skipped not supported]"
> -    if [ $err -ne 1 ]
> -    then
> -      err=2
> -    fi
>      return
>    fi
>    if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> --
> 2.38.0.135.g90850a2211-goog
>

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

* Re: [PATCH 2/8] perf test: Fix shellcheck issues in the record test
  2022-10-20 17:26 ` [PATCH 2/8] perf test: Fix shellcheck issues in the record test Namhyung Kim
  2022-10-20 23:48   ` Ian Rogers
@ 2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Adrian Hunter @ 2022-10-21  8:45 UTC (permalink / raw)
  To: Namhyung Kim, Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, linux-perf-users

On 20/10/22 20:26, Namhyung Kim wrote:
> Basically there are 3 issues:
> 
>  1. quote shell expansion
>  2. do not use egrep
>  3. use upper case letters for signal names
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/tests/shell/record.sh | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 747c33a1ec45..464071462809 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -8,16 +8,16 @@ err=0
>  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
>  
>  cleanup() {
> -  rm -f ${perfdata}
> -  rm -f ${perfdata}.old
> -  trap - exit term int
> +  rm -f "${perfdata}"
> +  rm -f "${perfdata}".old
> +  trap - EXIT TERM INT
>  }
>  
>  trap_cleanup() {
>    cleanup
>    exit 1
>  }
> -trap trap_cleanup exit term int
> +trap trap_cleanup EXIT TERM INT
>  
>  test_per_thread() {
>    echo "Basic --per-thread mode test"
> @@ -30,13 +30,13 @@ test_per_thread() {
>      fi
>      return
>    fi
> -  if ! perf record --per-thread -o ${perfdata} true 2> /dev/null
> +  if ! perf record --per-thread -o "${perfdata}" true 2> /dev/null
>    then
>      echo "Per-thread record [Failed record]"
>      err=1
>      return
>    fi
> -  if ! perf report -i ${perfdata} -q | egrep -q true
> +  if ! perf report -i "${perfdata}" -q | grep -q true
>    then
>      echo "Per-thread record [Failed missing output]"
>      err=1
> @@ -47,7 +47,7 @@ test_per_thread() {
>  
>  test_register_capture() {
>    echo "Register capture test"
> -  if ! perf list | egrep -q 'br_inst_retired.near_call'
> +  if ! perf list | grep -q 'br_inst_retired.near_call'
>    then
>      echo "Register capture test [Skipped missing event]"
>      if [ $err -ne 1 ]
> @@ -56,7 +56,7 @@ test_register_capture() {
>      fi
>      return
>    fi
> -  if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
> +  if ! perf record --intr-regs=\? 2>&1 | grep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
>    then
>      echo "Register capture test [Skipped missing registers]"
>      return
> @@ -64,7 +64,7 @@ test_register_capture() {
>    if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
>      -c 1000 --per-thread true 2> /dev/null \
>      | perf script -F ip,sym,iregs -i - 2> /dev/null \
> -    | egrep -q "DI:"
> +    | grep -q "DI:"
>    then
>      echo "Register capture test [Failed missing output]"
>      err=1


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

* Re: [PATCH 7/8] perf test: Test record with --threads option
  2022-10-20 17:26 ` [PATCH 7/8] perf test: Test record with --threads option Namhyung Kim
  2022-10-21  0:02   ` Ian Rogers
@ 2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Adrian Hunter @ 2022-10-21  8:45 UTC (permalink / raw)
  To: Namhyung Kim, Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, linux-perf-users

On 20/10/22 20:26, Namhyung Kim wrote:
> The --threads option changed the perf record behavior significantly, so
> it'd be nice if we test it separately.  Add --threads options with
> different argument in each test supported and check the result.
> 
> Also update the cleanup routine because threads recording produces data
> in a directory.
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/tests/shell/record.sh | 30 ++++++++++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index c59d1459c960..01aa9531b369 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -13,8 +13,8 @@ testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
>  testsym="test_loop"
>  
>  cleanup() {
> -  rm -f "${perfdata}"
> -  rm -f "${perfdata}".old
> +  rm -rf "${perfdata}"
> +  rm -rf "${perfdata}".old
>  
>    if [ "${testprog}" != "true" ]; then
>      rm -f "${testprog}"
> @@ -171,6 +171,19 @@ test_system_wide() {
>      err=1
>      return
>    fi
> +  if ! perf record -aB --synth=no -e cpu-clock,cs --threads=cpu \
> +    -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "System-wide record [Failed record --threads option]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "System-wide record [Failed --threads missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic --system-wide mode test [Success]"
>  }
>  
> @@ -188,6 +201,19 @@ test_workload() {
>      err=1
>      return
>    fi
> +  if ! perf record -e cpu-clock,cs --threads=package \
> +    -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "Workload record [Failed record --threads option]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "Workload record [Failed --threads missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic target workload test [Success]"
>  }
>  


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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-20 17:26 ` [PATCH 3/8] perf test: Use a test program in perf record tests Namhyung Kim
  2022-10-20 23:52   ` Ian Rogers
@ 2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Adrian Hunter @ 2022-10-21  8:45 UTC (permalink / raw)
  To: Namhyung Kim, Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, linux-perf-users

On 20/10/22 20:26, Namhyung Kim wrote:
> If the system has cc it could build a test program with two threads
> and then use it for more detailed testing.  Also it accepts an option
> to run a thread forever to ensure multi-thread runs.
> 
> If cc is not found, it falls back to use the default value 'true'.

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/tests/shell/record.sh | 64 ++++++++++++++++++++++++++++++--
>  1 file changed, 60 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 464071462809..952981481239 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -6,10 +6,17 @@ set -e
>  
>  err=0
>  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> +testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
> +testsym="test_loop"
>  
>  cleanup() {
>    rm -f "${perfdata}"
>    rm -f "${perfdata}".old
> +
> +  if [ "${testprog}" != "true" ]; then
> +    rm -f "${testprog}"
> +  fi
> +
>    trap - EXIT TERM INT
>  }
>  
> @@ -19,9 +26,56 @@ trap_cleanup() {
>  }
>  trap trap_cleanup EXIT TERM INT
>  
> +build_test_program() {
> +  if ! [ -x "$(command -v cc)" ]; then
> +    # No CC found. Fall back to 'true'
> +    testprog=true
> +    testsym=true
> +    return
> +  fi
> +
> +  echo "Build a test program"
> +  cat <<EOF | cc -o ${testprog} -xc - -pthread
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <pthread.h>
> +
> +void test_loop(void) {
> +  volatile int count = 1000000;
> +
> +  while (count--)
> +    continue;
> +}
> +
> +void *thfunc(void *arg) {
> +  int forever = *(int *)arg;
> +
> +  do {
> +    test_loop();
> +  } while (forever);
> +
> +  return NULL;
> +}
> +
> +int main(int argc, char *argv[]) {
> +  pthread_t th;
> +  int forever = 0;
> +
> +  if (argc > 1)
> +    forever = atoi(argv[1]);
> +
> +  pthread_create(&th, NULL, thfunc, &forever);
> +  test_loop();
> +  pthread_join(th, NULL);
> +
> +  return 0;
> +}
> +EOF
> +}
> +
>  test_per_thread() {
>    echo "Basic --per-thread mode test"
> -  if ! perf record -o /dev/null --quiet true 2> /dev/null
> +  if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
>    then
>      echo "Per-thread record [Skipped event not supported]"
>      if [ $err -ne 1 ]
> @@ -30,13 +84,13 @@ test_per_thread() {
>      fi
>      return
>    fi
> -  if ! perf record --per-thread -o "${perfdata}" true 2> /dev/null
> +  if ! perf record --per-thread -o "${perfdata}" ${testprog} 2> /dev/null
>    then
>      echo "Per-thread record [Failed record]"
>      err=1
>      return
>    fi
> -  if ! perf report -i "${perfdata}" -q | grep -q true
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
>    then
>      echo "Per-thread record [Failed missing output]"
>      err=1
> @@ -62,7 +116,7 @@ test_register_capture() {
>      return
>    fi
>    if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
> -    -c 1000 --per-thread true 2> /dev/null \
> +    -c 1000 --per-thread ${testprog} 2> /dev/null \
>      | perf script -F ip,sym,iregs -i - 2> /dev/null \
>      | grep -q "DI:"
>    then
> @@ -73,6 +127,8 @@ test_register_capture() {
>    echo "Register capture test [Success]"
>  }
>  
> +build_test_program
> +
>  test_per_thread
>  test_register_capture
>  


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

* Re: [PATCH 4/8] perf test: Wait for a new thread when testing --per-thread record
  2022-10-20 17:26 ` [PATCH 4/8] perf test: Wait for a new thread when testing --per-thread record Namhyung Kim
  2022-10-20 23:57   ` Ian Rogers
@ 2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Adrian Hunter @ 2022-10-21  8:45 UTC (permalink / raw)
  To: Namhyung Kim, Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, linux-perf-users

On 20/10/22 20:26, Namhyung Kim wrote:
> Just running the target program is not enough to test multi-thread
> target because it'd be racy perf vs target startup.  I used the
> initial delay but it cannot guarantee for perf to see the thread.
> 
> Instead, use wait_for_threads helper from shell/lib/waiting.sh to make
> sure it starts the sibling thread first.  Then perf record can use -p
> option to profile the target process.
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/tests/shell/record.sh | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 952981481239..d1640d1daf2e 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -4,6 +4,9 @@
>  
>  set -e
>  
> +shelldir=$(dirname "$0")
> +. "${shelldir}"/lib/waiting.sh
> +
>  err=0
>  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
>  testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
> @@ -96,6 +99,30 @@ test_per_thread() {
>      err=1
>      return
>    fi
> +
> +  # run the test program in background (forever)
> +  ${testprog} 1 &
> +  TESTPID=$!
> +
> +  rm -f "${perfdata}"
> +
> +  wait_for_threads ${TESTPID} 2
> +  perf record -p "${TESTPID}" --per-thread -o "${perfdata}" sleep 1 2> /dev/null
> +  kill ${TESTPID}
> +
> +  if [ ! -e "${perfdata}" ]
> +  then
> +    echo "Per-thread record [Failed record -p]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "Per-thread record [Failed -p missing output]"
> +    err=1
> +    return
> +  fi
> +
>    echo "Basic --per-thread mode test [Success]"
>  }
>  


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

* Re: [PATCH 6/8] perf test: Add target workload test in perf record tests
  2022-10-20 17:26 ` [PATCH 6/8] perf test: Add target workload test " Namhyung Kim
  2022-10-21  0:01   ` Ian Rogers
@ 2022-10-21  8:45   ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Adrian Hunter @ 2022-10-21  8:45 UTC (permalink / raw)
  To: Namhyung Kim, Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, linux-perf-users

On 20/10/22 20:26, Namhyung Kim wrote:
> Add a subtest which profiles the given workload on the command line.
> As it's a minimal requirement, test should run ok so it doesn't skip
> the test even if it failed to run the perf record.
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/tests/shell/record.sh | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 345764afb745..c59d1459c960 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -174,11 +174,29 @@ test_system_wide() {
>    echo "Basic --system-wide mode test [Success]"
>  }
>  
> +test_workload() {
> +  echo "Basic target workload test"
> +  if ! perf record -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "Workload record [Failed record]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "Workload record [Failed missing output]"
> +    err=1
> +    return
> +  fi
> +  echo "Basic target workload test [Success]"
> +}
> +
>  build_test_program
>  
>  test_per_thread
>  test_register_capture
>  test_system_wide
> +test_workload
>  
>  cleanup
>  exit $err


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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-20 23:52   ` Ian Rogers
@ 2022-10-24 11:33     ` Arnaldo Carvalho de Melo
  2022-10-24 14:00       ` Adrian Hunter
  2022-10-25  4:18       ` Namhyung Kim
  0 siblings, 2 replies; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-10-24 11:33 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Namhyung Kim, Jiri Olsa, Ingo Molnar, Peter Zijlstra, LKML,
	Adrian Hunter, linux-perf-users

Em Thu, Oct 20, 2022 at 04:52:14PM -0700, Ian Rogers escreveu:
> On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:

> > If the system has cc it could build a test program with two threads
> > and then use it for more detailed testing.  Also it accepts an option
> > to run a thread forever to ensure multi-thread runs.
> >
> > If cc is not found, it falls back to use the default value 'true'.
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> 
> Acked-by: Ian Rogers <irogers@google.com>
> 
> I wonder if these utilities should just be built into perf to avoid
> the cc dependency. Perhaps we can have a hidden option built into perf
> test.

Agreed, not depending on a compiler makes 'perf test' usable in more
systems, particularly production ones where we may want to check if perf
is passing all tests applicable to that system.

- Arnaldo
 
> Thanks,
> Ian
> 
> > ---
> >  tools/perf/tests/shell/record.sh | 64 ++++++++++++++++++++++++++++++--
> >  1 file changed, 60 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> > index 464071462809..952981481239 100755
> > --- a/tools/perf/tests/shell/record.sh
> > +++ b/tools/perf/tests/shell/record.sh
> > @@ -6,10 +6,17 @@ set -e
> >
> >  err=0
> >  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> > +testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
> > +testsym="test_loop"
> >
> >  cleanup() {
> >    rm -f "${perfdata}"
> >    rm -f "${perfdata}".old
> > +
> > +  if [ "${testprog}" != "true" ]; then
> > +    rm -f "${testprog}"
> > +  fi
> > +
> >    trap - EXIT TERM INT
> >  }
> >
> > @@ -19,9 +26,56 @@ trap_cleanup() {
> >  }
> >  trap trap_cleanup EXIT TERM INT
> >
> > +build_test_program() {
> > +  if ! [ -x "$(command -v cc)" ]; then
> > +    # No CC found. Fall back to 'true'
> > +    testprog=true
> > +    testsym=true
> > +    return
> > +  fi
> > +
> > +  echo "Build a test program"
> > +  cat <<EOF | cc -o ${testprog} -xc - -pthread
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <pthread.h>
> > +
> > +void test_loop(void) {
> > +  volatile int count = 1000000;
> > +
> > +  while (count--)
> > +    continue;
> > +}
> > +
> > +void *thfunc(void *arg) {
> > +  int forever = *(int *)arg;
> > +
> > +  do {
> > +    test_loop();
> > +  } while (forever);
> > +
> > +  return NULL;
> > +}
> > +
> > +int main(int argc, char *argv[]) {
> > +  pthread_t th;
> > +  int forever = 0;
> > +
> > +  if (argc > 1)
> > +    forever = atoi(argv[1]);
> > +
> > +  pthread_create(&th, NULL, thfunc, &forever);
> > +  test_loop();
> > +  pthread_join(th, NULL);
> > +
> > +  return 0;
> > +}
> > +EOF
> > +}
> > +
> >  test_per_thread() {
> >    echo "Basic --per-thread mode test"
> > -  if ! perf record -o /dev/null --quiet true 2> /dev/null
> > +  if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
> >    then
> >      echo "Per-thread record [Skipped event not supported]"
> >      if [ $err -ne 1 ]
> > @@ -30,13 +84,13 @@ test_per_thread() {
> >      fi
> >      return
> >    fi
> > -  if ! perf record --per-thread -o "${perfdata}" true 2> /dev/null
> > +  if ! perf record --per-thread -o "${perfdata}" ${testprog} 2> /dev/null
> >    then
> >      echo "Per-thread record [Failed record]"
> >      err=1
> >      return
> >    fi
> > -  if ! perf report -i "${perfdata}" -q | grep -q true
> > +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> >    then
> >      echo "Per-thread record [Failed missing output]"
> >      err=1
> > @@ -62,7 +116,7 @@ test_register_capture() {
> >      return
> >    fi
> >    if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
> > -    -c 1000 --per-thread true 2> /dev/null \
> > +    -c 1000 --per-thread ${testprog} 2> /dev/null \
> >      | perf script -F ip,sym,iregs -i - 2> /dev/null \
> >      | grep -q "DI:"
> >    then
> > @@ -73,6 +127,8 @@ test_register_capture() {
> >    echo "Register capture test [Success]"
> >  }
> >
> > +build_test_program
> > +
> >  test_per_thread
> >  test_register_capture
> >
> > --
> > 2.38.0.135.g90850a2211-goog
> >

-- 

- Arnaldo

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

* Re: [PATCH 8/8] perf test: Do not set TEST_SKIP for record subtests
  2022-10-21  0:05   ` Ian Rogers
@ 2022-10-24 11:34     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-10-24 11:34 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Namhyung Kim, Jiri Olsa, Ingo Molnar, Peter Zijlstra, LKML,
	Adrian Hunter, linux-perf-users

Em Thu, Oct 20, 2022 at 05:05:49PM -0700, Ian Rogers escreveu:
> On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > It now has 4 sub tests and one of them should run at least.
> > But once TEST_SKIP (= 2) return value is set, it won't be overwritten
> > unless there's a failure.  I think we should return success when one
> > or more tested are skipped but the remaining subtests are passed.
> >
> > So update the test code not to set the err variable when it skips
> > the test.
> >
> > Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> 
> Acked-by: Ian Rogers <irogers@google.com>
> 
> Perhaps we can have proper sub-tests in shell tests like we do for the C ones.

Yeah, giving info about the various subtests helps in giving progress
information and overal confidence that more stuff is being tested.

- Arnaldo
 
> Thanks,
> Ian
> 
> > ---
> >  tools/perf/tests/shell/record.sh | 12 ------------
> >  1 file changed, 12 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> > index 01aa9531b369..e93b3a8871fe 100755
> > --- a/tools/perf/tests/shell/record.sh
> > +++ b/tools/perf/tests/shell/record.sh
> > @@ -81,10 +81,6 @@ test_per_thread() {
> >    if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
> >    then
> >      echo "Per-thread record [Skipped event not supported]"
> > -    if [ $err -ne 1 ]
> > -    then
> > -      err=2
> > -    fi
> >      return
> >    fi
> >    if ! perf record --per-thread -o "${perfdata}" ${testprog} 2> /dev/null
> > @@ -131,10 +127,6 @@ test_register_capture() {
> >    if ! perf list | grep -q 'br_inst_retired.near_call'
> >    then
> >      echo "Register capture test [Skipped missing event]"
> > -    if [ $err -ne 1 ]
> > -    then
> > -      err=2
> > -    fi
> >      return
> >    fi
> >    if ! perf record --intr-regs=\? 2>&1 | grep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
> > @@ -159,10 +151,6 @@ test_system_wide() {
> >    if ! perf record -aB --synth=no -o "${perfdata}" ${testprog} 2> /dev/null
> >    then
> >      echo "System-wide record [Skipped not supported]"
> > -    if [ $err -ne 1 ]
> > -    then
> > -      err=2
> > -    fi
> >      return
> >    fi
> >    if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> > --
> > 2.38.0.135.g90850a2211-goog
> >

-- 

- Arnaldo

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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-24 11:33     ` Arnaldo Carvalho de Melo
@ 2022-10-24 14:00       ` Adrian Hunter
  2022-10-24 16:00         ` Arnaldo Carvalho de Melo
  2022-10-25  4:18       ` Namhyung Kim
  1 sibling, 1 reply; 32+ messages in thread
From: Adrian Hunter @ 2022-10-24 14:00 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ian Rogers
  Cc: Namhyung Kim, Jiri Olsa, Ingo Molnar, Peter Zijlstra, LKML,
	Adrian Hunter, linux-perf-users

On 24/10/22 14:33, Arnaldo Carvalho de Melo wrote:
> Em Thu, Oct 20, 2022 at 04:52:14PM -0700, Ian Rogers escreveu:
>> On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
> 
>>> If the system has cc it could build a test program with two threads
>>> and then use it for more detailed testing.  Also it accepts an option
>>> to run a thread forever to ensure multi-thread runs.
>>>
>>> If cc is not found, it falls back to use the default value 'true'.
>>>
>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>>
>> Acked-by: Ian Rogers <irogers@google.com>
>>
>> I wonder if these utilities should just be built into perf to avoid
>> the cc dependency. Perhaps we can have a hidden option built into perf
>> test.
> 
> Agreed, not depending on a compiler makes 'perf test' usable in more
> systems, particularly production ones where we may want to check if perf
> is passing all tests applicable to that system.

I haven't seen anyone package anything except the perf executable, so
I presume the only people running these tests install the source, and
so need a compiler anyway.


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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-24 14:00       ` Adrian Hunter
@ 2022-10-24 16:00         ` Arnaldo Carvalho de Melo
  2022-10-25  4:12           ` Namhyung Kim
  2022-10-25 13:17           ` Adrian Hunter
  0 siblings, 2 replies; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-10-24 16:00 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ian Rogers, Namhyung Kim, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, linux-perf-users

Em Mon, Oct 24, 2022 at 05:00:14PM +0300, Adrian Hunter escreveu:
> On 24/10/22 14:33, Arnaldo Carvalho de Melo wrote:
> > Em Thu, Oct 20, 2022 at 04:52:14PM -0700, Ian Rogers escreveu:
> >> I wonder if these utilities should just be built into perf to avoid
> >> the cc dependency. Perhaps we can have a hidden option built into
> >> perf test.

> > Agreed, not depending on a compiler makes 'perf test' usable in more
> > systems, particularly production ones where we may want to check if perf
> > is passing all tests applicable to that system.
 
> I haven't seen anyone package anything except the perf executable, so
> I presume the only people running these tests install the source, and
> so need a compiler anyway.

Humm?

[root@quaco ~]# head -3 /etc/os-release
NAME="Fedora Linux"
VERSION="36 (Workstation Edition)"
ID=fedora
[root@quaco ~]#G

[root@quaco ~]# rpm -qi perf
Name        : perf
Version     : 5.19.4
Release     : 200.fc36
Architecture: x86_64
Install Date: Mon 24 Oct 2022 12:57:34 PM -03
Group       : Unspecified
Size        : 12663136
License     : GPLv2
Signature   : RSA/SHA256, Thu 25 Aug 2022 07:16:04 PM -03, Key ID 999f7cbf38ab71f4
Source RPM  : kernel-tools-5.19.4-200.fc36.src.rpm
Build Date  : Thu 25 Aug 2022 06:30:42 PM -03
Build Host  : bkernel02.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.kernel.org/
Bug URL     : https://bugz.fedoraproject.org/kernel-tools
Summary     : Performance monitoring for the Linux kernel
Description :
This package contains the perf tool, which enables performance monitoring
of the Linux kernel.
[root@quaco ~]#

[root@quaco ~]# rpm -ql perf
/etc/bash_completion.d/perf
/usr/bin/perf
/usr/lib/.build-id
/usr/lib/.build-id/0c
/usr/lib/.build-id/0c/54d587cab1b533b9ab777717ddd256ff84f241
/usr/lib/.build-id/15
/usr/lib/.build-id/15/6552556be0d4ca8cffb8e002d8a67add55aed5
/usr/lib/.build-id/15/c4dfaa3861f530ef60def5506385d4b0b8924f
/usr/lib/.build-id/1f
/usr/lib/.build-id/1f/799c084e326516a24a647cfd5f484cd054e0a2
/usr/lib/.build-id/23
/usr/lib/.build-id/23/311fe148dd3f3d487ca5ace54ff2faa72ea8da
/usr/lib/.build-id/37
/usr/lib/.build-id/37/c9ee70f321fae7fc1fc00fca91514c63f9f052
/usr/lib/.build-id/54
/usr/lib/.build-id/54/43b6bc332ad188b907fdde69ac02c9a69d158f
/usr/lib/.build-id/7e
/usr/lib/.build-id/7e/55e7a8e4df03137ec23b4135e205bc8eb77e05
/usr/lib/.build-id/84
/usr/lib/.build-id/84/3c3863a123d129c98fa7cb99a58d620c9e5edc
/usr/lib/.build-id/86
/usr/lib/.build-id/86/d063d2f9833a447d96504e5f9e472048d12c49
/usr/lib/.build-id/98
/usr/lib/.build-id/98/a28589fde6ce95d9f3d305f7c9853333a9415b
/usr/lib/.build-id/9e
/usr/lib/.build-id/9e/567f55ca9c2b4867eb95d4182da07d4843976d
/usr/lib/.build-id/b6
/usr/lib/.build-id/b6/f8c9a6d6e1990f8577a9fbac875f812a316a20
/usr/lib/.build-id/c0
/usr/lib/.build-id/c0/8b255f02ce8f3e90df2b6156d2d38b1221995d
/usr/lib/.build-id/d5/e964c3413f52492e6355852d25b2ab23b03e38
/usr/lib/.build-id/e8
/usr/lib/.build-id/e8/2de614bf77f501a4511cb70151b98392669c77
/usr/lib64/libperf-jvmti.so
/usr/libexec/perf-core
/usr/libexec/perf-core/dlfilters
/usr/libexec/perf-core/dlfilters/dlfilter-show-cycles.so
/usr/libexec/perf-core/dlfilters/dlfilter-test-api-v0.so
/usr/libexec/perf-core/perf-archive
/usr/libexec/perf-core/perf-iostat
/usr/libexec/perf-core/scripts
/usr/libexec/perf-core/scripts/perl
/usr/libexec/perf-core/scripts/perl/Perf-Trace-Util
/usr/libexec/perf-core/scripts/perl/Perf-Trace-Util/lib
/usr/libexec/perf-core/scripts/perl/Perf-Trace-Util/lib/Perf
/usr/libexec/perf-core/scripts/perl/Perf-Trace-Util/lib/Perf/Trace
/usr/libexec/perf-core/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Context.pm
/usr/libexec/perf-core/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm
/usr/libexec/perf-core/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm
/usr/libexec/perf-core/scripts/perl/bin
/usr/libexec/perf-core/scripts/perl/bin/check-perf-trace-record
/usr/libexec/perf-core/scripts/perl/bin/failed-syscalls-record
/usr/libexec/perf-core/scripts/perl/bin/failed-syscalls-report
/usr/libexec/perf-core/scripts/perl/bin/rw-by-file-record
/usr/libexec/perf-core/scripts/perl/bin/rw-by-file-report
/usr/libexec/perf-core/scripts/perl/bin/rw-by-pid-record
/usr/libexec/perf-core/scripts/perl/bin/rw-by-pid-report
/usr/libexec/perf-core/scripts/perl/bin/rwtop-record
/usr/libexec/perf-core/scripts/perl/bin/rwtop-report
/usr/libexec/perf-core/scripts/perl/bin/wakeup-latency-record
/usr/libexec/perf-core/scripts/perl/bin/wakeup-latency-report
/usr/libexec/perf-core/scripts/perl/check-perf-trace.pl
/usr/libexec/perf-core/scripts/perl/failed-syscalls.pl
/usr/libexec/perf-core/scripts/perl/rw-by-file.pl
/usr/libexec/perf-core/scripts/perl/rw-by-pid.pl
/usr/libexec/perf-core/scripts/perl/rwtop.pl
/usr/libexec/perf-core/scripts/perl/wakeup-latency.pl
/usr/libexec/perf-core/scripts/python
/usr/libexec/perf-core/scripts/python/Perf-Trace-Util
/usr/libexec/perf-core/scripts/python/Perf-Trace-Util/lib
/usr/libexec/perf-core/scripts/python/Perf-Trace-Util/lib/Perf
/usr/libexec/perf-core/scripts/python/Perf-Trace-Util/lib/Perf/Trace
/usr/libexec/perf-core/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
/usr/libexec/perf-core/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py
/usr/libexec/perf-core/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py
/usr/libexec/perf-core/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
/usr/libexec/perf-core/scripts/python/arm-cs-trace-disasm.py
/usr/libexec/perf-core/scripts/python/bin
/usr/libexec/perf-core/scripts/python/bin/compaction-times-record
/usr/libexec/perf-core/scripts/python/bin/compaction-times-report
/usr/libexec/perf-core/scripts/python/bin/event_analyzing_sample-record
/usr/libexec/perf-core/scripts/python/bin/event_analyzing_sample-report
/usr/libexec/perf-core/scripts/python/bin/export-to-postgresql-record
/usr/libexec/perf-core/scripts/python/bin/export-to-postgresql-report
/usr/libexec/perf-core/scripts/python/bin/export-to-sqlite-record
/usr/libexec/perf-core/scripts/python/bin/export-to-sqlite-report
/usr/libexec/perf-core/scripts/python/bin/failed-syscalls-by-pid-record
/usr/libexec/perf-core/scripts/python/bin/failed-syscalls-by-pid-report
/usr/libexec/perf-core/scripts/python/bin/flamegraph-record
/usr/libexec/perf-core/scripts/python/bin/flamegraph-report
/usr/libexec/perf-core/scripts/python/bin/futex-contention-record
/usr/libexec/perf-core/scripts/python/bin/futex-contention-report
/usr/libexec/perf-core/scripts/python/bin/intel-pt-events-record
/usr/libexec/perf-core/scripts/python/bin/intel-pt-events-report
/usr/libexec/perf-core/scripts/python/bin/mem-phys-addr-record
/usr/libexec/perf-core/scripts/python/bin/mem-phys-addr-report
/usr/libexec/perf-core/scripts/python/bin/net_dropmonitor-record
/usr/libexec/perf-core/scripts/python/bin/net_dropmonitor-report
/usr/libexec/perf-core/scripts/python/bin/netdev-times-record
/usr/libexec/perf-core/scripts/python/bin/netdev-times-report
/usr/libexec/perf-core/scripts/python/bin/powerpc-hcalls-record
/usr/libexec/perf-core/scripts/python/bin/powerpc-hcalls-report
/usr/libexec/perf-core/scripts/python/bin/sched-migration-record
/usr/libexec/perf-core/scripts/python/bin/sched-migration-report
/usr/libexec/perf-core/scripts/python/bin/sctop-record
/usr/libexec/perf-core/scripts/python/bin/sctop-report
/usr/libexec/perf-core/scripts/python/bin/stackcollapse-record
/usr/libexec/perf-core/scripts/python/bin/stackcollapse-report
/usr/libexec/perf-core/scripts/python/bin/syscall-counts-by-pid-record
/usr/libexec/perf-core/scripts/python/bin/syscall-counts-by-pid-report
/usr/libexec/perf-core/scripts/python/bin/syscall-counts-record
/usr/libexec/perf-core/scripts/python/bin/syscall-counts-report
/usr/libexec/perf-core/scripts/python/check-perf-trace.py
/usr/libexec/perf-core/scripts/python/compaction-times.py
/usr/libexec/perf-core/scripts/python/event_analyzing_sample.py
/usr/libexec/perf-core/scripts/python/export-to-postgresql.py
/usr/libexec/perf-core/scripts/python/export-to-sqlite.py
/usr/libexec/perf-core/scripts/python/exported-sql-viewer.py
/usr/libexec/perf-core/scripts/python/failed-syscalls-by-pid.py
/usr/libexec/perf-core/scripts/python/flamegraph.py
/usr/libexec/perf-core/scripts/python/futex-contention.py
/usr/libexec/perf-core/scripts/python/intel-pt-events.py
/usr/libexec/perf-core/scripts/python/libxed.py
/usr/libexec/perf-core/scripts/python/mem-phys-addr.py
/usr/libexec/perf-core/scripts/python/net_dropmonitor.py
/usr/libexec/perf-core/scripts/python/netdev-times.py
/usr/libexec/perf-core/scripts/python/powerpc-hcalls.py
/usr/libexec/perf-core/scripts/python/sched-migration.py
/usr/libexec/perf-core/scripts/python/sctop.py
/usr/libexec/perf-core/scripts/python/stackcollapse.py
/usr/libexec/perf-core/scripts/python/stat-cpi.py
/usr/libexec/perf-core/scripts/python/syscall-counts-by-pid.py
/usr/libexec/perf-core/scripts/python/syscall-counts.py
/usr/libexec/perf-core/tests
/usr/libexec/perf-core/tests/attr
/usr/libexec/perf-core/tests/attr.py
/usr/libexec/perf-core/tests/attr/README
/usr/libexec/perf-core/tests/attr/base-record
/usr/libexec/perf-core/tests/attr/base-record-spe
/usr/libexec/perf-core/tests/attr/base-stat
/usr/libexec/perf-core/tests/attr/system-wide-dummy
/usr/libexec/perf-core/tests/attr/test-record-C0
/usr/libexec/perf-core/tests/attr/test-record-basic
/usr/libexec/perf-core/tests/attr/test-record-branch-any
/usr/libexec/perf-core/tests/attr/test-record-branch-filter-any
/usr/libexec/perf-core/tests/attr/test-record-branch-filter-any_call
/usr/libexec/perf-core/tests/attr/test-record-branch-filter-any_ret
/usr/libexec/perf-core/tests/attr/test-record-branch-filter-hv
/usr/libexec/perf-core/tests/attr/test-record-branch-filter-ind_call
/usr/libexec/perf-core/tests/attr/test-record-branch-filter-k
/usr/libexec/perf-core/tests/attr/test-record-branch-filter-u
/usr/libexec/perf-core/tests/attr/test-record-count
/usr/libexec/perf-core/tests/attr/test-record-data
/usr/libexec/perf-core/tests/attr/test-record-freq
/usr/libexec/perf-core/tests/attr/test-record-graph-default
/usr/libexec/perf-core/tests/attr/test-record-graph-default-aarch64
/usr/libexec/perf-core/tests/attr/test-record-graph-dwarf
/usr/libexec/perf-core/tests/attr/test-record-graph-fp
/usr/libexec/perf-core/tests/attr/test-record-graph-fp-aarch64
/usr/libexec/perf-core/tests/attr/test-record-group
/usr/libexec/perf-core/tests/attr/test-record-group-sampling
/usr/libexec/perf-core/tests/attr/test-record-group1
/usr/libexec/perf-core/tests/attr/test-record-group2
/usr/libexec/perf-core/tests/attr/test-record-no-buffering
/usr/libexec/perf-core/tests/attr/test-record-no-inherit
/usr/libexec/perf-core/tests/attr/test-record-no-samples
/usr/libexec/perf-core/tests/attr/test-record-period
/usr/libexec/perf-core/tests/attr/test-record-pfm-period
/usr/libexec/perf-core/tests/attr/test-record-raw
/usr/libexec/perf-core/tests/attr/test-record-spe-period
/usr/libexec/perf-core/tests/attr/test-record-spe-period-term
/usr/libexec/perf-core/tests/attr/test-record-spe-physical-address
/usr/libexec/perf-core/tests/attr/test-stat-C0
/usr/libexec/perf-core/tests/attr/test-stat-basic
/usr/libexec/perf-core/tests/attr/test-stat-default
/usr/libexec/perf-core/tests/attr/test-stat-detailed-1
/usr/libexec/perf-core/tests/attr/test-stat-detailed-2
/usr/libexec/perf-core/tests/attr/test-stat-detailed-3
/usr/libexec/perf-core/tests/attr/test-stat-group
/usr/libexec/perf-core/tests/attr/test-stat-group1
/usr/libexec/perf-core/tests/attr/test-stat-no-inherit
/usr/libexec/perf-core/tests/pe-file.exe
/usr/libexec/perf-core/tests/pe-file.exe.debug
/usr/libexec/perf-core/tests/shell
/usr/libexec/perf-core/tests/shell/buildid.sh
/usr/libexec/perf-core/tests/shell/daemon.sh
/usr/libexec/perf-core/tests/shell/lib
/usr/libexec/perf-core/tests/shell/lib/probe.sh
/usr/libexec/perf-core/tests/shell/lib/probe_vfs_getname.sh
/usr/libexec/perf-core/tests/shell/pipe_test.sh
/usr/libexec/perf-core/tests/shell/probe_vfs_getname.sh
/usr/libexec/perf-core/tests/shell/record+probe_libc_inet_pton.sh
/usr/libexec/perf-core/tests/shell/record+script_probe_vfs_getname.sh
/usr/libexec/perf-core/tests/shell/record+zstd_comp_decomp.sh
/usr/libexec/perf-core/tests/shell/record.sh
/usr/libexec/perf-core/tests/shell/record_offcpu.sh
/usr/libexec/perf-core/tests/shell/stat+csv_output.sh
/usr/libexec/perf-core/tests/shell/stat+csv_summary.sh
/usr/libexec/perf-core/tests/shell/stat+shadow_stat.sh
/usr/libexec/perf-core/tests/shell/stat.sh
/usr/libexec/perf-core/tests/shell/stat_all_metricgroups.sh
/usr/libexec/perf-core/tests/shell/stat_all_metrics.sh
/usr/libexec/perf-core/tests/shell/stat_all_pmu.sh
/usr/libexec/perf-core/tests/shell/stat_bpf_counters.sh
/usr/libexec/perf-core/tests/shell/test_arm_callgraph_fp.sh
/usr/libexec/perf-core/tests/shell/test_arm_coresight.sh
/usr/libexec/perf-core/tests/shell/test_arm_spe.sh
/usr/libexec/perf-core/tests/shell/test_arm_spe_fork.sh
/usr/libexec/perf-core/tests/shell/test_intel_pt.sh
/usr/libexec/perf-core/tests/shell/trace+probe_vfs_getname.sh
/usr/share/doc/perf
/usr/share/doc/perf-tip/tips.txt
/usr/share/doc/perf/examples.txt
/usr/share/licenses/perf
/usr/share/licenses/perf/COPYING
/usr/share/man/man1/perf-annotate.1.gz
/usr/share/man/man1/perf-archive.1.gz
/usr/share/man/man1/perf-arm-spe.1.gz
/usr/share/man/man1/perf-bench.1.gz
/usr/share/man/man1/perf-buildid-cache.1.gz
/usr/share/man/man1/perf-buildid-list.1.gz
/usr/share/man/man1/perf-c2c.1.gz
/usr/share/man/man1/perf-config.1.gz
/usr/share/man/man1/perf-daemon.1.gz
/usr/share/man/man1/perf-data.1.gz
/usr/share/man/man1/perf-diff.1.gz
/usr/share/man/man1/perf-dlfilter.1.gz
/usr/share/man/man1/perf-evlist.1.gz
/usr/share/man/man1/perf-ftrace.1.gz
/usr/share/man/man1/perf-help.1.gz
/usr/share/man/man1/perf-inject.1.gz
/usr/share/man/man1/perf-intel-pt.1.gz
/usr/share/man/man1/perf-iostat.1.gz
/usr/share/man/man1/perf-kallsyms.1.gz
/usr/share/man/man1/perf-kmem.1.gz
/usr/share/man/man1/perf-kvm.1.gz
/usr/share/man/man1/perf-list.1.gz
/usr/share/man/man1/perf-lock.1.gz
/usr/share/man/man1/perf-mem.1.gz
/usr/share/man/man1/perf-probe.1.gz
/usr/share/man/man1/perf-record.1.gz
/usr/share/man/man1/perf-report.1.gz
/usr/share/man/man1/perf-sched.1.gz
/usr/share/man/man1/perf-script-perl.1.gz
/usr/share/man/man1/perf-script-python.1.gz
/usr/share/man/man1/perf-script.1.gz
/usr/share/man/man1/perf-stat.1.gz
/usr/share/man/man1/perf-test.1.gz
/usr/share/man/man1/perf-timechart.1.gz
/usr/share/man/man1/perf-top.1.gz
/usr/share/man/man1/perf-trace.1.gz
/usr/share/man/man1/perf-version.1.gz
/usr/share/man/man1/perf.1.gz
/usr/share/perf-core
/usr/share/perf-core/strace
/usr/share/perf-core/strace/groups
/usr/share/perf-core/strace/groups/file
/usr/share/perf-core/strace/groups/string

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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-24 16:00         ` Arnaldo Carvalho de Melo
@ 2022-10-25  4:12           ` Namhyung Kim
  2022-10-25 13:10             ` Arnaldo Carvalho de Melo
  2022-10-25 13:17           ` Adrian Hunter
  1 sibling, 1 reply; 32+ messages in thread
From: Namhyung Kim @ 2022-10-25  4:12 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Adrian Hunter, Ian Rogers, Jiri Olsa, Ingo Molnar,
	Peter Zijlstra, LKML, linux-perf-users

On Mon, Oct 24, 2022 at 9:00 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Mon, Oct 24, 2022 at 05:00:14PM +0300, Adrian Hunter escreveu:
> > On 24/10/22 14:33, Arnaldo Carvalho de Melo wrote:
> > > Em Thu, Oct 20, 2022 at 04:52:14PM -0700, Ian Rogers escreveu:
> > >> I wonder if these utilities should just be built into perf to avoid
> > >> the cc dependency. Perhaps we can have a hidden option built into
> > >> perf test.
>
> > > Agreed, not depending on a compiler makes 'perf test' usable in more
> > > systems, particularly production ones where we may want to check if perf
> > > is passing all tests applicable to that system.
>
> > I haven't seen anyone package anything except the perf executable, so
> > I presume the only people running these tests install the source, and
> > so need a compiler anyway.
>
> Humm?
>
> [root@quaco ~]# head -3 /etc/os-release
> NAME="Fedora Linux"
> VERSION="36 (Workstation Edition)"
> ID=fedora
> [root@quaco ~]#G
>
> [root@quaco ~]# rpm -qi perf
> Name        : perf
> Version     : 5.19.4
> Release     : 200.fc36
> Architecture: x86_64
> Install Date: Mon 24 Oct 2022 12:57:34 PM -03
> Group       : Unspecified
> Size        : 12663136
> License     : GPLv2
> Signature   : RSA/SHA256, Thu 25 Aug 2022 07:16:04 PM -03, Key ID 999f7cbf38ab71f4
> Source RPM  : kernel-tools-5.19.4-200.fc36.src.rpm
> Build Date  : Thu 25 Aug 2022 06:30:42 PM -03
> Build Host  : bkernel02.iad2.fedoraproject.org
> Packager    : Fedora Project
> Vendor      : Fedora Project
> URL         : http://www.kernel.org/
> Bug URL     : https://bugz.fedoraproject.org/kernel-tools
> Summary     : Performance monitoring for the Linux kernel
> Description :
> This package contains the perf tool, which enables performance monitoring
> of the Linux kernel.
> [root@quaco ~]#
>
> [root@quaco ~]# rpm -ql perf
> /etc/bash_completion.d/perf
> /usr/bin/perf
> /usr/lib/.build-id
> /usr/lib/.build-id/0c
> /usr/lib/.build-id/0c/54d587cab1b533b9ab777717ddd256ff84f241
> /usr/lib/.build-id/15
> /usr/lib/.build-id/15/6552556be0d4ca8cffb8e002d8a67add55aed5
> /usr/lib/.build-id/15/c4dfaa3861f530ef60def5506385d4b0b8924f
> /usr/lib/.build-id/1f
> /usr/lib/.build-id/1f/799c084e326516a24a647cfd5f484cd054e0a2
> /usr/lib/.build-id/23
> /usr/lib/.build-id/23/311fe148dd3f3d487ca5ace54ff2faa72ea8da
> /usr/lib/.build-id/37
> /usr/lib/.build-id/37/c9ee70f321fae7fc1fc00fca91514c63f9f052
> /usr/lib/.build-id/54
> /usr/lib/.build-id/54/43b6bc332ad188b907fdde69ac02c9a69d158f
> /usr/lib/.build-id/7e
> /usr/lib/.build-id/7e/55e7a8e4df03137ec23b4135e205bc8eb77e05
> /usr/lib/.build-id/84
> /usr/lib/.build-id/84/3c3863a123d129c98fa7cb99a58d620c9e5edc
> /usr/lib/.build-id/86
> /usr/lib/.build-id/86/d063d2f9833a447d96504e5f9e472048d12c49
> /usr/lib/.build-id/98
> /usr/lib/.build-id/98/a28589fde6ce95d9f3d305f7c9853333a9415b
> /usr/lib/.build-id/9e
> /usr/lib/.build-id/9e/567f55ca9c2b4867eb95d4182da07d4843976d
> /usr/lib/.build-id/b6
> /usr/lib/.build-id/b6/f8c9a6d6e1990f8577a9fbac875f812a316a20
> /usr/lib/.build-id/c0
> /usr/lib/.build-id/c0/8b255f02ce8f3e90df2b6156d2d38b1221995d
> /usr/lib/.build-id/d5/e964c3413f52492e6355852d25b2ab23b03e38
> /usr/lib/.build-id/e8
> /usr/lib/.build-id/e8/2de614bf77f501a4511cb70151b98392669c77

Interesting, it contains some build-ids for system libraries?

Thanks,
Namhyung

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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-24 11:33     ` Arnaldo Carvalho de Melo
  2022-10-24 14:00       ` Adrian Hunter
@ 2022-10-25  4:18       ` Namhyung Kim
  1 sibling, 0 replies; 32+ messages in thread
From: Namhyung Kim @ 2022-10-25  4:18 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ian Rogers, Jiri Olsa, Ingo Molnar, Peter Zijlstra, LKML,
	Adrian Hunter, linux-perf-users

On Mon, Oct 24, 2022 at 4:33 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Thu, Oct 20, 2022 at 04:52:14PM -0700, Ian Rogers escreveu:
> > On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> > > If the system has cc it could build a test program with two threads
> > > and then use it for more detailed testing.  Also it accepts an option
> > > to run a thread forever to ensure multi-thread runs.
> > >
> > > If cc is not found, it falls back to use the default value 'true'.
> > >
> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> >
> > Acked-by: Ian Rogers <irogers@google.com>
> >
> > I wonder if these utilities should just be built into perf to avoid
> > the cc dependency. Perhaps we can have a hidden option built into perf
> > test.
>
> Agreed, not depending on a compiler makes 'perf test' usable in more
> systems, particularly production ones where we may want to check if perf
> is passing all tests applicable to that system.

Good idea.

I think we can add an option (like -w/--workload) to run the specified
workload rather than executing the tests.  Like below (assuming we
have a workload called 'noploop').  Thoughts?

  $ perf stat -- perf test -w noploop

Thanks,
Namhyung

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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-25  4:12           ` Namhyung Kim
@ 2022-10-25 13:10             ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-10-25 13:10 UTC (permalink / raw)
  To: Namhyung Kim, Justin M. Forbes, Steven Rostedt
  Cc: Adrian Hunter, Ian Rogers, Jiri Olsa, Ingo Molnar,
	Peter Zijlstra, LKML, linux-perf-users

Em Mon, Oct 24, 2022 at 09:12:21PM -0700, Namhyung Kim escreveu:
> On Mon, Oct 24, 2022 at 9:00 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> > Em Mon, Oct 24, 2022 at 05:00:14PM +0300, Adrian Hunter escreveu:
> > > On 24/10/22 14:33, Arnaldo Carvalho de Melo wrote:
> > > > Em Thu, Oct 20, 2022 at 04:52:14PM -0700, Ian Rogers escreveu:
> > > >> I wonder if these utilities should just be built into perf to avoid
> > > >> the cc dependency. Perhaps we can have a hidden option built into
> > > >> perf test.

> > > > Agreed, not depending on a compiler makes 'perf test' usable in more
> > > > systems, particularly production ones where we may want to check if perf
> > > > is passing all tests applicable to that system.

> > > I haven't seen anyone package anything except the perf executable, so
> > > I presume the only people running these tests install the source, and
> > > so need a compiler anyway.

> > Humm?

> > [root@quaco ~]# head -3 /etc/os-release
> > NAME="Fedora Linux"
> > VERSION="36 (Workstation Edition)"
> > ID=fedora
> > [root@quaco ~]#G

> > [root@quaco ~]# rpm -qi perf
> > Name        : perf
> > Version     : 5.19.4
> > Release     : 200.fc36
> > Architecture: x86_64
> > Install Date: Mon 24 Oct 2022 12:57:34 PM -03
> > Group       : Unspecified
> > Size        : 12663136
> > License     : GPLv2
> > Signature   : RSA/SHA256, Thu 25 Aug 2022 07:16:04 PM -03, Key ID 999f7cbf38ab71f4
> > Source RPM  : kernel-tools-5.19.4-200.fc36.src.rpm
> > Build Date  : Thu 25 Aug 2022 06:30:42 PM -03
> > Build Host  : bkernel02.iad2.fedoraproject.org
> > Packager    : Fedora Project
> > Vendor      : Fedora Project
> > URL         : http://www.kernel.org/
> > Bug URL     : https://bugz.fedoraproject.org/kernel-tools
> > Summary     : Performance monitoring for the Linux kernel
> > Description :
> > This package contains the perf tool, which enables performance monitoring
> > of the Linux kernel.
> > [root@quaco ~]#
> >
> > [root@quaco ~]# rpm -ql perf
> > /etc/bash_completion.d/perf
> > /usr/bin/perf
> > /usr/lib/.build-id
> > /usr/lib/.build-id/0c
> > /usr/lib/.build-id/0c/54d587cab1b533b9ab777717ddd256ff84f241
> > /usr/lib/.build-id/15
> > /usr/lib/.build-id/15/6552556be0d4ca8cffb8e002d8a67add55aed5
> > /usr/lib/.build-id/15/c4dfaa3861f530ef60def5506385d4b0b8924f
> > /usr/lib/.build-id/1f
> > /usr/lib/.build-id/1f/799c084e326516a24a647cfd5f484cd054e0a2
> > /usr/lib/.build-id/23
> > /usr/lib/.build-id/23/311fe148dd3f3d487ca5ace54ff2faa72ea8da
> > /usr/lib/.build-id/37
> > /usr/lib/.build-id/37/c9ee70f321fae7fc1fc00fca91514c63f9f052
> > /usr/lib/.build-id/54
> > /usr/lib/.build-id/54/43b6bc332ad188b907fdde69ac02c9a69d158f
> > /usr/lib/.build-id/7e
> > /usr/lib/.build-id/7e/55e7a8e4df03137ec23b4135e205bc8eb77e05
> > /usr/lib/.build-id/84
> > /usr/lib/.build-id/84/3c3863a123d129c98fa7cb99a58d620c9e5edc
> > /usr/lib/.build-id/86
> > /usr/lib/.build-id/86/d063d2f9833a447d96504e5f9e472048d12c49
> > /usr/lib/.build-id/98
> > /usr/lib/.build-id/98/a28589fde6ce95d9f3d305f7c9853333a9415b
> > /usr/lib/.build-id/9e
> > /usr/lib/.build-id/9e/567f55ca9c2b4867eb95d4182da07d4843976d
> > /usr/lib/.build-id/b6
> > /usr/lib/.build-id/b6/f8c9a6d6e1990f8577a9fbac875f812a316a20
> > /usr/lib/.build-id/c0
> > /usr/lib/.build-id/c0/8b255f02ce8f3e90df2b6156d2d38b1221995d
> > /usr/lib/.build-id/d5/e964c3413f52492e6355852d25b2ab23b03e38
> > /usr/lib/.build-id/e8
> > /usr/lib/.build-id/e8/2de614bf77f501a4511cb70151b98392669c77
> 
> Interesting, it contains some build-ids for system libraries?

[acme@quaco ~]$ ls -la /usr/lib/.build-id/e8/2de614bf77f501a4511cb70151b98392669c77
lrwxrwxrwx. 1 root root 67 Aug 25 18:33 /usr/lib/.build-id/e8/2de614bf77f501a4511cb70151b98392669c77 -> ../../../../usr/libexec/perf-core/dlfilters/dlfilter-test-api-v0.so
[acme@quaco ~]$

Yeah, strange:

[acme@quaco ~]$ rpm -ql perf | grep build-id/../
/usr/lib/.build-id/0c/54d587cab1b533b9ab777717ddd256ff84f241
/usr/lib/.build-id/15/6552556be0d4ca8cffb8e002d8a67add55aed5
/usr/lib/.build-id/15/c4dfaa3861f530ef60def5506385d4b0b8924f
/usr/lib/.build-id/1f/799c084e326516a24a647cfd5f484cd054e0a2
/usr/lib/.build-id/23/311fe148dd3f3d487ca5ace54ff2faa72ea8da
/usr/lib/.build-id/37/c9ee70f321fae7fc1fc00fca91514c63f9f052
/usr/lib/.build-id/54/43b6bc332ad188b907fdde69ac02c9a69d158f
/usr/lib/.build-id/7e/55e7a8e4df03137ec23b4135e205bc8eb77e05
/usr/lib/.build-id/84/3c3863a123d129c98fa7cb99a58d620c9e5edc
/usr/lib/.build-id/86/d063d2f9833a447d96504e5f9e472048d12c49
/usr/lib/.build-id/98/a28589fde6ce95d9f3d305f7c9853333a9415b
/usr/lib/.build-id/9e/567f55ca9c2b4867eb95d4182da07d4843976d
/usr/lib/.build-id/b6/f8c9a6d6e1990f8577a9fbac875f812a316a20
/usr/lib/.build-id/c0/8b255f02ce8f3e90df2b6156d2d38b1221995d
/usr/lib/.build-id/d5/e964c3413f52492e6355852d25b2ab23b03e38
/usr/lib/.build-id/e8/2de614bf77f501a4511cb70151b98392669c77
[acme@quaco ~]$
[acme@quaco ~]$ rpm -ql perf | grep build-id/../ | xargs realpath
/usr/lib64/traceevent/plugins/plugin_sched_switch.so
/usr/lib64/traceevent/plugins/plugin_kmem.so
/usr/lib64/traceevent/plugins/plugin_tlb.so
/usr/lib64/traceevent/plugins/plugin_jbd2.so
/usr/lib64/traceevent/plugins/plugin_hrtimer.so
/usr/lib64/traceevent/plugins/plugin_mac80211.so
/usr/lib64/libperf-jvmti.so
/usr/lib64/traceevent/plugins/plugin_cfg80211.so
/usr/lib64/traceevent/plugins/plugin_xen.so
/usr/lib64/traceevent/plugins/plugin_kvm.so
/usr/libexec/perf-core/dlfilters/dlfilter-show-cycles.so
/usr/lib64/traceevent/plugins/plugin_scsi.so
/usr/lib64/traceevent/plugins/plugin_futex.so
/usr/bin/perf
/usr/lib64/traceevent/plugins/plugin_function.so
/usr/libexec/perf-core/dlfilters/dlfilter-test-api-v0.so
[acme@quaco ~]$ rpm -ql perf | grep build-id/../ | xargs realpath | xargs rpm -qf
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
perf-5.19.4-200.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
perf-5.19.4-200.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
perf-5.19.4-200.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
perf-5.19.4-200.fc36.x86_64
[acme@quaco ~]$

Humm, but then the build-ids are different...

[acme@quaco ~]$ rpm -ql libtraceevent | grep build-id/../
/usr/lib/.build-id/00/59bd37dc1c345eb2f98cf2bc1163bc1fd4b63e
/usr/lib/.build-id/00/b22aa8cc2b81e4cb383d8b4dc14cbeb958fda6
/usr/lib/.build-id/11/6a8d17c89795d2269d3d65906ea7c7c5bcb856
/usr/lib/.build-id/24/8bfb4534954eb71ab3e5f7887507cb8981f921
/usr/lib/.build-id/57/0768e8ea5155cf2759c4f5dca3736a73c3dfad
/usr/lib/.build-id/61/2744cd9cb2d1b0c569b0c86578d11be7227f27
/usr/lib/.build-id/9d/630834441f4e382ddcecef810b100737bb56e4
/usr/lib/.build-id/b0/57189b558351ace427ae0a650c248deca4badd
/usr/lib/.build-id/b1/a0003b83e307cf61d7c8a2751e5c78e6ccfc87
/usr/lib/.build-id/b4/b8a30ebf86cb849bcb0cabc4d452c1a44487cc
/usr/lib/.build-id/ce/5e0647f756ec2c30b2e6df9a5a98e552871cb6
/usr/lib/.build-id/e0/a6a6207f56674ffacd7b063fd2acd4cec3f661
/usr/lib/.build-id/f4/86fb5b3072945405d0590045715d18adc7aa18
[acme@quaco ~]$
[acme@quaco ~]$ rpm -ql libtraceevent | grep build-id/../ | xargs realpath
/usr/lib64/traceevent/plugins/plugin_function.so
/usr/lib64/traceevent/plugins/plugin_scsi.so
/usr/lib64/traceevent/plugins/plugin_futex.so
/usr/lib64/traceevent/plugins/plugin_cfg80211.so
/usr/lib64/traceevent/plugins/plugin_hrtimer.so
/usr/lib64/traceevent/plugins/plugin_mac80211.so
/usr/lib64/traceevent/plugins/plugin_sched_switch.so
/usr/lib64/traceevent/plugins/plugin_jbd2.so
/usr/lib64/traceevent/plugins/plugin_tlb.so
/usr/lib64/traceevent/plugins/plugin_xen.so
/usr/lib64/traceevent/plugins/plugin_kvm.so
/usr/lib64/traceevent/plugins/plugin_kmem.so
/usr/lib64/libtraceevent.so.1.5.3
[acme@quaco ~]$ rpm -ql libtraceevent | grep build-id/../ | xargs realpath  | xargs rpm -qf
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
libtraceevent-1.5.3-2.fc36.x86_64
[acme@quaco ~]$

I.e. libtraceevent has the plugins and the build-id symlinks, perf has
just the symlinks:

[acme@quaco ~]$ rpm -ql libtraceevent | grep plugin_.*so
/usr/lib64/traceevent/plugins/plugin_cfg80211.so
/usr/lib64/traceevent/plugins/plugin_function.so
/usr/lib64/traceevent/plugins/plugin_futex.so
/usr/lib64/traceevent/plugins/plugin_hrtimer.so
/usr/lib64/traceevent/plugins/plugin_jbd2.so
/usr/lib64/traceevent/plugins/plugin_kmem.so
/usr/lib64/traceevent/plugins/plugin_kvm.so
/usr/lib64/traceevent/plugins/plugin_mac80211.so
/usr/lib64/traceevent/plugins/plugin_sched_switch.so
/usr/lib64/traceevent/plugins/plugin_scsi.so
/usr/lib64/traceevent/plugins/plugin_tlb.so
/usr/lib64/traceevent/plugins/plugin_xen.so
[acme@quaco ~]$ rpm -ql perf | grep plugin_.*so
[acme@quaco ~]$ 

And perf is being built with the libtraceevent that is in fedora:

[acme@quaco ~]$ ldd `which perf` | grep traceevent
	libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f43496dc000)
[acme@quaco ~]$ rpm -qf /lib64/libtraceevent.so.1
libtraceevent-1.5.3-2.fc36.x86_64
[acme@quaco ~]$ rpm -qf /usr/bin/perf
perf-5.19.4-200.fc36.x86_64
[acme@quaco ~]$
[acme@quaco ~]$ file /usr/bin/perf
/usr/bin/perf: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=c08b255f02ce8f3e90df2b6156d2d38b1221995d, for GNU/Linux 3.2.0, stripped
[acme@quaco ~]$

So it seems its just a matter of removing those /usr/lib/.build-id/
symlinks to the libtraceevent plugins from the fedora perf rpm.

Justin?

- Arnaldo

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

* Re: [PATCH 3/8] perf test: Use a test program in perf record tests
  2022-10-24 16:00         ` Arnaldo Carvalho de Melo
  2022-10-25  4:12           ` Namhyung Kim
@ 2022-10-25 13:17           ` Adrian Hunter
  1 sibling, 0 replies; 32+ messages in thread
From: Adrian Hunter @ 2022-10-25 13:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ian Rogers, Namhyung Kim, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	LKML, linux-perf-users

On 24/10/22 19:00, Arnaldo Carvalho de Melo wrote:
> Em Mon, Oct 24, 2022 at 05:00:14PM +0300, Adrian Hunter escreveu:
>> On 24/10/22 14:33, Arnaldo Carvalho de Melo wrote:
>>> Em Thu, Oct 20, 2022 at 04:52:14PM -0700, Ian Rogers escreveu:
>>>> I wonder if these utilities should just be built into perf to avoid
>>>> the cc dependency. Perhaps we can have a hidden option built into
>>>> perf test.
> 
>>> Agreed, not depending on a compiler makes 'perf test' usable in more
>>> systems, particularly production ones where we may want to check if perf
>>> is passing all tests applicable to that system.
>  
>> I haven't seen anyone package anything except the perf executable, so
>> I presume the only people running these tests install the source, and
>> so need a compiler anyway.
> 
> Humm?
> 
> [root@quaco ~]# head -3 /etc/os-release
> NAME="Fedora Linux"
> VERSION="36 (Workstation Edition)"
> ID=fedora
> [root@quaco ~]#G

I guess I got confused - it seems it is only Ubuntu that does that.


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

* Re: [PATCH 5/8] perf test: Add system-wide mode in perf record tests
  2022-10-21  0:00   ` Ian Rogers
@ 2022-10-26 14:11     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-10-26 14:11 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Namhyung Kim, Jiri Olsa, Ingo Molnar, Peter Zijlstra, LKML,
	Adrian Hunter, linux-perf-users

Em Thu, Oct 20, 2022 at 05:00:39PM -0700, Ian Rogers escreveu:
> On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > Add system wide recording test with the same pattern.  It'd skip the
> > test when it failes to run perf record.  For system-wide mode, it needs
> 
> nit: s/failes/fails/
> 
> > to avoid build-id collection and synthesis because the test only cares
> > about the test program and kernel would generates necessary events as
> 
> nit: s/generates/generate the/

fixed
 
> > the process starts.
> >
> > Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> 
> Acked-by: Ian Rogers <irogers@google.com>
> 
> Thanks,
> Ian
> 
> > ---
> >  tools/perf/tests/shell/record.sh | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> >
> > diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> > index d1640d1daf2e..345764afb745 100755
> > --- a/tools/perf/tests/shell/record.sh
> > +++ b/tools/perf/tests/shell/record.sh
> > @@ -154,10 +154,31 @@ test_register_capture() {
> >    echo "Register capture test [Success]"
> >  }
> >
> > +test_system_wide() {
> > +  echo "Basic --system-wide mode test"
> > +  if ! perf record -aB --synth=no -o "${perfdata}" ${testprog} 2> /dev/null
> > +  then
> > +    echo "System-wide record [Skipped not supported]"
> > +    if [ $err -ne 1 ]
> > +    then
> > +      err=2
> > +    fi
> > +    return
> > +  fi
> > +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> > +  then
> > +    echo "System-wide record [Failed missing output]"
> > +    err=1
> > +    return
> > +  fi
> > +  echo "Basic --system-wide mode test [Success]"
> > +}
> > +
> >  build_test_program
> >
> >  test_per_thread
> >  test_register_capture
> > +test_system_wide
> >
> >  cleanup
> >  exit $err
> > --
> > 2.38.0.135.g90850a2211-goog
> >

-- 

- Arnaldo

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

* Re: [PATCHSET 0/8] perf test: Improve perf record tests (v2)
  2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
                   ` (7 preceding siblings ...)
  2022-10-20 17:26 ` [PATCH 8/8] perf test: Do not set TEST_SKIP for record subtests Namhyung Kim
@ 2022-10-26 14:15 ` Arnaldo Carvalho de Melo
  8 siblings, 0 replies; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-10-26 14:15 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers,
	Adrian Hunter, linux-perf-users

Em Thu, Oct 20, 2022 at 10:26:35AM -0700, Namhyung Kim escreveu:
> Hello,
> 
> This patchset improves the perf record tests to check more cases so that it
> can find problems early.  The motivation was a failure per-thread mmap with
> multi-threaded targets which Adrian is working on the fix.
> 
> Changes in v2)
>  * fix shellcheck issues
>  * drop unsupported --per-thread and --threads combination
>  * do not use initial delay (-D option); instead it runs the target
>    and wait for it separately using the recent waiting.sh library
>  * add Adrian's Reviewed-by tags
> 
> I added a custom test program and more combinations like system-wide and
> command line workload (in per-process mode) testing with multi-threaded
> recording mode.

Thanks, applied to perf/core.

- Arnaldo

 
> Currently it succeeds every tests when running as root!
> 
>   $ sudo ./perf test -v 91
>    91: perf record tests                                               :
>   --- start ---
>   test child forked, pid 108975
>   Build a test program
>   Basic --per-thread mode test
>   Basic --per-thread mode test [Success]
>   Register capture test
>   Register capture test [Success]
>   Basic --system-wide mode test
>   Basic --system-wide mode test [Success]
>   Basic target workload test
>   Basic target workload test [Success]
>   test child finished with 0
>   ---- end ----
>   perf record tests: Ok
> 
> You can find it in 'perf/record-test-v2' branch in
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
> 
> Thanks,
> Namhyung
> 
> 
> Namhyung Kim (8):
>   perf test: Do not use instructions:u explicitly
>   perf test: Fix shellcheck issues in the record test
>   perf test: Use a test program in perf record tests
>   perf test: Wait for a new thread when testing --per-thread record
>   perf test: Add system-wide mode in perf record tests
>   perf test: Add target workload test in perf record tests
>   perf test: Test record with --threads option
>   perf test: Do not set TEST_SKIP for record subtests
> 
>  tools/perf/tests/shell/record.sh | 180 +++++++++++++++++++++++++++----
>  1 file changed, 158 insertions(+), 22 deletions(-)
> 
> 
> base-commit: a3a365655a28f12f07eddf4f3fd596987b175e1d
> -- 
> 2.38.0.135.g90850a2211-goog

-- 

- Arnaldo

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

end of thread, other threads:[~2022-10-26 14:15 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 17:26 [PATCHSET 0/8] perf test: Improve perf record tests (v2) Namhyung Kim
2022-10-20 17:26 ` [PATCH 1/8] perf test: Do not use instructions:u explicitly Namhyung Kim
2022-10-20 23:47   ` Ian Rogers
2022-10-20 17:26 ` [PATCH 2/8] perf test: Fix shellcheck issues in the record test Namhyung Kim
2022-10-20 23:48   ` Ian Rogers
2022-10-21  8:45   ` Adrian Hunter
2022-10-20 17:26 ` [PATCH 3/8] perf test: Use a test program in perf record tests Namhyung Kim
2022-10-20 23:52   ` Ian Rogers
2022-10-24 11:33     ` Arnaldo Carvalho de Melo
2022-10-24 14:00       ` Adrian Hunter
2022-10-24 16:00         ` Arnaldo Carvalho de Melo
2022-10-25  4:12           ` Namhyung Kim
2022-10-25 13:10             ` Arnaldo Carvalho de Melo
2022-10-25 13:17           ` Adrian Hunter
2022-10-25  4:18       ` Namhyung Kim
2022-10-21  8:45   ` Adrian Hunter
2022-10-20 17:26 ` [PATCH 4/8] perf test: Wait for a new thread when testing --per-thread record Namhyung Kim
2022-10-20 23:57   ` Ian Rogers
2022-10-21  8:45   ` Adrian Hunter
2022-10-20 17:26 ` [PATCH 5/8] perf test: Add system-wide mode in perf record tests Namhyung Kim
2022-10-21  0:00   ` Ian Rogers
2022-10-26 14:11     ` Arnaldo Carvalho de Melo
2022-10-20 17:26 ` [PATCH 6/8] perf test: Add target workload test " Namhyung Kim
2022-10-21  0:01   ` Ian Rogers
2022-10-21  8:45   ` Adrian Hunter
2022-10-20 17:26 ` [PATCH 7/8] perf test: Test record with --threads option Namhyung Kim
2022-10-21  0:02   ` Ian Rogers
2022-10-21  8:45   ` Adrian Hunter
2022-10-20 17:26 ` [PATCH 8/8] perf test: Do not set TEST_SKIP for record subtests Namhyung Kim
2022-10-21  0:05   ` Ian Rogers
2022-10-24 11:34     ` Arnaldo Carvalho de Melo
2022-10-26 14:15 ` [PATCHSET 0/8] perf test: Improve perf record tests (v2) Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.