Re: [DTrace-devel] [PATCH] test: Use /usr/bin/perf for perf

Sam James <[email protected]>
Newsgroups dev.linux.lists.dtrace
Organization Gentoo
Message-ID <[email protected]>
"eugene.loh--- via DTrace-devel" <[email protected]> writes:

> From: Eugene Loh <[email protected]>
>
> The testsuite package has a dependency on the perf package.  But that
> package installs perf in /usr/bin.  Meanwhile, there is a /sbin/perf,
> which is likely to appear earlier in the search path for dtrace users.
> That perf is a wrapper for an executable that might not exist, causing
> some silent, unexpected behaviors with the test suite.

Just for my own curiosity: what exactly is /sbin/perf? I've never heard
of this "collision" before, so want to know if I should be aware of it
in other contexts.

>
> Change references to "perf" to be explicitly "/usr/bin/perf".
>
> Signed-off-by: Eugene Loh <[email protected]>
> ---
>  test/unittest/cpc/tst.branches.x     | 4 ++--
>  test/unittest/cpc/tst.instructions.x | 4 ++--
>  test/utils/cpc_get_events.sh         | 4 ++--
>  test/utils/perf_count_event.sh       | 4 ++--
>  4 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/test/unittest/cpc/tst.branches.x b/test/unittest/cpc/tst.branches.x
> index 4b235055d..a19d1bc6d 100755
> --- a/test/unittest/cpc/tst.branches.x
> +++ b/test/unittest/cpc/tst.branches.x
> @@ -1,11 +1,11 @@
>  #!/bin/bash
>  #
>  # Oracle Linux DTrace.
> -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
> +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
>  # Licensed under the Universal Permissive License v 1.0 as shown at
>  # http://oss.oracle.com/licenses/upl.
>  
> -if ! perf list hw | grep -qw branches; then
> +if ! /usr/bin/perf list hw | grep -qw branches; then
>  	echo 'no "branches" event on this system'
>  	exit 2
>  fi
> diff --git a/test/unittest/cpc/tst.instructions.x b/test/unittest/cpc/tst.instructions.x
> index c3a2ede34..3c1e47b75 100755
> --- a/test/unittest/cpc/tst.instructions.x
> +++ b/test/unittest/cpc/tst.instructions.x
> @@ -1,11 +1,11 @@
>  #!/bin/bash
>  #
>  # Oracle Linux DTrace.
> -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
> +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
>  # Licensed under the Universal Permissive License v 1.0 as shown at
>  # http://oss.oracle.com/licenses/upl.
>  
> -if ! perf list hw | grep -qw instructions; then
> +if ! /usr/bin/perf list hw | grep -qw instructions; then
>  	echo 'no "instructions" event on this system'
>  	exit 2
>  fi
> diff --git a/test/utils/cpc_get_events.sh b/test/utils/cpc_get_events.sh
> index 80d3584b2..cc833fbb9 100755
> --- a/test/utils/cpc_get_events.sh
> +++ b/test/utils/cpc_get_events.sh
> @@ -1,7 +1,7 @@
>  #!/bin/bash
>  #
>  # Oracle Linux DTrace.
> -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
> +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
>  # Licensed under the Universal Permissive License v 1.0 as shown at
>  # http://oss.oracle.com/licenses/upl.
>  
> @@ -13,7 +13,7 @@ eventnamelist="cpu-clock"
>  $(dirname $0)/cpc_temp_skip_bug.sh > /dev/null
>  if [ $? -eq 0 ]; then
>  	for eventname in branches instructions; do
> -		if perf list hw | grep -qw $eventname; then
> +		if /usr/bin/perf list hw | grep -qw $eventname; then
>  			eventnamelist="$eventnamelist $eventname"
>  		fi
>  	done
> diff --git a/test/utils/perf_count_event.sh b/test/utils/perf_count_event.sh
> index 957363e55..bc1441f32 100755
> --- a/test/utils/perf_count_event.sh
> +++ b/test/utils/perf_count_event.sh
> @@ -1,7 +1,7 @@
>  #!/bin/bash
>  #
>  # Oracle Linux DTrace.
> -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
> +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
>  # Licensed under the Universal Permissive License v 1.0 as shown at
>  # http://oss.oracle.com/licenses/upl.
>  
> @@ -20,7 +20,7 @@ shift
>  #   If the output is no good, report -1.
>  #   If the output is time in msec, convert to nsec.
>  #   Otherwise, just report the count.
> -perf stat -e $event --no-big-num -x\  $utils/$* |& gawk '
> +/usr/bin/perf stat -e $event --no-big-num -x\  $utils/$* |& gawk '
>  /^[^0-9]/ { print -1; exit 1 }
>  / msec / { print int(1000000. * $1); exit 0 }
>  { print $1; exit 0 }'
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.