lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 30 Jun 2023 09:14:51 -0700
From:   Ian Rogers <irogers@...gle.com>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        linux-perf-users@...r.kernel.org, Song Liu <song@...nel.org>,
        Hao Luo <haoluo@...gle.com>
Subject: Re: [PATCH 4/4] perf test: Test perf lock contention CSV output

On Wed, Jun 28, 2023 at 1:01 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> To verify CSV output, just check the number of separators (",") using
> the tr and wc commands like this.
>
>   grep -v "^#" ${result} | tr -d -c | wc -c
>
> Now it expects 6 columns (and 5 separators) in the output, but it may
> be changed later so count the field in the header first and compare it
> to the actual output lines.
>
>   $ cat ${result}
>   # output: contended, total wait, max wait, avg wait, type, caller
>   1, 28787, 28787, 28787, spinlock, raw_spin_rq_lock_nested+0x1b
>
> The test looks like below now:
>
>   $ sudo ./perf test -v contention
>    86: kernel lock contention analysis test                            :
>   --- start ---
>   test child forked, pid 2705822
>   Testing perf lock record and perf lock contention
>   Testing perf lock contention --use-bpf
>   Testing perf lock record and perf lock contention at the same time
>   Testing perf lock contention --threads
>   Testing perf lock contention --lock-addr
>   Testing perf lock contention --type-filter (w/ spinlock)
>   Testing perf lock contention --lock-filter (w/ tasklist_lock)
>   Testing perf lock contention --callstack-filter (w/ unix_stream)
>   Testing perf lock contention --callstack-filter with task aggregation
>   Testing perf lock contention CSV output
>   test child finished with 0
>   ---- end ----
>   kernel lock contention analysis test: Ok
>
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>

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

Thanks,
Ian

> ---
>  tools/perf/tests/shell/lock_contention.sh | 36 +++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>
> diff --git a/tools/perf/tests/shell/lock_contention.sh b/tools/perf/tests/shell/lock_contention.sh
> index f2cc187b6186..4a194420416e 100755
> --- a/tools/perf/tests/shell/lock_contention.sh
> +++ b/tools/perf/tests/shell/lock_contention.sh
> @@ -233,6 +233,41 @@ test_aggr_task_stack_filter()
>         fi
>  }
>
> +test_csv_output()
> +{
> +       echo "Testing perf lock contention CSV output"
> +       perf lock contention -i ${perfdata} -E 1 -x , --output ${result}
> +       # count the number of commas in the header
> +       # it should have 5: contended, total-wait, max-wait, avg-wait, type, caller
> +       header=$(grep "# output:" ${result} | tr -d -c , | wc -c)
> +       if [ "${header}" != "5" ]; then
> +               echo "[Fail] Recorded result does not have enough output columns: ${header} != 5"
> +               err=1
> +               exit
> +       fi
> +       # count the number of commas in the output
> +       output=$(grep -v "^#" ${result} | tr -d -c , | wc -c)
> +       if [ "${header}" != "${output}" ]; then
> +               echo "[Fail] Recorded result does not match the number of commas: ${header} != ${output}"
> +               err=1
> +               exit
> +       fi
> +
> +       if ! perf lock con -b true > /dev/null 2>&1 ; then
> +               echo "[Skip] No BPF support"
> +               return
> +       fi
> +
> +       # the perf lock contention output goes to the stderr
> +       perf lock con -a -b -E 1 -x , --output ${result} -- perf bench sched messaging > /dev/null 2>&1
> +       output=$(grep -v "^#" ${result} | tr -d -c , | wc -c)
> +       if [ "${header}" != "${output}" ]; then
> +               echo "[Fail] BPF result does not match the number of commas: ${header} != ${output}"
> +               err=1
> +               exit
> +       fi
> +}
> +
>  check
>
>  test_record
> @@ -244,5 +279,6 @@ test_type_filter
>  test_lock_filter
>  test_stack_filter
>  test_aggr_task_stack_filter
> +test_csv_output
>
>  exit ${err}
> --
> 2.41.0.255.g8b1d071c50-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ