aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/lockdep.c
diff options
context:
space:
mode:
authorYong Zhang <yong.zhang0@gmail.com>2011-11-09 03:07:14 -0500
committerIngo Molnar <mingo@elte.hu>2011-11-14 07:54:11 -0500
commit87cdee71166fa107c5dc8e43060eeefa533c6a3b (patch)
tree286a359e9e27e404f047ce2fa73458353a4b6e9e /kernel/lockdep.c
parent7f80850d3f9fd8fda23a317044aef3a6bafab06b (diff)
lockdep: Always try to set ->class_cache in register_lock_class() lockdep_init_map()
Commit ["62016250 lockdep: Add improved subclass caching"] tries to improve performance (expecially to reduce the cost of rq->lock) when using lockdep, but it fails due to lockdep_init_map() in which ->class_cache is cleared. The typical caller is lock_set_subclass(), after that class will not be cached anymore. This patch tries to achive the goal of commit 62016250 by always setting ->class_cache in register_lock_class(). === Score comparison of benchmarks === for i in `seq 1 10`; do ./perf bench -f simple sched messaging; done before: min: 0.604, max: 0.660, avg: 0.622 after: min: 0.414, max: 0.473, avg: 0.427 for i in `seq 1 10`; do ./perf bench -f simple sched messaging -g 40; done before: min: 2.347, max: 2.421, avg: 2.391 after: min: 1.652, max: 1.699, avg: 1.671 Signed-off-by: Yong Zhang <yong.zhang0@gmail.com> Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20111109080714.GC8124@zhy Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/lockdep.c')
-rw-r--r--kernel/lockdep.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index e69434b070da..103bed8423ff 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -722,7 +722,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
722 722
723 class = look_up_lock_class(lock, subclass); 723 class = look_up_lock_class(lock, subclass);
724 if (likely(class)) 724 if (likely(class))
725 return class; 725 goto out_set_class_cache;
726 726
727 /* 727 /*
728 * Debug-check: all keys must be persistent! 728 * Debug-check: all keys must be persistent!
@@ -807,6 +807,7 @@ out_unlock_set:
807 graph_unlock(); 807 graph_unlock();
808 raw_local_irq_restore(flags); 808 raw_local_irq_restore(flags);
809 809
810out_set_class_cache:
810 if (!subclass || force) 811 if (!subclass || force)
811 lock->class_cache[0] = class; 812 lock->class_cache[0] = class;
812 else if (subclass < NR_LOCKDEP_CACHING_CLASSES) 813 else if (subclass < NR_LOCKDEP_CACHING_CLASSES)