@@ -303,6 +303,7 @@ int _spin_trylock_recursive(struct spinlock_recursive *lock)
/* Don't allow overflow of recurse_cpu field. */
BUILD_BUG_ON(NR_CPUS > SPINLOCK_NO_CPU);
+ BUILD_BUG_ON(SPINLOCK_CPU_BITS > sizeof(lock->recurse_cpu) * 8);
BUILD_BUG_ON(SPINLOCK_RECURSE_BITS < 3);
check_lock(&lock->lock.debug, true);
@@ -6,16 +6,16 @@
#include <asm/spinlock.h>
#include <asm/types.h>
-#define SPINLOCK_CPU_BITS 12
+#define SPINLOCK_CPU_BITS 16
#ifdef CONFIG_DEBUG_LOCKS
union lock_debug {
- uint16_t val;
-#define LOCK_DEBUG_INITVAL 0xffff
+ uint32_t val;
+#define LOCK_DEBUG_INITVAL 0xffffffff
struct {
- uint16_t cpu:SPINLOCK_CPU_BITS;
-#define LOCK_DEBUG_PAD_BITS (14 - SPINLOCK_CPU_BITS)
- uint16_t :LOCK_DEBUG_PAD_BITS;
+ uint32_t cpu:SPINLOCK_CPU_BITS;
+#define LOCK_DEBUG_PAD_BITS (30 - SPINLOCK_CPU_BITS)
+ uint32_t :LOCK_DEBUG_PAD_BITS;
bool irq_safe:1;
bool unseen:1;
};
@@ -173,10 +173,10 @@ typedef struct spinlock {
struct spinlock_recursive {
struct spinlock lock;
- u16 recurse_cpu:SPINLOCK_CPU_BITS;
+ uint16_t recurse_cpu;
#define SPINLOCK_NO_CPU ((1u << SPINLOCK_CPU_BITS) - 1)
-#define SPINLOCK_RECURSE_BITS (16 - SPINLOCK_CPU_BITS)
- u16 recurse_cnt:SPINLOCK_RECURSE_BITS;
+#define SPINLOCK_RECURSE_BITS 8
+ uint8_t recurse_cnt;
#define SPINLOCK_MAX_RECURSE ((1u << SPINLOCK_RECURSE_BITS) - 1)
};
There is no real reason why the cpu fields of struct spinlock should be limited to 12 bits, now that there is a 2 byte padding hole after those fields. Make the related structures a little bit larger allowing 16 bits per cpu number, which is the limit imposed by spinlock_tickets_t. Signed-off-by: Juergen Gross <jgross@suse.com> --- xen/common/spinlock.c | 1 + xen/include/xen/spinlock.h | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-)