linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Disha Goel <disgoel@linux.ibm.com>
To: Kajol Jain <kjain@linux.ibm.com>, acme@kernel.org
Cc: irogers@google.com, atrajeev@linux.vnet.ibm.com,
	linux-perf-users@vger.kernel.org, maddy@linux.ibm.com,
	namhyung@kernel.org, naveen.n.rao@linux.vnet.ibm.com,
	Disha Goel <disgoel@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] perf test: Skip perf bench breakpoint run if no breakpoints available
Date: Wed, 23 Aug 2023 14:15:55 +0530	[thread overview]
Message-ID: <d39f82e2-9b51-4487-7d5c-dcd992eb56cb@linux.ibm.com> (raw)
In-Reply-To: <20230823075103.190565-1-kjain@linux.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 3755 bytes --]

On 23/08/23 1:21 pm, Kajol Jain wrote:

> Based on commit 7d54a4acd8c1 ("perf test: Skip watchpoint
> tests if no watchpoints available"), hardware breakpoints
> are not available for power9 platform and because of that
> perf bench breakpoint run fails on power9 platform.
> Add code to check for the return value of perf_event_open()
> in breakpoint run and skip the perf bench breakpoint run,
> if hardware breakpoints are not available.
>
> Result on power9 system before patch changes:
> [command]# perf bench breakpoint thread
> perf_event_open: No such device
>
> Result on power9 system after patch changes:
> [command]# ./perf bench breakpoint thread
> Skipping perf bench breakpoint thread: No hardware support
>
> Reported-by: Disha Goel<disgoel@linux.vnet.ibm.com>
> Signed-off-by: Kajol Jain<kjain@linux.ibm.com>

With this patch applied perf bench breakpoint test works correctly on Power9 and Power10.

Result on Power9 system with patch changes:
[root@]# ./perf bench breakpoint all
# Running breakpoint/thread benchmark...
Skipping perf bench breakpoint thread: No hardware support

# Running breakpoint/enable benchmark...
Skipping perf bench breakpoint enable: No hardware support

Result on Power10 system with patch changes:
[root@]# ./perf bench breakpoint all
# Running breakpoint/thread benchmark...
# Created/joined 10 threads with 1 breakpoints and 1 parallelism
      Total time: 0.001 [sec]

      115.100000 usecs/op
      115.100000 usecs/op/cpu

# Running breakpoint/enable benchmark...
# Enabled/disabled breakpoint 10 time with 0 passive and 0 active threads
      Total time: 0.000 [sec]

        2.800000 usecs/op

Tested-by: Disha Goel<disgoel@linux.ibm.com>

> ---
>   tools/perf/bench/breakpoint.c | 24 +++++++++++++++++++++---
>   1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/bench/breakpoint.c b/tools/perf/bench/breakpoint.c
> index 41385f89ffc7..dfd18f5db97d 100644
> --- a/tools/perf/bench/breakpoint.c
> +++ b/tools/perf/bench/breakpoint.c
> @@ -47,6 +47,7 @@ struct breakpoint {
>   static int breakpoint_setup(void *addr)
>   {
>   	struct perf_event_attr attr = { .size = 0, };
> +	int fd;
>   
>   	attr.type = PERF_TYPE_BREAKPOINT;
>   	attr.size = sizeof(attr);
> @@ -56,7 +57,12 @@ static int breakpoint_setup(void *addr)
>   	attr.bp_addr = (unsigned long)addr;
>   	attr.bp_type = HW_BREAKPOINT_RW;
>   	attr.bp_len = HW_BREAKPOINT_LEN_1;
> -	return syscall(SYS_perf_event_open, &attr, 0, -1, -1, 0);
> +	fd = syscall(SYS_perf_event_open, &attr, 0, -1, -1, 0);
> +
> +	if (fd < 0)
> +		fd = -errno;
> +
> +	return fd;
>   }
>   
>   static void *passive_thread(void *arg)
> @@ -122,8 +128,14 @@ int bench_breakpoint_thread(int argc, const char **argv)
>   
>   	for (i = 0; i < thread_params.nbreakpoints; i++) {
>   		breakpoints[i].fd = breakpoint_setup(&breakpoints[i].watched);
> -		if (breakpoints[i].fd == -1)
> +
> +		if (breakpoints[i].fd < 0) {
> +			if (breakpoints[i].fd == -ENODEV) {
> +				printf("Skipping perf bench breakpoint thread: No hardware support\n");
> +				return 0;
> +			}
>   			exit((perror("perf_event_open"), EXIT_FAILURE));
> +		}
>   	}
>   	gettimeofday(&start, NULL);
>   	for (i = 0; i < thread_params.nparallel; i++) {
> @@ -196,8 +208,14 @@ int bench_breakpoint_enable(int argc, const char **argv)
>   		exit(EXIT_FAILURE);
>   	}
>   	fd = breakpoint_setup(&watched);
> -	if (fd == -1)
> +
> +	if (fd < 0) {
> +		if (fd == -ENODEV) {
> +			printf("Skipping perf bench breakpoint enable: No hardware support\n");
> +			return 0;
> +		}
>   		exit((perror("perf_event_open"), EXIT_FAILURE));
> +	}
>   	nthreads = enable_params.npassive + enable_params.nactive;
>   	threads = calloc(nthreads, sizeof(threads[0]));
>   	if (!threads)

[-- Attachment #2: Type: text/html, Size: 4310 bytes --]

  reply	other threads:[~2023-08-23 12:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23  7:51 [PATCH] perf test: Skip perf bench breakpoint run if no breakpoints available Kajol Jain
2023-08-23  8:45 ` Disha Goel [this message]
2023-08-23 10:58 ` Naveen N Rao
2023-08-29 19:03   ` Ian Rogers
2023-08-23 11:40 ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d39f82e2-9b51-4487-7d5c-dcd992eb56cb@linux.ibm.com \
    --to=disgoel@linux.ibm.com \
    --cc=acme@kernel.org \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=disgoel@linux.vnet.ibm.com \
    --cc=irogers@google.com \
    --cc=kjain@linux.ibm.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=namhyung@kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).