History log of /linux-master/tools/perf/tests/shell/daemon.sh
Revision Date Author Comments
# 9a8dd2f2 23-Jan-2024 Ian Rogers <irogers@google.com>

perf test shell daemon: Make signal test less racy

The daemon signal test sends signals and then expects files to be
written. It was observed on an Intel Alderlake that the signals were
sent too quickly leading to the 3 expected files not appearing.

To avoid this send the next signal only after the expected previous file
has appeared. To avoid an infinite loop the number of retries is
limited.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Ross Zwisler <zwisler@chromium.org>
Cc: Shirisha G <shirisha@linux.ibm.com>
Link: https://lore.kernel.org/r/20240124043015.1388867-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 5bd35dfb 13-Jun-2023 Shirisha G <shirisha@linux.ibm.com>

perf tests daemon: Address shellcheck warnings

Running shellcheck -S on daemon.sh throws below warnings:

Result from shellcheck:
# shellcheck -S warning daemon.sh
local line_name=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $2 }'`
^-------^ SC2155: Declare and assign separately to avoid masking return values.

trap "echo 'FAILED: Signal caught'; daemon_exit ${config}; exit 1" SIGINT SIGTERM
^-------^ SC2064: Use single quotes, otherwise this expands now rather than when signalled.

count=`ls ${base}/session-test/ | grep perf.data | wc -l`
^-- SC2010: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.

if [ ${size} != "OK" -o ${type} != "OK" ]; then
^-- SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.

Fixed above warnings by:
- declaring and assigning local variables separately
- To fix SC2010, instead of using "ls | grep", used glob to allow non-alphanumeric filenames
- Used single quotes to prevent expanding.

Result from shellcheck after patch changes:
$ shellcheck -S warning daemon.sh
$ echo $?
0

Signed-off-by: Shirisha G <shirisha@linux.ibm.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230613164145.50488-5-atrajeev@linux.vnet.ibm.com
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# a6cb06ff 16-Mar-2021 Ian Rogers <irogers@google.com>

perf test: Add 30s timeout for wait for daemon start.

Retry the ping loop upto 600 times, or approximately 30 seconds, to make
sure the test does hang at start up.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20210317005505.2794804-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 078cbb6f 16-Mar-2021 Ian Rogers <irogers@google.com>

perf test: Cleanup daemon if test is interrupted.

Reorder daemon_start and daemon_exit as the trap handler is added in
daemon_start referencing daemon_exit.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20210317005505.2794804-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 87cb88d3 16-Mar-2021 Ian Rogers <irogers@google.com>

perf test: Remove unused argument

Remove unused argument from daemon_exit.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20210317005505.2794804-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 1dc481c0 20-Mar-2021 Leo Yan <leo.yan@linaro.org>

perf test: Change to use bash for daemon test

When executing the daemon test on Arm64 and x86 with Debian (Buster)
distro, both skip the test case with the log:

# ./perf test -v 76
76: daemon operations :
--- start ---
test child forked, pid 11687
test daemon list
trap: SIGINT: bad trap
./tests/shell/daemon.sh: 173: local: cpu-clock: bad variable name
test child finished with -2
---- end ----
daemon operations: Skip

So the error happens for the variable expansion when use local variable
in the shell script. Since Debian Buster uses dash but not bash as
non-interactive shell, when execute the daemon testing, it hits a known
issue for dash which was reported [1].

To resolve this issue, one option is to add double quotes for all local
variables assignment, so need to change the code from:

local line=`perf daemon --config ${config} -x: | head -2 | tail -1`

... to:

local line="`perf daemon --config ${config} -x: | head -2 | tail -1`"

But the testing script has bunch of local variables, this leads to big
changes for whole script.

On the other hand, the testing script asks to use the "local" feature
which is bash-specific, so this patch explicitly uses "#!/bin/bash" to
ensure running the script with bash.

After:

# ./perf test -v 76
76: daemon operations :
--- start ---
test child forked, pid 11329
test daemon list
test daemon reconfig
test daemon stop
test daemon signal
signal 12 sent to session 'test [11596]'
signal 12 sent to session 'test [11596]'
test daemon ping
test daemon lock
test child finished with 0
---- end ----
daemon operations: Ok

[1] https://bugs.launchpad.net/ubuntu/+source/dash/+bug/139097

Fixes: 2291bb915b55 ("perf tests: Add daemon 'list' command test")
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210320104554.529213-1-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 36bc511f 01-Mar-2021 Jiri Olsa <jolsa@kernel.org>

perf daemon: Fix running test for non root user

John reported that the daemon test is not working for non root user.
Changing the tests configurations so it's allowed to run under normal
user.

Fixes: 2291bb915b55 ("perf tests: Add daemon 'list' command test")
Reported-by: John Garry <john.garry@huawei.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: John Garry <john.garry@huawei.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210301122510.64402-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# dec34515 08-Feb-2021 Jiri Olsa <jolsa@kernel.org>

perf tests: Add daemon 'lock' test

Add a test for the perf daemon 'lock' command ensuring only one instance
of daemon can run over one base directory.

Committer testing:

[root@five ~]# perf test -v daemon
76: daemon operations :
--- start ---
test child forked, pid 793255
test daemon list
test daemon reconfig
test daemon stop
test daemon signal
signal 12 sent to session 'test [793506]'
signal 12 sent to session 'test [793506]'
test daemon ping
test daemon lock
test child finished with 0
---- end ----
daemon operations: Ok
[root@five ~]#

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-25-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 63551dc7 08-Feb-2021 Jiri Olsa <jolsa@kernel.org>

perf tests: Add daemon 'ping' command test

Add a test for the perf daemon 'ping' command. The tests verifies the
ping command gets proper answer from sessions.

Committer testing:

[root@five ~]# perf test daemon
76: daemon operations : Ok
[root@five ~]# perf test -v daemon
76: daemon operations :
--- start ---
test child forked, pid 792143
test daemon list
test daemon reconfig
test daemon stop
test daemon signal
signal 12 sent to session 'test [792415]'
signal 12 sent to session 'test [792415]'
test daemon ping
test child finished with 0
---- end ----
daemon operations: Ok
[root@five ~]#

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-24-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# f32102aa 08-Feb-2021 Jiri Olsa <jolsa@kernel.org>

perf tests: Add daemon 'signal' command test

Add a test for the perf daemon 'signal' command. The test sends a signal
to configured sessions and verifies the perf data files were generated
accordingly.

Committer testing:

[root@five ~]# perf test daemon
76: daemon operations : Ok
[root@five ~]# perf test -v daemon
76: daemon operations :
--- start ---
test child forked, pid 790017
test daemon list
test daemon reconfig
test daemon stop
test daemon signal
signal 12 sent to session 'test [790268]'
signal 12 sent to session 'test [790268]'
test child finished with 0
---- end ----
daemon operations: Ok
[root@five ~]#

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-23-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# f624f6d0 08-Feb-2021 Jiri Olsa <jolsa@kernel.org>

perf tests: Add daemon 'stop' command test

Add a test for the perf daemon 'stop' command. The test stops the daemon
and verifies all the configured sessions are properly terminated.

Committer testing:

[root@five ~]# time perf test daemon
76: daemon operations : Ok
[root@five ~]# time perf test -v daemon
76: daemon operations :
--- start ---
test child forked, pid 788560
test daemon list
test daemon reconfig
test daemon stop
test child finished with 0
---- end ----
daemon operations: Ok
#

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-22-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 91a17d6f 08-Feb-2021 Jiri Olsa <jolsa@kernel.org>

perf tests: Add daemon reconfig test

Add a test for daemon reconfiguration. The test changes the
configuration file and checks that the session is changed properly.

Committer testing:

[root@five ~]# perf test daemon
76: daemon operations : Ok
[root@five ~]# time perf test daemon
76: daemon operations : Ok

real 0m6.055s
user 0m0.174s
sys 0m0.147s
[root@five ~]# time perf test -v daemon
76: daemon operations :
--- start ---
test child forked, pid 786863
test daemon list
test daemon reconfig
test child finished with 0
---- end ----
daemon operations: Ok

real 0m6.127s
user 0m0.222s
sys 0m0.165s
[root@five ~]#

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-21-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 2291bb91 08-Feb-2021 Jiri Olsa <jolsa@kernel.org>

perf tests: Add daemon 'list' command test

Add test for basic perf daemon listing via the CSV output mode (-x
option).

Check that the configured sessions display expected values.

Committer testing:

[root@five ~]# perf test daemon
76: daemon operations : Ok
[root@five ~]#
[root@five ~]# perf test -v daemon
76: daemon operations :
--- start ---
test child forked, pid 785037
test daemon list
test child finished with 0
---- end ----
daemon operations: Ok
[root@five ~]#

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-20-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>