From a3946564b990b2bc6b8c0644221107ab313412be Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 8 Jan 2017 10:13:25 -0800 Subject: [PATCH] kernel - Reduce size of struct spinlock * Reduce the size of struct spinlock from 16 to 8 bytes. The description field was not being used (we use __func__ instead). This reduces structural bloat for a number of important structures, in particular reducing sizeof(struct vm_page) from 136 to 128 bytes. --- sys/sys/spinlock.h | 15 +++++++-------- sys/sys/spinlock2.h | 4 +++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/sys/spinlock.h b/sys/sys/spinlock.h index ecaba2ec55..de8295c8b5 100644 --- a/sys/sys/spinlock.h +++ b/sys/sys/spinlock.h @@ -38,20 +38,19 @@ * so structures using embedded spinlocks do not change size for SMP vs UP * builds. * - * DragonFly spinlocks use a chasing counter. A core desiring a spinlock - * does a atomic_fetchadd_int() on countb and then waits for counta to - * reach its value using MWAIT. Releasing the spinlock involves an - * atomic_add_int() on counta. If no MWAIT is available the core can spin - * waiting for the value to change which is still represented by a shared+ro - * cache entry. + * DragonFly spinlocks use a basic count/flag system. It has been shown to + * be the quickest way of doing things over time. Shared spinlocks are + * supported (and even relatively optimal). + * + * There is no description field. The wait description is pulled from + * __func__ if the lock cannot be instantly obtained. */ struct spinlock { int counta; int countb; - const char *descr; }; -#define SPINLOCK_INITIALIZER(head, d) { 0, 0, #d } +#define SPINLOCK_INITIALIZER(head, d) { 0, 0 } #define SPINLOCK_SHARED 0x80000000 #define SPINLOCK_EXCLWAIT 0x00100000 /* high bits counter */ diff --git a/sys/sys/spinlock2.h b/sys/sys/spinlock2.h index 81ba600dd5..2f235ce1aa 100644 --- a/sys/sys/spinlock2.h +++ b/sys/sys/spinlock2.h @@ -262,11 +262,13 @@ spin_unlock_shared(struct spinlock *spin) } static __inline void -spin_init(struct spinlock *spin, const char *descr) +spin_init(struct spinlock *spin, const char *descr __unused) { spin->counta = 0; spin->countb = 0; +#if 0 spin->descr = descr; +#endif } static __inline void -- 2.11.4.GIT