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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fWjXS43xBujQ2DOAeo41WX5L4hfTfJVEV8h6i1Uu2HBEA@mail.gmail.com>
Date:   Tue, 7 Nov 2023 10:05:05 -0800
From:   Ian Rogers <irogers@...gle.com>
To:     kan.liang@...ux.intel.com
Cc:     acme@...nel.org, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org, peterz@...radead.org,
        mingo@...hat.com, jolsa@...nel.org, namhyung@...nel.org,
        adrian.hunter@...el.com, tinghao.zhang@...el.com
Subject: Re: [PATCH] perf test: Basic branch counter support

On Tue, Nov 7, 2023 at 9:44 AM <kan.liang@...ux.intel.com> wrote:
>
> From: Kan Liang <kan.liang@...ux.intel.com>
>
> Add a basic test for the branch counter feature.
>
> The test verifies that
> - The new filter can be successfully applied on the supported platforms.
> - The counter value can be outputted via the perf report -D
>
> Signed-off-by: Kan Liang <kan.liang@...ux.intel.com>

Thanks Kan!

> ---
>  tools/perf/tests/shell/record.sh | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 4fbc74805d52..2783e867c07c 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -11,6 +11,9 @@ err=0
>  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
>  testprog="perf test -w thloop"
>  testsym="test_loop"
> +cpu_pmu_dir="/sys/bus/event_source/devices/cpu*"
> +br_cntr_file="/caps/branch_counter_nr"
> +br_cntr_output="branch stack counters"
>
>  cleanup() {
>    rm -rf "${perfdata}"
> @@ -154,10 +157,37 @@ test_workload() {
>    echo "Basic target workload test [Success]"
>  }
>
> +test_branch_counter() {
> +  echo "Basic branch counter test"
> +  # Check if the branch counter feature is supported

If $cpu_pmu_dir is empty, e.g. ARM and S390, this should also skip.

> +  for dir in $cpu_pmu_dir
> +  do
> +    if [ ! -e "$dir$br_cntr_file" ]
> +    then
> +      echo "Not support branch counter feature [Skipped]"

Perhaps here it'd be clearer to output:
echo "branch counter feature not supported on all core PMUs ($dir) [Skipped]"

Thanks,
Ian

> +      return
> +    fi
> +  done
> +  if ! perf record -o "${perfdata}" -j any,counter ${testprog} 2> /dev/null
> +  then
> +    echo "Basic branch counter test [Failed record]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -D -q | grep -q "$br_cntr_output"
> +  then
> +    echo "Basic branch record test [Failed missing output]"
> +    err=1
> +    return
> +  fi
> +  echo "Basic branch counter test [Success]"
> +}
> +
>  test_per_thread
>  test_register_capture
>  test_system_wide
>  test_workload
> +test_branch_counter
>
>  cleanup
>  exit $err
> --
> 2.35.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ