* [PATCH] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
@ 2025-03-03 9:24 Saket Kumar Bhaskar
2025-03-03 10:32 ` [tip: perf/core] " tip-bot2 for Saket Kumar Bhaskar
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Saket Kumar Bhaskar @ 2025-03-03 9:24 UTC (permalink / raw)
To: linux-perf-users, linux-kernel
Cc: peterz, mingo, namhyung, mark.rutland, alexander.shishkin, jolsa,
irogers, adrian.hunter, kan.liang, hbathini, atrajeev
Currently, __reserve_bp_slot() returns -ENOSPC for unsupported
breakpoint types on the architecture. For example, powerpc
does not support hardware instruction breakpoints. This causes
the perf_skip BPF selftest to fail, as neither ENOENT nor
EOPNOTSUPP is returned by perf_event_open for unsupported
breakpoint types. As a result, the test that should be skipped
for this arch is not correctly identified.
To resolve this, hw_breakpoint_event_init() should exit early by
checking for unsupported breakpoint types using
hw_breakpoint_slots_cached() and return the appropriate error
(-EOPNOTSUPP).
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
---
kernel/events/hw_breakpoint.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index bc4a61029b6d..8ec2cb688903 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -950,9 +950,10 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
return -ENOENT;
/*
- * no branch sampling for breakpoint events
+ * Check if breakpoint type is supported before proceeding.
+ * Also, no branch sampling for breakpoint events.
*/
- if (has_branch_stack(bp))
+ if (!hw_breakpoint_slots_cached(find_slot_idx(bp->attr.bp_type)) || has_branch_stack(bp))
return -EOPNOTSUPP;
err = register_perf_hw_breakpoint(bp);
--
2.43.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: perf/core] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
2025-03-03 9:24 [PATCH] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type Saket Kumar Bhaskar
@ 2025-03-03 10:32 ` tip-bot2 for Saket Kumar Bhaskar
2025-03-03 12:29 ` tip-bot2 for Saket Kumar Bhaskar
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Saket Kumar Bhaskar @ 2025-03-03 10:32 UTC (permalink / raw)
To: linux-tip-commits
Cc: Saket Kumar Bhaskar, Ingo Molnar, Marco Elver, Dmitry Vyukov,
Ian Rogers, Frederic Weisbecker, x86, linux-kernel
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 21d96cea578f83e43ec9016e5bba8703b290c748
Gitweb: https://git.kernel.org/tip/21d96cea578f83e43ec9016e5bba8703b290c748
Author: Saket Kumar Bhaskar <skb99@linux.ibm.com>
AuthorDate: Mon, 03 Mar 2025 14:54:51 +05:30
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 03 Mar 2025 11:23:15 +01:00
perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
Currently, __reserve_bp_slot() returns -ENOSPC for unsupported
breakpoint types on the architecture. For example, powerpc
does not support hardware instruction breakpoints. This causes
the perf_skip BPF selftest to fail, as neither ENOENT nor
EOPNOTSUPP is returned by perf_event_open for unsupported
breakpoint types. As a result, the test that should be skipped
for this arch is not correctly identified.
To resolve this, hw_breakpoint_event_init() should exit early by
checking for unsupported breakpoint types using
hw_breakpoint_slots_cached() and return the appropriate error
(-EOPNOTSUPP).
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: https://lore.kernel.org/r/20250303092451.1862862-1-skb99@linux.ibm.com
---
kernel/events/hw_breakpoint.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index bc4a610..8ec2cb6 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -950,9 +950,10 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
return -ENOENT;
/*
- * no branch sampling for breakpoint events
+ * Check if breakpoint type is supported before proceeding.
+ * Also, no branch sampling for breakpoint events.
*/
- if (has_branch_stack(bp))
+ if (!hw_breakpoint_slots_cached(find_slot_idx(bp->attr.bp_type)) || has_branch_stack(bp))
return -EOPNOTSUPP;
err = register_perf_hw_breakpoint(bp);
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: perf/core] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
2025-03-03 9:24 [PATCH] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type Saket Kumar Bhaskar
2025-03-03 10:32 ` [tip: perf/core] " tip-bot2 for Saket Kumar Bhaskar
@ 2025-03-03 12:29 ` tip-bot2 for Saket Kumar Bhaskar
2025-03-03 16:56 ` [PATCH] " Ian Rogers
2025-03-04 8:57 ` [tip: perf/core] " tip-bot2 for Saket Kumar Bhaskar
3 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Saket Kumar Bhaskar @ 2025-03-03 12:29 UTC (permalink / raw)
To: linux-tip-commits
Cc: Saket Kumar Bhaskar, Ingo Molnar, Marco Elver, Dmitry Vyukov,
Ian Rogers, Frederic Weisbecker, x86, linux-kernel
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 4118628d0ce005e5651174b9d5fc0209a8d49ee0
Gitweb: https://git.kernel.org/tip/4118628d0ce005e5651174b9d5fc0209a8d49ee0
Author: Saket Kumar Bhaskar <skb99@linux.ibm.com>
AuthorDate: Mon, 03 Mar 2025 14:54:51 +05:30
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 03 Mar 2025 13:24:12 +01:00
perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
Currently, __reserve_bp_slot() returns -ENOSPC for unsupported
breakpoint types on the architecture. For example, powerpc
does not support hardware instruction breakpoints. This causes
the perf_skip BPF selftest to fail, as neither ENOENT nor
EOPNOTSUPP is returned by perf_event_open for unsupported
breakpoint types. As a result, the test that should be skipped
for this arch is not correctly identified.
To resolve this, hw_breakpoint_event_init() should exit early by
checking for unsupported breakpoint types using
hw_breakpoint_slots_cached() and return the appropriate error
(-EOPNOTSUPP).
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: https://lore.kernel.org/r/20250303092451.1862862-1-skb99@linux.ibm.com
---
kernel/events/hw_breakpoint.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index bc4a610..8ec2cb6 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -950,9 +950,10 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
return -ENOENT;
/*
- * no branch sampling for breakpoint events
+ * Check if breakpoint type is supported before proceeding.
+ * Also, no branch sampling for breakpoint events.
*/
- if (has_branch_stack(bp))
+ if (!hw_breakpoint_slots_cached(find_slot_idx(bp->attr.bp_type)) || has_branch_stack(bp))
return -EOPNOTSUPP;
err = register_perf_hw_breakpoint(bp);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
2025-03-03 9:24 [PATCH] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type Saket Kumar Bhaskar
2025-03-03 10:32 ` [tip: perf/core] " tip-bot2 for Saket Kumar Bhaskar
2025-03-03 12:29 ` tip-bot2 for Saket Kumar Bhaskar
@ 2025-03-03 16:56 ` Ian Rogers
2025-03-04 8:57 ` [tip: perf/core] " tip-bot2 for Saket Kumar Bhaskar
3 siblings, 0 replies; 5+ messages in thread
From: Ian Rogers @ 2025-03-03 16:56 UTC (permalink / raw)
To: Saket Kumar Bhaskar
Cc: linux-perf-users, linux-kernel, peterz, mingo, namhyung,
mark.rutland, alexander.shishkin, jolsa, adrian.hunter,
kan.liang, hbathini, atrajeev
On Mon, Mar 3, 2025 at 1:25 AM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
>
> Currently, __reserve_bp_slot() returns -ENOSPC for unsupported
> breakpoint types on the architecture. For example, powerpc
> does not support hardware instruction breakpoints. This causes
> the perf_skip BPF selftest to fail, as neither ENOENT nor
> EOPNOTSUPP is returned by perf_event_open for unsupported
> breakpoint types. As a result, the test that should be skipped
> for this arch is not correctly identified.
>
> To resolve this, hw_breakpoint_event_init() should exit early by
> checking for unsupported breakpoint types using
> hw_breakpoint_slots_cached() and return the appropriate error
> (-EOPNOTSUPP).
Hi Saket,
This looks good to me! Did you happen to run "perf test" as there are
a couple of tests there covering breakpoint behavior and I wonder if
we may need to update them? Particularly there are some comments about
PowerPC just not working:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/tests/bp_account.c#n24
Thanks,
Ian
> Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> ---
> kernel/events/hw_breakpoint.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
> index bc4a61029b6d..8ec2cb688903 100644
> --- a/kernel/events/hw_breakpoint.c
> +++ b/kernel/events/hw_breakpoint.c
> @@ -950,9 +950,10 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
> return -ENOENT;
>
> /*
> - * no branch sampling for breakpoint events
> + * Check if breakpoint type is supported before proceeding.
> + * Also, no branch sampling for breakpoint events.
> */
> - if (has_branch_stack(bp))
> + if (!hw_breakpoint_slots_cached(find_slot_idx(bp->attr.bp_type)) || has_branch_stack(bp))
> return -EOPNOTSUPP;
>
> err = register_perf_hw_breakpoint(bp);
> --
> 2.43.5
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: perf/core] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
2025-03-03 9:24 [PATCH] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type Saket Kumar Bhaskar
` (2 preceding siblings ...)
2025-03-03 16:56 ` [PATCH] " Ian Rogers
@ 2025-03-04 8:57 ` tip-bot2 for Saket Kumar Bhaskar
3 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Saket Kumar Bhaskar @ 2025-03-04 8:57 UTC (permalink / raw)
To: linux-tip-commits
Cc: Saket Kumar Bhaskar, Ingo Molnar, Marco Elver, Dmitry Vyukov,
Ian Rogers, Frederic Weisbecker, x86, linux-kernel
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 061c991697062f3bf87b72ed553d1d33a0e370dd
Gitweb: https://git.kernel.org/tip/061c991697062f3bf87b72ed553d1d33a0e370dd
Author: Saket Kumar Bhaskar <skb99@linux.ibm.com>
AuthorDate: Mon, 03 Mar 2025 14:54:51 +05:30
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 04 Mar 2025 09:42:13 +01:00
perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
Currently, __reserve_bp_slot() returns -ENOSPC for unsupported
breakpoint types on the architecture. For example, powerpc
does not support hardware instruction breakpoints. This causes
the perf_skip BPF selftest to fail, as neither ENOENT nor
EOPNOTSUPP is returned by perf_event_open for unsupported
breakpoint types. As a result, the test that should be skipped
for this arch is not correctly identified.
To resolve this, hw_breakpoint_event_init() should exit early by
checking for unsupported breakpoint types using
hw_breakpoint_slots_cached() and return the appropriate error
(-EOPNOTSUPP).
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: https://lore.kernel.org/r/20250303092451.1862862-1-skb99@linux.ibm.com
---
kernel/events/hw_breakpoint.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index bc4a610..8ec2cb6 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -950,9 +950,10 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
return -ENOENT;
/*
- * no branch sampling for breakpoint events
+ * Check if breakpoint type is supported before proceeding.
+ * Also, no branch sampling for breakpoint events.
*/
- if (has_branch_stack(bp))
+ if (!hw_breakpoint_slots_cached(find_slot_idx(bp->attr.bp_type)) || has_branch_stack(bp))
return -EOPNOTSUPP;
err = register_perf_hw_breakpoint(bp);
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-04 8:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-03 9:24 [PATCH] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type Saket Kumar Bhaskar
2025-03-03 10:32 ` [tip: perf/core] " tip-bot2 for Saket Kumar Bhaskar
2025-03-03 12:29 ` tip-bot2 for Saket Kumar Bhaskar
2025-03-03 16:56 ` [PATCH] " Ian Rogers
2025-03-04 8:57 ` [tip: perf/core] " tip-bot2 for Saket Kumar Bhaskar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®