__exit_idle();
}
--#ifdef CONFIG_HOTPLUG_CPU
--DECLARE_PER_CPU(int, cpu_state);
--
--#include <linux/nmi.h>
--/* We halt the CPU with physical CPU hotplug */
--static inline void play_dead(void)
--{
-- idle_task_exit();
-- c1e_remove_cpu(raw_smp_processor_id());
--
-- mb();
-- /* Ack it */
-- __get_cpu_var(cpu_state) = CPU_DEAD;
--
-- local_irq_disable();
-- /* mask all interrupts, flush any and all caches, and halt */
-- wbinvd_halt();
--}
--#else
++#ifndef CONFIG_SMP
static inline void play_dead(void)
{
BUG();
}
--#endif /* CONFIG_HOTPLUG_CPU */
++#endif
/*
* The idle thread. There's no useful work to be
if (!p || p == current || p->state == TASK_RUNNING)
return 0;
stack = (unsigned long)task_stack_page(p);
- - if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE)
+ + if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
return 0;
fp = *(u64 *)(p->thread.sp);
do {
if (fp < (unsigned long)stack ||
- - fp > (unsigned long)stack+THREAD_SIZE)
+ + fp >= (unsigned long)stack+THREAD_SIZE)
return 0;
ip = *(u64 *)(fp+8);
if (!in_sched_functions(ip))
#ifdef CONFIG_X86_32
# define LOCK_PTR_REG "a"
++ # define REG_PTR_MODE "k"
#else
# define LOCK_PTR_REG "D"
++ # define REG_PTR_MODE "q"
#endif
#if defined(CONFIG_X86_32) && \
* much between them in performance though, especially as locks are out of line.
*/
#if (NR_CPUS < 256)
-- static inline int __ticket_spin_is_locked(raw_spinlock_t *lock)
-- {
-- int tmp = ACCESS_ONCE(lock->slock);
--
-- return (((tmp >> 8) & 0xff) != (tmp & 0xff));
-- }
--
-- static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
-- {
-- int tmp = ACCESS_ONCE(lock->slock);
--
-- return (((tmp >> 8) - tmp) & 0xff) > 1;
-- }
++ #define TICKET_SHIFT 8
static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
{
static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
{
-- int tmp;
-- short new;
++ int tmp, new;
-- asm volatile("movw %2,%w0\n\t"
++ asm volatile("movzwl %2, %0\n\t"
"cmpb %h0,%b0\n\t"
++ "leal 0x100(%" REG_PTR_MODE "0), %1\n\t"
"jne 1f\n\t"
-- "movw %w0,%w1\n\t"
-- "incb %h1\n\t"
LOCK_PREFIX "cmpxchgw %w1,%2\n\t"
"1:"
"sete %b1\n\t"
"movzbl %b1,%0\n\t"
-- : "=&a" (tmp), "=Q" (new), "+m" (lock->slock)
++ : "=&a" (tmp), "=&q" (new), "+m" (lock->slock)
:
: "memory", "cc");
: "memory", "cc");
}
#else
-- static inline int __ticket_spin_is_locked(raw_spinlock_t *lock)
-- {
-- int tmp = ACCESS_ONCE(lock->slock);
--
-- return (((tmp >> 16) & 0xffff) != (tmp & 0xffff));
-- }
--
-- static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
-- {
-- int tmp = ACCESS_ONCE(lock->slock);
--
-- return (((tmp >> 16) - tmp) & 0xffff) > 1;
-- }
++ #define TICKET_SHIFT 16
static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
{
/* don't need lfence here, because loads are in-order */
"jmp 1b\n"
"2:"
-- : "+Q" (inc), "+m" (lock->slock), "=r" (tmp)
++ : "+r" (inc), "+m" (lock->slock), "=&r" (tmp)
:
: "memory", "cc");
}
"movl %0,%1\n\t"
"roll $16, %0\n\t"
"cmpl %0,%1\n\t"
++ "leal 0x00010000(%" REG_PTR_MODE "0), %1\n\t"
"jne 1f\n\t"
-- "addl $0x00010000, %1\n\t"
LOCK_PREFIX "cmpxchgl %1,%2\n\t"
"1:"
"sete %b1\n\t"
"movzbl %b1,%0\n\t"
-- : "=&a" (tmp), "=r" (new), "+m" (lock->slock)
++ : "=&a" (tmp), "=&q" (new), "+m" (lock->slock)
:
: "memory", "cc");
}
#endif
- #define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
++ static inline int __ticket_spin_is_locked(raw_spinlock_t *lock)
++ {
++ int tmp = ACCESS_ONCE(lock->slock);
++
++ return !!(((tmp >> TICKET_SHIFT) ^ tmp) & ((1 << TICKET_SHIFT) - 1));
++ }
++
++ static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
++ {
++ int tmp = ACCESS_ONCE(lock->slock);
++
++ return (((tmp >> TICKET_SHIFT) - tmp) & ((1 << TICKET_SHIFT) - 1)) > 1;
++ }
+
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
-
#ifdef CONFIG_PARAVIRT
/*
* Define virtualization-friendly old-style lock byte lock, for use in
{
__ticket_spin_unlock(lock);
}
++
++static __always_inline void __raw_spin_lock_flags(raw_spinlock_t *lock,
++ unsigned long flags)
++{
++ __raw_spin_lock(lock);
++}
++
#endif /* CONFIG_PARAVIRT */
static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)