diff options
Diffstat (limited to 'kernel/lockdep.c')
-rw-r--r-- | kernel/lockdep.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 70ca4db28aff..a8dc99d9fef7 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -149,6 +149,50 @@ static void lock_time_inc(struct lock_time *lt, s64 time) | |||
149 | lt->nr++; | 149 | lt->nr++; |
150 | } | 150 | } |
151 | 151 | ||
152 | static inline void lock_time_add(struct lock_time *src, struct lock_time *dst) | ||
153 | { | ||
154 | dst->min += src->min; | ||
155 | dst->max += src->max; | ||
156 | dst->total += src->total; | ||
157 | dst->nr += src->nr; | ||
158 | } | ||
159 | |||
160 | struct lock_class_stats lock_stats(struct lock_class *class) | ||
161 | { | ||
162 | struct lock_class_stats stats; | ||
163 | int cpu, i; | ||
164 | |||
165 | memset(&stats, 0, sizeof(struct lock_class_stats)); | ||
166 | for_each_possible_cpu(cpu) { | ||
167 | struct lock_class_stats *pcs = | ||
168 | &per_cpu(lock_stats, cpu)[class - lock_classes]; | ||
169 | |||
170 | for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++) | ||
171 | stats.contention_point[i] += pcs->contention_point[i]; | ||
172 | |||
173 | lock_time_add(&pcs->read_waittime, &stats.read_waittime); | ||
174 | lock_time_add(&pcs->write_waittime, &stats.write_waittime); | ||
175 | |||
176 | lock_time_add(&pcs->read_holdtime, &stats.read_holdtime); | ||
177 | lock_time_add(&pcs->write_holdtime, &stats.write_holdtime); | ||
178 | } | ||
179 | |||
180 | return stats; | ||
181 | } | ||
182 | |||
183 | void clear_lock_stats(struct lock_class *class) | ||
184 | { | ||
185 | int cpu; | ||
186 | |||
187 | for_each_possible_cpu(cpu) { | ||
188 | struct lock_class_stats *cpu_stats = | ||
189 | &per_cpu(lock_stats, cpu)[class - lock_classes]; | ||
190 | |||
191 | memset(cpu_stats, 0, sizeof(struct lock_class_stats)); | ||
192 | } | ||
193 | memset(class->contention_point, 0, sizeof(class->contention_point)); | ||
194 | } | ||
195 | |||
152 | static struct lock_class_stats *get_lock_stats(struct lock_class *class) | 196 | static struct lock_class_stats *get_lock_stats(struct lock_class *class) |
153 | { | 197 | { |
154 | return &get_cpu_var(lock_stats)[class - lock_classes]; | 198 | return &get_cpu_var(lock_stats)[class - lock_classes]; |