i386 rw_semaphore improvements
Subsystems (4)
PATCH 1/1 i386 rw_semaphore improvements
This patch (made against linux-2.4.4-pre5) makes several changes to the rwsem implementation:
(1) It fixes the bug found by Andrea by changing how processes that are waiting on the semaphore are managed.
(2) As a result of (1), the wake_up_ctx() stuff is no longer used and has been removed.
(3) Contention handling in this rwsem implementation is now faster as a result of (1). The increase from slightly to a fair amount depending on the situation.
(4) The asm-i386/rwsem-spin.h implementation is now gone. i386 CPUs will use the generic implementation instead.
(5) The asm-i386/rwsem-xadd.h has been subsumed by asm-i386/rwsem.h since there's now only one i386-arch optimised version.
(6) Some alpha-arch fixes have been applied.
(7) The sparc64-arch optimised implementation has been updated to fall in
line with (1).
(8) The generic implementation now has a single spinlock which it uses both for waiting process management and for guarding access to the counter.
I'll have a look tomorrow at making the generic spinlock implementation non-inline.
David
arch/alpha/kernel/alpha_ksyms.c +0 -7
@@ -173,13 +173,6 @@EXPORT_SYMBOL (down_interruptible);EXPORT_SYMBOL (down_trylock);EXPORT_SYMBOL (up); -EXPORT_SYMBOL (__down_read_failed); -EXPORT_SYMBOL (__down_write_failed); -EXPORT_SYMBOL (__rwsem_wake); -EXPORT_SYMBOL (down_read); -EXPORT_SYMBOL (down_write); -EXPORT_SYMBOL (up_read); -EXPORT_SYMBOL (up_write);/* * SMP-specific symbols.
arch/i386/config.in +4 -2
@@ -9,8 +9,6 @@ define_bool CONFIG_SBUS n define_bool CONFIG_UID16 y -define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n -define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y mainmenu_option next_comment comment 'Code maturity level options'
@@ -52,6 +50,8 @@ define_bool CONFIG_X86_CMPXCHG n define_bool CONFIG_X86_XADD n define_int CONFIG_X86_L1_CACHE_SHIFT 4 + define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y + define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n else define_bool CONFIG_X86_WP_WORKS_OK y define_bool CONFIG_X86_INVLPG y
@@ -59,6 +59,8 @@ define_bool CONFIG_X86_XADD y define_bool CONFIG_X86_BSWAP y define_bool CONFIG_X86_POPAD_OK y + define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n + define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y fi if [ "$CONFIG_M486" = "y" ]; then define_int CONFIG_X86_L1_CACHE_SHIFT 4
arch/i386/kernel/i386_ksyms.c +2 -0
@@ -80,9 +80,11 @@EXPORT_SYMBOL_NOVERS (__down_failed_interruptible);EXPORT_SYMBOL_NOVERS (__down_failed_trylock);EXPORT_SYMBOL_NOVERS (__up_wakeup); +#ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM EXPORT_SYMBOL_NOVERS (__rwsem_down_write_failed);EXPORT_SYMBOL_NOVERS (__rwsem_down_read_failed);EXPORT_SYMBOL_NOVERS (__rwsem_wake); +#endif /* Networking helper routines. */ EXPORT_SYMBOL (csum_partial_copy_generic);/* Delay loops */
include/asm-i386/rwsem-spin.h +0 -318
318 lines not on this page · raw message
include/asm-i386/rwsem-xadd.h +0 -194
194 lines not on this page · raw message
include/asm-i386/rwsem.h +184 -6
204 lines not on this page · raw message
include/asm-sparc64/rwsem.h +6 -4
@@ -13,6 +13,8 @@ #ifdef __KERNEL__ +struct rwsem_waiter; + struct rw_semaphore { signed int count; #define RWSEM_UNLOCKED_VALUE 0x00000000
@@ -21,13 +23,13 @@#define RWSEM_WAITING_BIAS 0xffff0000#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) -wait_queue_head_t wait; -#define RWSEM_WAITING_FOR_READ WQ_FLAG_CONTEXT_0/* bits to use in wait_queue_t.flags */ -#define RWSEM_WAITING_FOR_WRITE WQ_FLAG_CONTEXT_1 +spinlock_t wait_lock; +struct rwsem_waiter *wait_front; +struct rwsem_waiter **wait_back; };#define __RWSEM_INITIALIZER (name) \ -{ RWSEM_UNLOCKED_VALUE, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) } +{ RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, NULL, &(name).wait_front }#define DECLARE_RWSEM (name) \ struct rw_semaphore name = __RWSEM_INITIALIZER(name)
include/linux/rwsem-spinlock.h +20 -22
129 lines not on this page · raw message
include/linux/rwsem.h +4 -3
@@ -38,9 +38,11 @@#ifdef __KERNEL__ +#include <linux/types.h> #include <asm/system.h> #include <asm/atomic.h> -#include <linux/wait.h> + +struct rw_semaphore ;/* defined contention handler functions for the generic case * - these are also used for the exchange-and-add based algorithm
@@ -60,8 +62,7 @@#ifndef rwsemtrace#if RWSEM_DEBUG -#include <asm/current.h> -#define rwsemtrace (SEM ,FMT ) do { if ((SEM)->debug) printk("[%d] "FMT"(count=%08lx)\n",current->pid,(SEM)->count); } while(0) +extern void FASTCALL (rwsemtrace (struct rw_semaphore *sem,const char *str));#else #define rwsemtrace (SEM ,FMT )#endif
include/linux/sched.h +0 -4
@@ -548,8 +548,6 @@extern void FASTCALL (__wake_up (wait_queue_head_t *q,unsigned int mode,int nr));extern void FASTCALL (__wake_up_sync (wait_queue_head_t *q,unsigned int mode,int nr)); -extern int FASTCALL (__wake_up_ctx (wait_queue_head_t *q,unsigned int mode,int count,int bit)); -extern int FASTCALL (__wake_up_sync_ctx (wait_queue_head_t *q,unsigned int mode,int count,int bit));extern void FASTCALL (sleep_on (wait_queue_head_t *q));extern long FASTCALL (sleep_on_timeout (wait_queue_head_t *q,signed long timeout));
@@ -568,8 +566,6 @@#define wake_up_interruptible_all (x) __wake_up((x),TASK_INTERRUPTIBLE, 0)#define wake_up_interruptible_sync (x) __wake_up_sync((x),TASK_INTERRUPTIBLE, 1)#define wake_up_interruptible_sync_nr (x) __wake_up_sync((x),TASK_INTERRUPTIBLE, nr) -#define wake_up_ctx (x,count,bit) __wake_up_ctx((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE,count,bit) -#define wake_up_sync_ctx (x,count,bit) __wake_up_ctx((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE,count,bit)asmlinkage long sys_wait4 (pid_t pid,unsigned int * stat_addr,int options,struct rusage * ru);extern int in_group_p (gid_t );
include/linux/wait.h +0 -8
@@ -26,14 +26,6 @@struct __wait_queue {unsigned int flags;#define WQ_FLAG_EXCLUSIVE 0x01 -#define WQ_FLAG_CONTEXT_0 8/* context specific flag bit numbers */ -#define WQ_FLAG_CONTEXT_1 9 -#define WQ_FLAG_CONTEXT_2 10 -#define WQ_FLAG_CONTEXT_3 11 -#define WQ_FLAG_CONTEXT_4 12 -#define WQ_FLAG_CONTEXT_5 13 -#define WQ_FLAG_CONTEXT_6 14 -#define WQ_FLAG_CONTEXT_7 15struct task_struct * task;struct list_head task_list;#if WAITQUEUE_DEBUG
kernel/sched.c +0 -69
75 lines not on this page · raw message
lib/rwsem.c +140 -58
275 lines not on this page · raw message