2008-07-23 14:28:58 -06:00
|
|
|
/*
|
|
|
|
* Split spinlock implementation out into its own file, so it can be
|
|
|
|
* compiled in a FTRACE-compatible way.
|
|
|
|
*/
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/spinlock.h>
|
2008-08-20 18:02:19 -06:00
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/log2.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/gfp.h>
|
2008-07-23 14:28:58 -06:00
|
|
|
|
|
|
|
#include <asm/paravirt.h>
|
|
|
|
|
|
|
|
#include <xen/interface/xen.h>
|
|
|
|
#include <xen/events.h>
|
|
|
|
|
|
|
|
#include "xen-ops.h"
|
2008-08-20 18:02:19 -06:00
|
|
|
#include "debugfs.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_XEN_DEBUG_FS
|
|
|
|
static struct xen_spinlock_stats
|
|
|
|
{
|
|
|
|
u64 taken;
|
|
|
|
u32 taken_slow;
|
|
|
|
u32 taken_slow_nested;
|
|
|
|
u32 taken_slow_pickup;
|
|
|
|
u32 taken_slow_spurious;
|
2008-08-20 18:02:20 -06:00
|
|
|
u32 taken_slow_irqenable;
|
2008-08-20 18:02:19 -06:00
|
|
|
|
|
|
|
u64 released;
|
|
|
|
u32 released_slow;
|
|
|
|
u32 released_slow_kicked;
|
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
#define HISTO_BUCKETS 30
|
|
|
|
u32 histo_spin_total[HISTO_BUCKETS+1];
|
|
|
|
u32 histo_spin_spinning[HISTO_BUCKETS+1];
|
|
|
|
u32 histo_spin_blocked[HISTO_BUCKETS+1];
|
|
|
|
|
|
|
|
u64 time_total;
|
|
|
|
u64 time_spinning;
|
|
|
|
u64 time_blocked;
|
2008-08-20 18:02:19 -06:00
|
|
|
} spinlock_stats;
|
|
|
|
|
|
|
|
static u8 zero_stats;
|
|
|
|
|
|
|
|
static unsigned lock_timeout = 1 << 10;
|
|
|
|
#define TIMEOUT lock_timeout
|
|
|
|
|
|
|
|
static inline void check_zero(void)
|
|
|
|
{
|
|
|
|
if (unlikely(zero_stats)) {
|
|
|
|
memset(&spinlock_stats, 0, sizeof(spinlock_stats));
|
|
|
|
zero_stats = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ADD_STATS(elem, val) \
|
|
|
|
do { check_zero(); spinlock_stats.elem += (val); } while(0)
|
|
|
|
|
|
|
|
static inline u64 spin_time_start(void)
|
|
|
|
{
|
|
|
|
return xen_clocksource_read();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __spin_time_accum(u64 delta, u32 *array)
|
|
|
|
{
|
|
|
|
unsigned index = ilog2(delta);
|
|
|
|
|
|
|
|
check_zero();
|
|
|
|
|
|
|
|
if (index < HISTO_BUCKETS)
|
|
|
|
array[index]++;
|
|
|
|
else
|
|
|
|
array[HISTO_BUCKETS]++;
|
|
|
|
}
|
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
static inline void spin_time_accum_spinning(u64 start)
|
|
|
|
{
|
|
|
|
u32 delta = xen_clocksource_read() - start;
|
|
|
|
|
|
|
|
__spin_time_accum(delta, spinlock_stats.histo_spin_spinning);
|
|
|
|
spinlock_stats.time_spinning += delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void spin_time_accum_total(u64 start)
|
2008-08-20 18:02:19 -06:00
|
|
|
{
|
|
|
|
u32 delta = xen_clocksource_read() - start;
|
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
__spin_time_accum(delta, spinlock_stats.histo_spin_total);
|
|
|
|
spinlock_stats.time_total += delta;
|
2008-08-20 18:02:19 -06:00
|
|
|
}
|
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
static inline void spin_time_accum_blocked(u64 start)
|
2008-08-20 18:02:19 -06:00
|
|
|
{
|
|
|
|
u32 delta = xen_clocksource_read() - start;
|
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
__spin_time_accum(delta, spinlock_stats.histo_spin_blocked);
|
|
|
|
spinlock_stats.time_blocked += delta;
|
2008-08-20 18:02:19 -06:00
|
|
|
}
|
|
|
|
#else /* !CONFIG_XEN_DEBUG_FS */
|
|
|
|
#define TIMEOUT (1 << 10)
|
|
|
|
#define ADD_STATS(elem, val) do { (void)(val); } while(0)
|
|
|
|
|
|
|
|
static inline u64 spin_time_start(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
static inline void spin_time_accum_total(u64 start)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void spin_time_accum_spinning(u64 start)
|
2008-08-20 18:02:19 -06:00
|
|
|
{
|
|
|
|
}
|
2008-08-20 18:02:21 -06:00
|
|
|
static inline void spin_time_accum_blocked(u64 start)
|
2008-08-20 18:02:19 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_XEN_DEBUG_FS */
|
2008-07-23 14:28:58 -06:00
|
|
|
|
|
|
|
struct xen_spinlock {
|
|
|
|
unsigned char lock; /* 0 -> free; 1 -> locked */
|
|
|
|
unsigned short spinners; /* count of waiting cpus */
|
|
|
|
};
|
|
|
|
|
2009-12-02 11:49:50 -07:00
|
|
|
static int xen_spin_is_locked(struct arch_spinlock *lock)
|
2008-07-23 14:28:58 -06:00
|
|
|
{
|
|
|
|
struct xen_spinlock *xl = (struct xen_spinlock *)lock;
|
|
|
|
|
|
|
|
return xl->lock != 0;
|
|
|
|
}
|
|
|
|
|
2009-12-02 11:49:50 -07:00
|
|
|
static int xen_spin_is_contended(struct arch_spinlock *lock)
|
2008-07-23 14:28:58 -06:00
|
|
|
{
|
|
|
|
struct xen_spinlock *xl = (struct xen_spinlock *)lock;
|
|
|
|
|
|
|
|
/* Not strictly true; this is only the count of contended
|
|
|
|
lock-takers entering the slow path. */
|
|
|
|
return xl->spinners != 0;
|
|
|
|
}
|
|
|
|
|
2009-12-02 11:49:50 -07:00
|
|
|
static int xen_spin_trylock(struct arch_spinlock *lock)
|
2008-07-23 14:28:58 -06:00
|
|
|
{
|
|
|
|
struct xen_spinlock *xl = (struct xen_spinlock *)lock;
|
|
|
|
u8 old = 1;
|
|
|
|
|
|
|
|
asm("xchgb %b0,%1"
|
|
|
|
: "+q" (old), "+m" (xl->lock) : : "memory");
|
|
|
|
|
|
|
|
return old == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEFINE_PER_CPU(int, lock_kicker_irq) = -1;
|
|
|
|
static DEFINE_PER_CPU(struct xen_spinlock *, lock_spinners);
|
|
|
|
|
2008-08-20 18:02:18 -06:00
|
|
|
/*
|
|
|
|
* Mark a cpu as interested in a lock. Returns the CPU's previous
|
|
|
|
* lock of interest, in case we got preempted by an interrupt.
|
|
|
|
*/
|
|
|
|
static inline struct xen_spinlock *spinning_lock(struct xen_spinlock *xl)
|
2008-07-23 14:28:58 -06:00
|
|
|
{
|
2008-08-20 18:02:18 -06:00
|
|
|
struct xen_spinlock *prev;
|
|
|
|
|
2010-12-06 10:16:29 -07:00
|
|
|
prev = __this_cpu_read(lock_spinners);
|
|
|
|
__this_cpu_write(lock_spinners, xl);
|
2008-08-20 18:02:18 -06:00
|
|
|
|
2008-07-23 14:28:58 -06:00
|
|
|
wmb(); /* set lock of interest before count */
|
2008-08-20 18:02:18 -06:00
|
|
|
|
2008-07-23 14:28:58 -06:00
|
|
|
asm(LOCK_PREFIX " incw %0"
|
|
|
|
: "+m" (xl->spinners) : : "memory");
|
2008-08-20 18:02:18 -06:00
|
|
|
|
|
|
|
return prev;
|
2008-07-23 14:28:58 -06:00
|
|
|
}
|
|
|
|
|
2008-08-20 18:02:18 -06:00
|
|
|
/*
|
|
|
|
* Mark a cpu as no longer interested in a lock. Restores previous
|
|
|
|
* lock of interest (NULL for none).
|
|
|
|
*/
|
|
|
|
static inline void unspinning_lock(struct xen_spinlock *xl, struct xen_spinlock *prev)
|
2008-07-23 14:28:58 -06:00
|
|
|
{
|
|
|
|
asm(LOCK_PREFIX " decw %0"
|
|
|
|
: "+m" (xl->spinners) : : "memory");
|
2008-08-20 18:02:18 -06:00
|
|
|
wmb(); /* decrement count before restoring lock */
|
2010-12-06 10:16:29 -07:00
|
|
|
__this_cpu_write(lock_spinners, prev);
|
2008-07-23 14:28:58 -06:00
|
|
|
}
|
|
|
|
|
2009-12-02 11:49:50 -07:00
|
|
|
static noinline int xen_spin_lock_slow(struct arch_spinlock *lock, bool irq_enable)
|
2008-07-23 14:28:58 -06:00
|
|
|
{
|
|
|
|
struct xen_spinlock *xl = (struct xen_spinlock *)lock;
|
2008-08-20 18:02:18 -06:00
|
|
|
struct xen_spinlock *prev;
|
2010-12-06 10:16:29 -07:00
|
|
|
int irq = __this_cpu_read(lock_kicker_irq);
|
2008-07-23 14:28:58 -06:00
|
|
|
int ret;
|
2008-08-20 18:02:21 -06:00
|
|
|
u64 start;
|
2008-07-23 14:28:58 -06:00
|
|
|
|
|
|
|
/* If kicker interrupts not initialized yet, just spin */
|
|
|
|
if (irq == -1)
|
|
|
|
return 0;
|
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
start = spin_time_start();
|
|
|
|
|
2008-07-23 14:28:58 -06:00
|
|
|
/* announce we're spinning */
|
2008-08-20 18:02:18 -06:00
|
|
|
prev = spinning_lock(xl);
|
2008-07-23 14:28:58 -06:00
|
|
|
|
2008-08-20 18:02:19 -06:00
|
|
|
ADD_STATS(taken_slow, 1);
|
|
|
|
ADD_STATS(taken_slow_nested, prev != NULL);
|
|
|
|
|
2008-08-20 18:02:18 -06:00
|
|
|
do {
|
2009-09-09 13:33:51 -06:00
|
|
|
unsigned long flags;
|
|
|
|
|
2008-08-20 18:02:18 -06:00
|
|
|
/* clear pending */
|
|
|
|
xen_clear_irq_pending(irq);
|
|
|
|
|
|
|
|
/* check again make sure it didn't become free while
|
|
|
|
we weren't looking */
|
|
|
|
ret = xen_spin_trylock(lock);
|
|
|
|
if (ret) {
|
2008-08-20 18:02:19 -06:00
|
|
|
ADD_STATS(taken_slow_pickup, 1);
|
|
|
|
|
2008-08-20 18:02:18 -06:00
|
|
|
/*
|
|
|
|
* If we interrupted another spinlock while it
|
|
|
|
* was blocking, make sure it doesn't block
|
|
|
|
* without rechecking the lock.
|
|
|
|
*/
|
|
|
|
if (prev != NULL)
|
|
|
|
xen_set_irq_pending(irq);
|
|
|
|
goto out;
|
|
|
|
}
|
2008-07-23 14:28:58 -06:00
|
|
|
|
2010-10-07 07:08:55 -06:00
|
|
|
flags = arch_local_save_flags();
|
2009-09-09 13:33:51 -06:00
|
|
|
if (irq_enable) {
|
|
|
|
ADD_STATS(taken_slow_irqenable, 1);
|
|
|
|
raw_local_irq_enable();
|
|
|
|
}
|
|
|
|
|
2008-08-20 18:02:18 -06:00
|
|
|
/*
|
|
|
|
* Block until irq becomes pending. If we're
|
|
|
|
* interrupted at this point (after the trylock but
|
|
|
|
* before entering the block), then the nested lock
|
|
|
|
* handler guarantees that the irq will be left
|
|
|
|
* pending if there's any chance the lock became free;
|
|
|
|
* xen_poll_irq() returns immediately if the irq is
|
|
|
|
* pending.
|
|
|
|
*/
|
|
|
|
xen_poll_irq(irq);
|
2009-09-09 13:33:51 -06:00
|
|
|
|
|
|
|
raw_local_irq_restore(flags);
|
|
|
|
|
2008-08-20 18:02:19 -06:00
|
|
|
ADD_STATS(taken_slow_spurious, !xen_test_irq_pending(irq));
|
2008-08-20 18:02:18 -06:00
|
|
|
} while (!xen_test_irq_pending(irq)); /* check for spurious wakeups */
|
2008-07-23 14:28:58 -06:00
|
|
|
|
2008-10-15 07:27:23 -06:00
|
|
|
kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
|
2008-07-23 14:28:58 -06:00
|
|
|
|
|
|
|
out:
|
2008-08-20 18:02:18 -06:00
|
|
|
unspinning_lock(xl, prev);
|
2008-08-20 18:02:21 -06:00
|
|
|
spin_time_accum_blocked(start);
|
|
|
|
|
2008-07-23 14:28:58 -06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-12-02 11:49:50 -07:00
|
|
|
static inline void __xen_spin_lock(struct arch_spinlock *lock, bool irq_enable)
|
2008-07-23 14:28:58 -06:00
|
|
|
{
|
|
|
|
struct xen_spinlock *xl = (struct xen_spinlock *)lock;
|
2008-08-20 18:02:19 -06:00
|
|
|
unsigned timeout;
|
2008-07-23 14:28:58 -06:00
|
|
|
u8 oldval;
|
2008-08-20 18:02:19 -06:00
|
|
|
u64 start_spin;
|
|
|
|
|
|
|
|
ADD_STATS(taken, 1);
|
|
|
|
|
|
|
|
start_spin = spin_time_start();
|
2008-07-23 14:28:58 -06:00
|
|
|
|
|
|
|
do {
|
2008-08-20 18:02:19 -06:00
|
|
|
u64 start_spin_fast = spin_time_start();
|
|
|
|
|
|
|
|
timeout = TIMEOUT;
|
2008-07-23 14:28:58 -06:00
|
|
|
|
|
|
|
asm("1: xchgb %1,%0\n"
|
|
|
|
" testb %1,%1\n"
|
|
|
|
" jz 3f\n"
|
|
|
|
"2: rep;nop\n"
|
|
|
|
" cmpb $0,%0\n"
|
|
|
|
" je 1b\n"
|
|
|
|
" dec %2\n"
|
|
|
|
" jnz 2b\n"
|
|
|
|
"3:\n"
|
|
|
|
: "+m" (xl->lock), "=q" (oldval), "+r" (timeout)
|
|
|
|
: "1" (1)
|
|
|
|
: "memory");
|
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
spin_time_accum_spinning(start_spin_fast);
|
2008-08-20 18:02:20 -06:00
|
|
|
|
|
|
|
} while (unlikely(oldval != 0 &&
|
|
|
|
(TIMEOUT == ~0 || !xen_spin_lock_slow(lock, irq_enable))));
|
2008-08-20 18:02:19 -06:00
|
|
|
|
2008-08-20 18:02:21 -06:00
|
|
|
spin_time_accum_total(start_spin);
|
2008-07-23 14:28:58 -06:00
|
|
|
}
|
|
|
|
|
2009-12-02 11:49:50 -07:00
|
|
|
static void xen_spin_lock(struct arch_spinlock *lock)
|
2008-08-20 18:02:20 -06:00
|
|
|
{
|
|
|
|
__xen_spin_lock(lock, false);
|
|
|
|
}
|
|
|
|
|
2009-12-02 11:49:50 -07:00
|
|
|
static void xen_spin_lock_flags(struct arch_spinlock *lock, unsigned long flags)
|
2008-08-20 18:02:20 -06:00
|
|
|
{
|
|
|
|
__xen_spin_lock(lock, !raw_irqs_disabled_flags(flags));
|
|
|
|
}
|
|
|
|
|
2008-07-23 14:28:58 -06:00
|
|
|
static noinline void xen_spin_unlock_slow(struct xen_spinlock *xl)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
|
2008-08-20 18:02:19 -06:00
|
|
|
ADD_STATS(released_slow, 1);
|
|
|
|
|
2008-07-23 14:28:58 -06:00
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
/* XXX should mix up next cpu selection */
|
|
|
|
if (per_cpu(lock_spinners, cpu) == xl) {
|
2008-08-20 18:02:19 -06:00
|
|
|
ADD_STATS(released_slow_kicked, 1);
|
2008-07-23 14:28:58 -06:00
|
|
|
xen_send_IPI_one(cpu, XEN_SPIN_UNLOCK_VECTOR);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-02 11:49:50 -07:00
|
|
|
static void xen_spin_unlock(struct arch_spinlock *lock)
|
2008-07-23 14:28:58 -06:00
|
|
|
{
|
|
|
|
struct xen_spinlock *xl = (struct xen_spinlock *)lock;
|
|
|
|
|
2008-08-20 18:02:19 -06:00
|
|
|
ADD_STATS(released, 1);
|
|
|
|
|
2008-07-23 14:28:58 -06:00
|
|
|
smp_wmb(); /* make sure no writes get moved after unlock */
|
|
|
|
xl->lock = 0; /* release lock */
|
|
|
|
|
2009-09-09 13:44:52 -06:00
|
|
|
/*
|
|
|
|
* Make sure unlock happens before checking for waiting
|
|
|
|
* spinners. We need a strong barrier to enforce the
|
|
|
|
* write-read ordering to different memory locations, as the
|
|
|
|
* CPU makes no implied guarantees about their ordering.
|
|
|
|
*/
|
|
|
|
mb();
|
2008-07-23 14:28:58 -06:00
|
|
|
|
|
|
|
if (unlikely(xl->spinners))
|
|
|
|
xen_spin_unlock_slow(xl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t dummy_handler(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
BUG();
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __cpuinit xen_init_lock_cpu(int cpu)
|
|
|
|
{
|
|
|
|
int irq;
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
name = kasprintf(GFP_KERNEL, "spinlock%d", cpu);
|
|
|
|
irq = bind_ipi_to_irqhandler(XEN_SPIN_UNLOCK_VECTOR,
|
|
|
|
cpu,
|
|
|
|
dummy_handler,
|
|
|
|
IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
|
|
|
|
name,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (irq >= 0) {
|
|
|
|
disable_irq(irq); /* make sure it's never delivered */
|
|
|
|
per_cpu(lock_kicker_irq, cpu) = irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk("cpu %d spinlock event irq %d\n", cpu, irq);
|
|
|
|
}
|
|
|
|
|
2008-08-22 04:52:15 -06:00
|
|
|
void xen_uninit_lock_cpu(int cpu)
|
|
|
|
{
|
|
|
|
unbind_from_irqhandler(per_cpu(lock_kicker_irq, cpu), NULL);
|
|
|
|
}
|
|
|
|
|
2008-07-23 14:28:58 -06:00
|
|
|
void __init xen_init_spinlocks(void)
|
|
|
|
{
|
|
|
|
pv_lock_ops.spin_is_locked = xen_spin_is_locked;
|
|
|
|
pv_lock_ops.spin_is_contended = xen_spin_is_contended;
|
|
|
|
pv_lock_ops.spin_lock = xen_spin_lock;
|
2008-08-20 18:02:20 -06:00
|
|
|
pv_lock_ops.spin_lock_flags = xen_spin_lock_flags;
|
2008-07-23 14:28:58 -06:00
|
|
|
pv_lock_ops.spin_trylock = xen_spin_trylock;
|
|
|
|
pv_lock_ops.spin_unlock = xen_spin_unlock;
|
|
|
|
}
|
2008-08-20 18:02:19 -06:00
|
|
|
|
|
|
|
#ifdef CONFIG_XEN_DEBUG_FS
|
|
|
|
|
|
|
|
static struct dentry *d_spin_debug;
|
|
|
|
|
|
|
|
static int __init xen_spinlock_debugfs(void)
|
|
|
|
{
|
|
|
|
struct dentry *d_xen = xen_init_debugfs();
|
|
|
|
|
|
|
|
if (d_xen == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
d_spin_debug = debugfs_create_dir("spinlocks", d_xen);
|
|
|
|
|
|
|
|
debugfs_create_u8("zero_stats", 0644, d_spin_debug, &zero_stats);
|
|
|
|
|
|
|
|
debugfs_create_u32("timeout", 0644, d_spin_debug, &lock_timeout);
|
|
|
|
|
|
|
|
debugfs_create_u64("taken", 0444, d_spin_debug, &spinlock_stats.taken);
|
|
|
|
debugfs_create_u32("taken_slow", 0444, d_spin_debug,
|
|
|
|
&spinlock_stats.taken_slow);
|
|
|
|
debugfs_create_u32("taken_slow_nested", 0444, d_spin_debug,
|
|
|
|
&spinlock_stats.taken_slow_nested);
|
|
|
|
debugfs_create_u32("taken_slow_pickup", 0444, d_spin_debug,
|
|
|
|
&spinlock_stats.taken_slow_pickup);
|
|
|
|
debugfs_create_u32("taken_slow_spurious", 0444, d_spin_debug,
|
|
|
|
&spinlock_stats.taken_slow_spurious);
|
2008-08-20 18:02:20 -06:00
|
|
|
debugfs_create_u32("taken_slow_irqenable", 0444, d_spin_debug,
|
|
|
|
&spinlock_stats.taken_slow_irqenable);
|
2008-08-20 18:02:19 -06:00
|
|
|
|
|
|
|
debugfs_create_u64("released", 0444, d_spin_debug, &spinlock_stats.released);
|
|
|
|
debugfs_create_u32("released_slow", 0444, d_spin_debug,
|
|
|
|
&spinlock_stats.released_slow);
|
|
|
|
debugfs_create_u32("released_slow_kicked", 0444, d_spin_debug,
|
|
|
|
&spinlock_stats.released_slow_kicked);
|
|
|
|
|
|
|
|
debugfs_create_u64("time_spinning", 0444, d_spin_debug,
|
2008-08-20 18:02:21 -06:00
|
|
|
&spinlock_stats.time_spinning);
|
|
|
|
debugfs_create_u64("time_blocked", 0444, d_spin_debug,
|
|
|
|
&spinlock_stats.time_blocked);
|
2008-08-20 18:02:19 -06:00
|
|
|
debugfs_create_u64("time_total", 0444, d_spin_debug,
|
2008-08-20 18:02:21 -06:00
|
|
|
&spinlock_stats.time_total);
|
2008-08-20 18:02:19 -06:00
|
|
|
|
|
|
|
xen_debugfs_create_u32_array("histo_total", 0444, d_spin_debug,
|
2008-08-20 18:02:21 -06:00
|
|
|
spinlock_stats.histo_spin_total, HISTO_BUCKETS + 1);
|
2008-08-20 18:02:19 -06:00
|
|
|
xen_debugfs_create_u32_array("histo_spinning", 0444, d_spin_debug,
|
2008-08-20 18:02:21 -06:00
|
|
|
spinlock_stats.histo_spin_spinning, HISTO_BUCKETS + 1);
|
|
|
|
xen_debugfs_create_u32_array("histo_blocked", 0444, d_spin_debug,
|
|
|
|
spinlock_stats.histo_spin_blocked, HISTO_BUCKETS + 1);
|
2008-08-20 18:02:19 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fs_initcall(xen_spinlock_debugfs);
|
|
|
|
|
|
|
|
#endif /* CONFIG_XEN_DEBUG_FS */
|