blob: a40f8508e760d0259e6016903be5fdb1e5d69aa9 [file] [log] [blame]
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -07001/*
2 * Split spinlock implementation out into its own file, so it can be
3 * compiled in a FTRACE-compatible way.
4 */
5#include <linux/kernel_stat.h>
6#include <linux/spinlock.h>
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -07007#include <linux/debugfs.h>
8#include <linux/log2.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09009#include <linux/gfp.h>
Konrad Rzeszutek Wilk354e7b72013-06-05 10:44:47 -040010#include <linux/slab.h>
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -070011
12#include <asm/paravirt.h>
13
14#include <xen/interface/xen.h>
15#include <xen/events.h>
16
17#include "xen-ops.h"
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -070018#include "debugfs.h"
19
20#ifdef CONFIG_XEN_DEBUG_FS
21static struct xen_spinlock_stats
22{
23 u64 taken;
24 u32 taken_slow;
25 u32 taken_slow_nested;
26 u32 taken_slow_pickup;
27 u32 taken_slow_spurious;
Jeremy Fitzhardinge1e696f62008-08-20 17:02:20 -070028 u32 taken_slow_irqenable;
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -070029
30 u64 released;
31 u32 released_slow;
32 u32 released_slow_kicked;
33
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -070034#define HISTO_BUCKETS 30
35 u32 histo_spin_total[HISTO_BUCKETS+1];
36 u32 histo_spin_spinning[HISTO_BUCKETS+1];
37 u32 histo_spin_blocked[HISTO_BUCKETS+1];
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -070038
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -070039 u64 time_total;
40 u64 time_spinning;
41 u64 time_blocked;
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -070042} spinlock_stats;
43
44static u8 zero_stats;
45
46static unsigned lock_timeout = 1 << 10;
47#define TIMEOUT lock_timeout
48
49static inline void check_zero(void)
50{
51 if (unlikely(zero_stats)) {
52 memset(&spinlock_stats, 0, sizeof(spinlock_stats));
53 zero_stats = 0;
54 }
55}
56
57#define ADD_STATS(elem, val) \
58 do { check_zero(); spinlock_stats.elem += (val); } while(0)
59
60static inline u64 spin_time_start(void)
61{
62 return xen_clocksource_read();
63}
64
65static void __spin_time_accum(u64 delta, u32 *array)
66{
67 unsigned index = ilog2(delta);
68
69 check_zero();
70
71 if (index < HISTO_BUCKETS)
72 array[index]++;
73 else
74 array[HISTO_BUCKETS]++;
75}
76
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -070077static inline void spin_time_accum_spinning(u64 start)
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -070078{
79 u32 delta = xen_clocksource_read() - start;
80
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -070081 __spin_time_accum(delta, spinlock_stats.histo_spin_spinning);
82 spinlock_stats.time_spinning += delta;
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -070083}
84
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -070085static inline void spin_time_accum_total(u64 start)
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -070086{
87 u32 delta = xen_clocksource_read() - start;
88
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -070089 __spin_time_accum(delta, spinlock_stats.histo_spin_total);
90 spinlock_stats.time_total += delta;
91}
92
93static inline void spin_time_accum_blocked(u64 start)
94{
95 u32 delta = xen_clocksource_read() - start;
96
97 __spin_time_accum(delta, spinlock_stats.histo_spin_blocked);
98 spinlock_stats.time_blocked += delta;
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -070099}
100#else /* !CONFIG_XEN_DEBUG_FS */
101#define TIMEOUT (1 << 10)
102#define ADD_STATS(elem, val) do { (void)(val); } while(0)
103
104static inline u64 spin_time_start(void)
105{
106 return 0;
107}
108
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700109static inline void spin_time_accum_total(u64 start)
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700110{
111}
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700112static inline void spin_time_accum_spinning(u64 start)
113{
114}
115static inline void spin_time_accum_blocked(u64 start)
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700116{
117}
118#endif /* CONFIG_XEN_DEBUG_FS */
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700119
David Vrabel7a7546b2012-01-23 19:32:25 +0000120/*
121 * Size struct xen_spinlock so it's the same as arch_spinlock_t.
122 */
123#if NR_CPUS < 256
124typedef u8 xen_spinners_t;
125# define inc_spinners(xl) \
126 asm(LOCK_PREFIX " incb %0" : "+m" ((xl)->spinners) : : "memory");
127# define dec_spinners(xl) \
128 asm(LOCK_PREFIX " decb %0" : "+m" ((xl)->spinners) : : "memory");
129#else
130typedef u16 xen_spinners_t;
131# define inc_spinners(xl) \
132 asm(LOCK_PREFIX " incw %0" : "+m" ((xl)->spinners) : : "memory");
133# define dec_spinners(xl) \
134 asm(LOCK_PREFIX " decw %0" : "+m" ((xl)->spinners) : : "memory");
135#endif
136
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700137struct xen_spinlock {
138 unsigned char lock; /* 0 -> free; 1 -> locked */
David Vrabel7a7546b2012-01-23 19:32:25 +0000139 xen_spinners_t spinners; /* count of waiting cpus */
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700140};
141
Thomas Gleixner445c8952009-12-02 19:49:50 +0100142static int xen_spin_is_locked(struct arch_spinlock *lock)
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700143{
144 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
145
146 return xl->lock != 0;
147}
148
Thomas Gleixner445c8952009-12-02 19:49:50 +0100149static int xen_spin_is_contended(struct arch_spinlock *lock)
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700150{
151 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
152
153 /* Not strictly true; this is only the count of contended
154 lock-takers entering the slow path. */
155 return xl->spinners != 0;
156}
157
Thomas Gleixner445c8952009-12-02 19:49:50 +0100158static int xen_spin_trylock(struct arch_spinlock *lock)
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700159{
160 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
161 u8 old = 1;
162
163 asm("xchgb %b0,%1"
164 : "+q" (old), "+m" (xl->lock) : : "memory");
165
166 return old == 0;
167}
168
Konrad Rzeszutek Wilk354e7b72013-06-05 10:44:47 -0400169static DEFINE_PER_CPU(char *, irq_name);
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700170static DEFINE_PER_CPU(int, lock_kicker_irq) = -1;
171static DEFINE_PER_CPU(struct xen_spinlock *, lock_spinners);
172
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700173/*
174 * Mark a cpu as interested in a lock. Returns the CPU's previous
175 * lock of interest, in case we got preempted by an interrupt.
176 */
177static inline struct xen_spinlock *spinning_lock(struct xen_spinlock *xl)
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700178{
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700179 struct xen_spinlock *prev;
180
Christoph Lameter780f36d2010-12-06 11:16:29 -0600181 prev = __this_cpu_read(lock_spinners);
182 __this_cpu_write(lock_spinners, xl);
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700183
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700184 wmb(); /* set lock of interest before count */
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700185
David Vrabel7a7546b2012-01-23 19:32:25 +0000186 inc_spinners(xl);
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700187
188 return prev;
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700189}
190
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700191/*
192 * Mark a cpu as no longer interested in a lock. Restores previous
193 * lock of interest (NULL for none).
194 */
195static inline void unspinning_lock(struct xen_spinlock *xl, struct xen_spinlock *prev)
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700196{
David Vrabel7a7546b2012-01-23 19:32:25 +0000197 dec_spinners(xl);
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700198 wmb(); /* decrement count before restoring lock */
Christoph Lameter780f36d2010-12-06 11:16:29 -0600199 __this_cpu_write(lock_spinners, prev);
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700200}
201
Thomas Gleixner445c8952009-12-02 19:49:50 +0100202static noinline int xen_spin_lock_slow(struct arch_spinlock *lock, bool irq_enable)
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700203{
204 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700205 struct xen_spinlock *prev;
Christoph Lameter780f36d2010-12-06 11:16:29 -0600206 int irq = __this_cpu_read(lock_kicker_irq);
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700207 int ret;
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700208 u64 start;
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700209
210 /* If kicker interrupts not initialized yet, just spin */
211 if (irq == -1)
212 return 0;
213
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700214 start = spin_time_start();
215
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700216 /* announce we're spinning */
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700217 prev = spinning_lock(xl);
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700218
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700219 ADD_STATS(taken_slow, 1);
220 ADD_STATS(taken_slow_nested, prev != NULL);
221
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700222 do {
Jeremy Fitzhardinge4d576b52009-09-09 12:33:51 -0700223 unsigned long flags;
224
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700225 /* clear pending */
226 xen_clear_irq_pending(irq);
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700227
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700228 /* check again make sure it didn't become free while
229 we weren't looking */
230 ret = xen_spin_trylock(lock);
231 if (ret) {
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700232 ADD_STATS(taken_slow_pickup, 1);
233
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700234 /*
235 * If we interrupted another spinlock while it
236 * was blocking, make sure it doesn't block
237 * without rechecking the lock.
238 */
239 if (prev != NULL)
240 xen_set_irq_pending(irq);
241 goto out;
242 }
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700243
David Howellsdf9ee292010-10-07 14:08:55 +0100244 flags = arch_local_save_flags();
Jeremy Fitzhardinge4d576b52009-09-09 12:33:51 -0700245 if (irq_enable) {
246 ADD_STATS(taken_slow_irqenable, 1);
247 raw_local_irq_enable();
248 }
249
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700250 /*
251 * Block until irq becomes pending. If we're
252 * interrupted at this point (after the trylock but
253 * before entering the block), then the nested lock
254 * handler guarantees that the irq will be left
255 * pending if there's any chance the lock became free;
256 * xen_poll_irq() returns immediately if the irq is
257 * pending.
258 */
259 xen_poll_irq(irq);
Jeremy Fitzhardinge4d576b52009-09-09 12:33:51 -0700260
261 raw_local_irq_restore(flags);
262
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700263 ADD_STATS(taken_slow_spurious, !xen_test_irq_pending(irq));
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700264 } while (!xen_test_irq_pending(irq)); /* check for spurious wakeups */
265
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200266 kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700267
268out:
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700269 unspinning_lock(xl, prev);
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700270 spin_time_accum_blocked(start);
271
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700272 return ret;
273}
274
Thomas Gleixner445c8952009-12-02 19:49:50 +0100275static inline void __xen_spin_lock(struct arch_spinlock *lock, bool irq_enable)
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700276{
277 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700278 unsigned timeout;
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700279 u8 oldval;
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700280 u64 start_spin;
281
282 ADD_STATS(taken, 1);
283
284 start_spin = spin_time_start();
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700285
286 do {
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700287 u64 start_spin_fast = spin_time_start();
288
289 timeout = TIMEOUT;
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700290
291 asm("1: xchgb %1,%0\n"
292 " testb %1,%1\n"
293 " jz 3f\n"
294 "2: rep;nop\n"
295 " cmpb $0,%0\n"
296 " je 1b\n"
297 " dec %2\n"
298 " jnz 2b\n"
299 "3:\n"
300 : "+m" (xl->lock), "=q" (oldval), "+r" (timeout)
301 : "1" (1)
302 : "memory");
303
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700304 spin_time_accum_spinning(start_spin_fast);
Jeremy Fitzhardinge1e696f62008-08-20 17:02:20 -0700305
306 } while (unlikely(oldval != 0 &&
307 (TIMEOUT == ~0 || !xen_spin_lock_slow(lock, irq_enable))));
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700308
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700309 spin_time_accum_total(start_spin);
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700310}
311
Thomas Gleixner445c8952009-12-02 19:49:50 +0100312static void xen_spin_lock(struct arch_spinlock *lock)
Jeremy Fitzhardinge1e696f62008-08-20 17:02:20 -0700313{
314 __xen_spin_lock(lock, false);
315}
316
Thomas Gleixner445c8952009-12-02 19:49:50 +0100317static void xen_spin_lock_flags(struct arch_spinlock *lock, unsigned long flags)
Jeremy Fitzhardinge1e696f62008-08-20 17:02:20 -0700318{
319 __xen_spin_lock(lock, !raw_irqs_disabled_flags(flags));
320}
321
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700322static noinline void xen_spin_unlock_slow(struct xen_spinlock *xl)
323{
324 int cpu;
325
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700326 ADD_STATS(released_slow, 1);
327
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700328 for_each_online_cpu(cpu) {
329 /* XXX should mix up next cpu selection */
330 if (per_cpu(lock_spinners, cpu) == xl) {
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700331 ADD_STATS(released_slow_kicked, 1);
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700332 xen_send_IPI_one(cpu, XEN_SPIN_UNLOCK_VECTOR);
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700333 }
334 }
335}
336
Thomas Gleixner445c8952009-12-02 19:49:50 +0100337static void xen_spin_unlock(struct arch_spinlock *lock)
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700338{
339 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
340
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700341 ADD_STATS(released, 1);
342
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700343 smp_wmb(); /* make sure no writes get moved after unlock */
344 xl->lock = 0; /* release lock */
345
Yang Xiaowei2496afb2009-09-09 12:44:52 -0700346 /*
347 * Make sure unlock happens before checking for waiting
348 * spinners. We need a strong barrier to enforce the
349 * write-read ordering to different memory locations, as the
350 * CPU makes no implied guarantees about their ordering.
351 */
352 mb();
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700353
354 if (unlikely(xl->spinners))
355 xen_spin_unlock_slow(xl);
356}
357
358static irqreturn_t dummy_handler(int irq, void *dev_id)
359{
360 BUG();
361 return IRQ_HANDLED;
362}
363
364void __cpuinit xen_init_lock_cpu(int cpu)
365{
366 int irq;
Konrad Rzeszutek Wilk354e7b72013-06-05 10:44:47 -0400367 char *name;
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700368
Konrad Rzeszutek Wilkcb91f8f2013-05-06 08:33:15 -0400369 WARN(per_cpu(lock_kicker_irq, cpu) >= 0, "spinlock on CPU%d exists on IRQ%d!\n",
Konrad Rzeszutek Wilkcb9c6f12013-04-16 14:33:20 -0400370 cpu, per_cpu(lock_kicker_irq, cpu));
371
Konrad Rzeszutek Wilk70dd4992013-04-16 14:34:45 -0400372 /*
373 * See git commit f10cd522c5fbfec9ae3cc01967868c9c2401ed23
374 * (xen: disable PV spinlocks on HVM)
375 */
376 if (xen_hvm_domain())
377 return;
378
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700379 name = kasprintf(GFP_KERNEL, "spinlock%d", cpu);
380 irq = bind_ipi_to_irqhandler(XEN_SPIN_UNLOCK_VECTOR,
381 cpu,
382 dummy_handler,
383 IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
384 name,
385 NULL);
386
387 if (irq >= 0) {
388 disable_irq(irq); /* make sure it's never delivered */
389 per_cpu(lock_kicker_irq, cpu) = irq;
Konrad Rzeszutek Wilk354e7b72013-06-05 10:44:47 -0400390 per_cpu(irq_name, cpu) = name;
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700391 }
392
393 printk("cpu %d spinlock event irq %d\n", cpu, irq);
394}
395
Alex Nixond68d82a2008-08-22 11:52:15 +0100396void xen_uninit_lock_cpu(int cpu)
397{
Konrad Rzeszutek Wilk70dd4992013-04-16 14:34:45 -0400398 /*
399 * See git commit f10cd522c5fbfec9ae3cc01967868c9c2401ed23
400 * (xen: disable PV spinlocks on HVM)
401 */
402 if (xen_hvm_domain())
403 return;
404
Alex Nixond68d82a2008-08-22 11:52:15 +0100405 unbind_from_irqhandler(per_cpu(lock_kicker_irq, cpu), NULL);
Konrad Rzeszutek Wilkcb9c6f12013-04-16 14:33:20 -0400406 per_cpu(lock_kicker_irq, cpu) = -1;
Konrad Rzeszutek Wilk354e7b72013-06-05 10:44:47 -0400407 kfree(per_cpu(irq_name, cpu));
408 per_cpu(irq_name, cpu) = NULL;
Alex Nixond68d82a2008-08-22 11:52:15 +0100409}
410
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700411void __init xen_init_spinlocks(void)
412{
Konrad Rzeszutek Wilk70dd4992013-04-16 14:34:45 -0400413 /*
414 * See git commit f10cd522c5fbfec9ae3cc01967868c9c2401ed23
415 * (xen: disable PV spinlocks on HVM)
416 */
417 if (xen_hvm_domain())
418 return;
419
David Vrabel7a7546b2012-01-23 19:32:25 +0000420 BUILD_BUG_ON(sizeof(struct xen_spinlock) > sizeof(arch_spinlock_t));
421
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700422 pv_lock_ops.spin_is_locked = xen_spin_is_locked;
423 pv_lock_ops.spin_is_contended = xen_spin_is_contended;
424 pv_lock_ops.spin_lock = xen_spin_lock;
Jeremy Fitzhardinge1e696f62008-08-20 17:02:20 -0700425 pv_lock_ops.spin_lock_flags = xen_spin_lock_flags;
Jeremy Fitzhardinged5de8842008-07-23 13:28:58 -0700426 pv_lock_ops.spin_trylock = xen_spin_trylock;
427 pv_lock_ops.spin_unlock = xen_spin_unlock;
428}
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700429
430#ifdef CONFIG_XEN_DEBUG_FS
431
432static struct dentry *d_spin_debug;
433
434static int __init xen_spinlock_debugfs(void)
435{
436 struct dentry *d_xen = xen_init_debugfs();
437
438 if (d_xen == NULL)
439 return -ENOMEM;
440
441 d_spin_debug = debugfs_create_dir("spinlocks", d_xen);
442
443 debugfs_create_u8("zero_stats", 0644, d_spin_debug, &zero_stats);
444
445 debugfs_create_u32("timeout", 0644, d_spin_debug, &lock_timeout);
446
447 debugfs_create_u64("taken", 0444, d_spin_debug, &spinlock_stats.taken);
448 debugfs_create_u32("taken_slow", 0444, d_spin_debug,
449 &spinlock_stats.taken_slow);
450 debugfs_create_u32("taken_slow_nested", 0444, d_spin_debug,
451 &spinlock_stats.taken_slow_nested);
452 debugfs_create_u32("taken_slow_pickup", 0444, d_spin_debug,
453 &spinlock_stats.taken_slow_pickup);
454 debugfs_create_u32("taken_slow_spurious", 0444, d_spin_debug,
455 &spinlock_stats.taken_slow_spurious);
Jeremy Fitzhardinge1e696f62008-08-20 17:02:20 -0700456 debugfs_create_u32("taken_slow_irqenable", 0444, d_spin_debug,
457 &spinlock_stats.taken_slow_irqenable);
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700458
459 debugfs_create_u64("released", 0444, d_spin_debug, &spinlock_stats.released);
460 debugfs_create_u32("released_slow", 0444, d_spin_debug,
461 &spinlock_stats.released_slow);
462 debugfs_create_u32("released_slow_kicked", 0444, d_spin_debug,
463 &spinlock_stats.released_slow_kicked);
464
465 debugfs_create_u64("time_spinning", 0444, d_spin_debug,
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700466 &spinlock_stats.time_spinning);
467 debugfs_create_u64("time_blocked", 0444, d_spin_debug,
468 &spinlock_stats.time_blocked);
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700469 debugfs_create_u64("time_total", 0444, d_spin_debug,
Jeremy Fitzhardingef8eca412008-08-20 17:02:21 -0700470 &spinlock_stats.time_total);
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700471
Srivatsa Vaddagiri9fe2a702012-03-23 13:36:28 +0530472 debugfs_create_u32_array("histo_total", 0444, d_spin_debug,
473 spinlock_stats.histo_spin_total, HISTO_BUCKETS + 1);
474 debugfs_create_u32_array("histo_spinning", 0444, d_spin_debug,
475 spinlock_stats.histo_spin_spinning, HISTO_BUCKETS + 1);
476 debugfs_create_u32_array("histo_blocked", 0444, d_spin_debug,
477 spinlock_stats.histo_spin_blocked, HISTO_BUCKETS + 1);
Jeremy Fitzhardinge994025c2008-08-20 17:02:19 -0700478
479 return 0;
480}
481fs_initcall(xen_spinlock_debugfs);
482
483#endif /* CONFIG_XEN_DEBUG_FS */