Skip to content

Commit

Permalink
lockdep: Use this_cpu_ptr instead of get_cpu_var stats
Browse files Browse the repository at this point in the history
get_cpu_var disables preemption which has the potential to call into the
preemption disable trace points causing some complications. There's also
no need to disable preemption in uses of get_lock_stats anyway since
preempt is already disabled. So lets simplify the code.

Link: http://lkml.kernel.org/r/20180730222423.196630-2-joel@joelfernandes.org

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
  • Loading branch information
Joel Fernandes (Google) authored and Steven Rostedt (VMware) committed Jul 30, 2018
1 parent 6fc7c41 commit 01f3849
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions kernel/locking/lockdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,7 @@ void clear_lock_stats(struct lock_class *class)

static struct lock_class_stats *get_lock_stats(struct lock_class *class)
{
return &get_cpu_var(cpu_lock_stats)[class - lock_classes];
}

static void put_lock_stats(struct lock_class_stats *stats)
{
put_cpu_var(cpu_lock_stats);
return &this_cpu_ptr(cpu_lock_stats)[class - lock_classes];
}

static void lock_release_holdtime(struct held_lock *hlock)
Expand All @@ -271,7 +266,6 @@ static void lock_release_holdtime(struct held_lock *hlock)
lock_time_inc(&stats->read_holdtime, holdtime);
else
lock_time_inc(&stats->write_holdtime, holdtime);
put_lock_stats(stats);
}
#else
static inline void lock_release_holdtime(struct held_lock *hlock)
Expand Down Expand Up @@ -4090,7 +4084,6 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip)
stats->contending_point[contending_point]++;
if (lock->cpu != smp_processor_id())
stats->bounces[bounce_contended + !!hlock->read]++;
put_lock_stats(stats);
}

static void
Expand Down Expand Up @@ -4138,7 +4131,6 @@ __lock_acquired(struct lockdep_map *lock, unsigned long ip)
}
if (lock->cpu != cpu)
stats->bounces[bounce_acquired + !!hlock->read]++;
put_lock_stats(stats);

lock->cpu = cpu;
lock->ip = ip;
Expand Down

0 comments on commit 01f3849

Please sign in to comment.