提交 16444645 编写于 作者: F Frederic Weisbecker 提交者: Ingo Molnar

perf/core: Use lockdep to assert IRQs are disabled/enabled

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: NFrederic Weisbecker <frederic@kernel.org>
Acked-by: NThomas Gleixner <tglx@linutronix.de>
Cc: David S . Miller <davem@davemloft.net>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1509980490-4285-9-git-send-email-frederic@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 7a10e2a9
...@@ -209,7 +209,7 @@ static int event_function(void *info) ...@@ -209,7 +209,7 @@ static int event_function(void *info)
struct perf_event_context *task_ctx = cpuctx->task_ctx; struct perf_event_context *task_ctx = cpuctx->task_ctx;
int ret = 0; int ret = 0;
WARN_ON_ONCE(!irqs_disabled()); lockdep_assert_irqs_disabled();
perf_ctx_lock(cpuctx, task_ctx); perf_ctx_lock(cpuctx, task_ctx);
/* /*
...@@ -306,7 +306,7 @@ static void event_function_local(struct perf_event *event, event_f func, void *d ...@@ -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 task_struct *task = READ_ONCE(ctx->task);
struct perf_event_context *task_ctx = NULL; struct perf_event_context *task_ctx = NULL;
WARN_ON_ONCE(!irqs_disabled()); lockdep_assert_irqs_disabled();
if (task) { if (task) {
if (task == TASK_TOMBSTONE) if (task == TASK_TOMBSTONE)
...@@ -1006,7 +1006,7 @@ static enum hrtimer_restart perf_mux_hrtimer_handler(struct hrtimer *hr) ...@@ -1006,7 +1006,7 @@ static enum hrtimer_restart perf_mux_hrtimer_handler(struct hrtimer *hr)
struct perf_cpu_context *cpuctx; struct perf_cpu_context *cpuctx;
int rotations = 0; int rotations = 0;
WARN_ON(!irqs_disabled()); lockdep_assert_irqs_disabled();
cpuctx = container_of(hr, struct perf_cpu_context, hrtimer); cpuctx = container_of(hr, struct perf_cpu_context, hrtimer);
rotations = perf_rotate_context(cpuctx); rotations = perf_rotate_context(cpuctx);
...@@ -1093,7 +1093,7 @@ static void perf_event_ctx_activate(struct perf_event_context *ctx) ...@@ -1093,7 +1093,7 @@ static void perf_event_ctx_activate(struct perf_event_context *ctx)
{ {
struct list_head *head = this_cpu_ptr(&active_ctx_list); 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)); WARN_ON(!list_empty(&ctx->active_ctx_list));
...@@ -1102,7 +1102,7 @@ static void perf_event_ctx_activate(struct perf_event_context *ctx) ...@@ -1102,7 +1102,7 @@ static void perf_event_ctx_activate(struct perf_event_context *ctx)
static void perf_event_ctx_deactivate(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)); WARN_ON(list_empty(&ctx->active_ctx_list));
...@@ -3523,7 +3523,7 @@ void perf_event_task_tick(void) ...@@ -3523,7 +3523,7 @@ void perf_event_task_tick(void)
struct perf_event_context *ctx, *tmp; struct perf_event_context *ctx, *tmp;
int throttled; int throttled;
WARN_ON(!irqs_disabled()); lockdep_assert_irqs_disabled();
__this_cpu_inc(perf_throttled_seq); __this_cpu_inc(perf_throttled_seq);
throttled = __this_cpu_xchg(perf_throttled_count, 0); throttled = __this_cpu_xchg(perf_throttled_count, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册