perf/HWBP: Optimize __modify_bp_slot() handling
PATCH 1/1 perf/HWBP: Optimize __modify_bp_slot() handling
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 <[email protected]>
--- kernel/events/hw_breakpoint.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
kernel/events/hw_breakpoint.c +10 -13
@@ -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)
Signature · 1 line
2.43.0