[PATCH v3 42/57] perf: Simplify perf_iterate_sb()

From: Peter Zijlstra
Date: Mon Jun 12 2023 - 06:00:34 EST



Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/events/core.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7871,8 +7871,8 @@ perf_iterate_sb(perf_iterate_f output, v
{
struct perf_event_context *ctx;

- rcu_read_lock();
- preempt_disable();
+ guard(rcu)();
+ guard(preempt)();

/*
* If we have task_ctx != NULL we only notify the task context itself.
@@ -7881,7 +7881,7 @@ perf_iterate_sb(perf_iterate_f output, v
*/
if (task_ctx) {
perf_iterate_ctx(task_ctx, output, data, false);
- goto done;
+ return;
}

perf_iterate_sb_cpu(output, data);
@@ -7889,9 +7889,6 @@ perf_iterate_sb(perf_iterate_f output, v
ctx = rcu_dereference(current->perf_event_ctxp);
if (ctx)
perf_iterate_ctx(ctx, output, data, false);
-done:
- preempt_enable();
- rcu_read_unlock();
}

/*