unsigned int cpu = smp_processor_id();
/* Don't allow overflow of recurse_cpu field. */
- BUILD_BUG_ON(NR_CPUS > 0xfffu);
+ BUILD_BUG_ON(NR_CPUS > SPINLOCK_NO_CPU);
check_lock(&lock->debug);
}
/* We support only fairly shallow recursion, else the counter overflows. */
- ASSERT(lock->recurse_cnt < 0xfu);
+ ASSERT(lock->recurse_cnt < SPINLOCK_MAX_RECURSE);
lock->recurse_cnt++;
return 1;
}
/* We support only fairly shallow recursion, else the counter overflows. */
- ASSERT(lock->recurse_cnt < 0xfu);
+ ASSERT(lock->recurse_cnt < SPINLOCK_MAX_RECURSE);
lock->recurse_cnt++;
}
{
if ( likely(--lock->recurse_cnt == 0) )
{
- lock->recurse_cpu = 0xfffu;
+ lock->recurse_cpu = SPINLOCK_NO_CPU;
spin_unlock(lock);
}
}
static struct lock_profile *__lock_profile_##name \
__used_section(".lockprofile.data") = \
&__lock_profile_data_##name
-#define _SPIN_LOCK_UNLOCKED(x) { { 0 }, 0xfffu, 0, _LOCK_DEBUG, x }
+#define _SPIN_LOCK_UNLOCKED(x) { { 0 }, SPINLOCK_NO_CPU, 0, _LOCK_DEBUG, x }
#define SPIN_LOCK_UNLOCKED _SPIN_LOCK_UNLOCKED(NULL)
#define DEFINE_SPINLOCK(l) \
spinlock_t l = _SPIN_LOCK_UNLOCKED(NULL); \
struct lock_profile_qhead { };
-#define SPIN_LOCK_UNLOCKED { { 0 }, 0xfffu, 0, _LOCK_DEBUG }
+#define SPIN_LOCK_UNLOCKED { { 0 }, SPINLOCK_NO_CPU, 0, _LOCK_DEBUG }
#define DEFINE_SPINLOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED
#define spin_lock_init_prof(s, l) spin_lock_init(&((s)->l))
typedef struct spinlock {
spinlock_tickets_t tickets;
u16 recurse_cpu:12;
+#define SPINLOCK_NO_CPU 0xfffu
u16 recurse_cnt:4;
+#define SPINLOCK_MAX_RECURSE 0xfu
struct lock_debug debug;
#ifdef LOCK_PROFILE
struct lock_profile *profile;