Skip to content

Commit 01f3849

Browse files
joelagnelrostedt
authored andcommitted
lockdep: Use this_cpu_ptr instead of get_cpu_var stats
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>
1 parent 6fc7c41 commit 01f3849

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

kernel/locking/lockdep.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,7 @@ void clear_lock_stats(struct lock_class *class)
248248

249249
static struct lock_class_stats *get_lock_stats(struct lock_class *class)
250250
{
251-
return &get_cpu_var(cpu_lock_stats)[class - lock_classes];
252-
}
253-
254-
static void put_lock_stats(struct lock_class_stats *stats)
255-
{
256-
put_cpu_var(cpu_lock_stats);
251+
return &this_cpu_ptr(cpu_lock_stats)[class - lock_classes];
257252
}
258253

259254
static void lock_release_holdtime(struct held_lock *hlock)
@@ -271,7 +266,6 @@ static void lock_release_holdtime(struct held_lock *hlock)
271266
lock_time_inc(&stats->read_holdtime, holdtime);
272267
else
273268
lock_time_inc(&stats->write_holdtime, holdtime);
274-
put_lock_stats(stats);
275269
}
276270
#else
277271
static inline void lock_release_holdtime(struct held_lock *hlock)
@@ -4090,7 +4084,6 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip)
40904084
stats->contending_point[contending_point]++;
40914085
if (lock->cpu != smp_processor_id())
40924086
stats->bounces[bounce_contended + !!hlock->read]++;
4093-
put_lock_stats(stats);
40944087
}
40954088

40964089
static void
@@ -4138,7 +4131,6 @@ __lock_acquired(struct lockdep_map *lock, unsigned long ip)
41384131
}
41394132
if (lock->cpu != cpu)
41404133
stats->bounces[bounce_acquired + !!hlock->read]++;
4141-
put_lock_stats(stats);
41424134

41434135
lock->cpu = cpu;
41444136
lock->ip = ip;

0 commit comments

Comments
 (0)