aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2009-07-16 09:44:29 -0400
committerPeter Zijlstra <a.p.zijlstra@chello.nl>2009-07-24 04:49:56 -0400
commitef681026ff85c49b7399ceec3eb62bbbcce605e8 (patch)
tree38093d7b18ad236e98d59118c730784b67f3467a
parent24208ca76707581a097c01a73fd63781e73d3404 (diff)
lockdep: Implement lockdep_count_*ward_deps by BFS
Implement lockdep_count_{for,back}ward using BFS. Signed-off-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1246201486-7308-8-git-send-email-tom.leiming@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--kernel/lockdep.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 938dc500f1aa..b896f23e00cf 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -1115,61 +1115,59 @@ static noinline int print_bfs_bug(int ret)
1115 return 0; 1115 return 0;
1116} 1116}
1117 1117
1118unsigned long __lockdep_count_forward_deps(struct lock_class *class, 1118static int noop_count(struct lock_list *entry, void *data)
1119 unsigned int depth)
1120{ 1119{
1121 struct lock_list *entry; 1120 (*(unsigned long *)data)++;
1122 unsigned long ret = 1; 1121 return 0;
1122}
1123 1123
1124 if (lockdep_dependency_visit(class, depth)) 1124unsigned long __lockdep_count_forward_deps(struct lock_list *this)
1125 return 0; 1125{
1126 unsigned long count = 0;
1127 struct lock_list *uninitialized_var(target_entry);
1126 1128
1127 /* 1129 __bfs_forwards(this, (void *)&count, noop_count, &target_entry);
1128 * Recurse this class's dependency list:
1129 */
1130 list_for_each_entry(entry, &class->locks_after, entry)
1131 ret += __lockdep_count_forward_deps(entry->class, depth + 1);
1132 1130
1133 return ret; 1131 return count;
1134} 1132}
1135
1136unsigned long lockdep_count_forward_deps(struct lock_class *class) 1133unsigned long lockdep_count_forward_deps(struct lock_class *class)
1137{ 1134{
1138 unsigned long ret, flags; 1135 unsigned long ret, flags;
1136 struct lock_list this;
1137
1138 this.parent = NULL;
1139 this.class = class;
1139 1140
1140 local_irq_save(flags); 1141 local_irq_save(flags);
1141 __raw_spin_lock(&lockdep_lock); 1142 __raw_spin_lock(&lockdep_lock);
1142 ret = __lockdep_count_forward_deps(class, 0); 1143 ret = __lockdep_count_forward_deps(&this);
1143 __raw_spin_unlock(&lockdep_lock); 1144 __raw_spin_unlock(&lockdep_lock);
1144 local_irq_restore(flags); 1145 local_irq_restore(flags);
1145 1146
1146 return ret; 1147 return ret;
1147} 1148}
1148 1149
1149unsigned long __lockdep_count_backward_deps(struct lock_class *class, 1150unsigned long __lockdep_count_backward_deps(struct lock_list *this)
1150 unsigned int depth)
1151{ 1151{
1152 struct lock_list *entry; 1152 unsigned long count = 0;
1153 unsigned long ret = 1; 1153 struct lock_list *uninitialized_var(target_entry);
1154 1154
1155 if (lockdep_dependency_visit(class, depth)) 1155 __bfs_backwards(this, (void *)&count, noop_count, &target_entry);
1156 return 0;
1157 /*
1158 * Recurse this class's dependency list:
1159 */
1160 list_for_each_entry(entry, &class->locks_before, entry)
1161 ret += __lockdep_count_backward_deps(entry->class, depth + 1);
1162 1156
1163 return ret; 1157 return count;
1164} 1158}
1165 1159
1166unsigned long lockdep_count_backward_deps(struct lock_class *class) 1160unsigned long lockdep_count_backward_deps(struct lock_class *class)
1167{ 1161{
1168 unsigned long ret, flags; 1162 unsigned long ret, flags;
1163 struct lock_list this;
1164
1165 this.parent = NULL;
1166 this.class = class;
1169 1167
1170 local_irq_save(flags); 1168 local_irq_save(flags);
1171 __raw_spin_lock(&lockdep_lock); 1169 __raw_spin_lock(&lockdep_lock);
1172 ret = __lockdep_count_backward_deps(class, 0); 1170 ret = __lockdep_count_backward_deps(&this);
1173 __raw_spin_unlock(&lockdep_lock); 1171 __raw_spin_unlock(&lockdep_lock);
1174 local_irq_restore(flags); 1172 local_irq_restore(flags);
1175 1173