[PATCH 08/14] perf: Use lockdep to assert IRQs are disabled/enabled

From: Frederic Weisbecker
Date: Mon Nov 06 2017 - 10:04:13 EST


Use lockdep to check that IRQs are enabled or disabled as expected. This
way the sanity check only shows overhead when concurrency correctness
debug code is enabled.

Signed-off-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
---
kernel/events/core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 8fd2f2d..6ea4c98 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -209,7 +209,7 @@ static int event_function(void *info)
struct perf_event_context *task_ctx = cpuctx->task_ctx;
int ret = 0;

- WARN_ON_ONCE(!irqs_disabled());
+ lockdep_assert_irqs_disabled();

perf_ctx_lock(cpuctx, task_ctx);
/*
@@ -306,7 +306,7 @@ static void event_function_local(struct perf_event *event, event_f func, void *d
struct task_struct *task = READ_ONCE(ctx->task);
struct perf_event_context *task_ctx = NULL;

- WARN_ON_ONCE(!irqs_disabled());
+ lockdep_assert_irqs_disabled();

if (task) {
if (task == TASK_TOMBSTONE)
@@ -1004,7 +1004,7 @@ static enum hrtimer_restart perf_mux_hrtimer_handler(struct hrtimer *hr)
struct perf_cpu_context *cpuctx;
int rotations = 0;

- WARN_ON(!irqs_disabled());
+ lockdep_assert_irqs_disabled();

cpuctx = container_of(hr, struct perf_cpu_context, hrtimer);
rotations = perf_rotate_context(cpuctx);
@@ -1091,7 +1091,7 @@ static void perf_event_ctx_activate(struct perf_event_context *ctx)
{
struct list_head *head = this_cpu_ptr(&active_ctx_list);

- WARN_ON(!irqs_disabled());
+ lockdep_assert_irqs_disabled();

WARN_ON(!list_empty(&ctx->active_ctx_list));

@@ -1100,7 +1100,7 @@ static void perf_event_ctx_activate(struct perf_event_context *ctx)

static void perf_event_ctx_deactivate(struct perf_event_context *ctx)
{
- WARN_ON(!irqs_disabled());
+ lockdep_assert_irqs_disabled();

WARN_ON(list_empty(&ctx->active_ctx_list));

@@ -3521,7 +3521,7 @@ void perf_event_task_tick(void)
struct perf_event_context *ctx, *tmp;
int throttled;

- WARN_ON(!irqs_disabled());
+ lockdep_assert_irqs_disabled();

__this_cpu_inc(perf_throttled_seq);
throttled = __this_cpu_xchg(perf_throttled_count, 0);
--
2.7.4