Commit [bd6d29]  Maximize  Restore  History

lockstat: Make lockstat counting per cpu

Locking statistics are implemented using global atomic
variables. This is usually fine unless some path write them very

This is the case for the function and function graph tracers
that disable irqs for each entry saved (except if the function
tracer is in preempt disabled only mode).
And calls to local_irq_save/restore() increment
hardirqs_on_events and hardirqs_off_events stats (or similar
stats for redundant versions).

Incrementing these global vars for each function ends up in too
much cache bouncing if lockstats are enabled.

To solve this, implement the debug_atomic_*() operations using
per cpu vars.

-v2: Use per_cpu() instead of get_cpu_var() to fetch the desired
cpu vars on debug_atomic_read()

-v3: Store the stats in a structure. No need for local_t as we
are NMI/irq safe.

-v4: Fix tons of build errors. I thought I had tested it but I
probably forgot to select the relevant config.

Suggested-by: Steven Rostedt <>
Signed-off-by: Frederic Weisbecker <>
Cc: Peter Zijlstra <>
Cc: Steven Rostedt <>
LKML-Reference: <>
Signed-off-by: Ingo Molnar <>
Cc: Peter Zijlstra <>
Cc: Steven Rostedt <>

Frederic Weisbecker Frederic Weisbecker 2010-04-05

Ingo Molnar Ingo Molnar 2010-04-05

changed kernel/lockdep.c
changed kernel/lockdep_internals.h
changed kernel/lockdep_proc.c
kernel/lockdep.c Diff Switch to side-by-side view
kernel/lockdep_internals.h Diff Switch to side-by-side view
kernel/lockdep_proc.c Diff Switch to side-by-side view

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks