* [PATCH] perf/HWBP: Optimize __modify_bp_slot() handling
@ 2025-09-02 9:17 Jinchao Wang
0 siblings, 0 replies; only message in thread
From: Jinchao Wang @ 2025-09-02 9:17 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan, linux-perf-users
Cc: linux-kernel, Jinchao Wang
Skip unnecessary release/reserve when old and new types share the same
slot.
Reserve the new slot first, then release the old one to maintain
consistency and avoid transient failures.
Signed-off-by: Jinchao Wang <wangjinchao600@gmail.com>
---
kernel/events/hw_breakpoint.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index 8ec2cb688903..1cc9cb32ceb4 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -625,23 +625,20 @@ void release_bp_slot(struct perf_event *bp)
static int __modify_bp_slot(struct perf_event *bp, u64 old_type, u64 new_type)
{
int err;
+ enum bp_type_idx old_type_idx, new_type_idx;
- __release_bp_slot(bp, old_type);
+ old_type_idx = find_slot_idx(old_type);
+ new_type_idx = find_slot_idx(new_type);
+ if (old_type_idx == new_type_idx)
+ return 0;
err = __reserve_bp_slot(bp, new_type);
- if (err) {
- /*
- * Reserve the old_type slot back in case
- * there's no space for the new type.
- *
- * This must succeed, because we just released
- * the old_type slot in the __release_bp_slot
- * call above. If not, something is broken.
- */
- WARN_ON(__reserve_bp_slot(bp, old_type));
- }
+ if (err)
+ return err;
- return err;
+ __release_bp_slot(bp, old_type);
+
+ return 0;
}
static int modify_bp_slot(struct perf_event *bp, u64 old_type, u64 new_type)
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-02 9:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-02 9:17 [PATCH] perf/HWBP: Optimize __modify_bp_slot() handling Jinchao Wang
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).