diff options
author | David Daney <ddaney@caviumnetworks.com> | 2010-02-04 14:31:49 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-02-27 06:53:42 -0500 |
commit | 500c2e1fdbcc2b273bd4c695a9b8ac8196f61614 (patch) | |
tree | f24c80f609a739beed194fd5c66abf9bc48ce0d6 /arch/mips/include/asm/spinlock_types.h | |
parent | e275ed5ee94b358964a0dae1c8b49f0bff260b60 (diff) |
MIPS: Optimize spinlocks.
The current locking mechanism uses a ll/sc sequence to release a
spinlock. This is slower than a wmb() followed by a store to unlock.
The branching forward to .subsection 2 on sc failure slows down the
contended case. So we get rid of that part too.
Since we are now working on naturally aligned u16 values, we can get
rid of a masking operation as the LHU already does the right thing.
The ANDI are reversed for better scheduling on multi-issue CPUs
On a 12 CPU 750MHz Octeon cn5750 this patch improves ipv4 UDP packet
forwarding rates from 3.58*10^6 PPS to 3.99*10^6 PPS, or about 11%.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
To: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/937/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/include/asm/spinlock_types.h')
-rw-r--r-- | arch/mips/include/asm/spinlock_types.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/arch/mips/include/asm/spinlock_types.h b/arch/mips/include/asm/spinlock_types.h index ee197c2f9c9..c52f36013a9 100644 --- a/arch/mips/include/asm/spinlock_types.h +++ b/arch/mips/include/asm/spinlock_types.h | |||
@@ -5,16 +5,28 @@ | |||
5 | # error "please don't include this file directly" | 5 | # error "please don't include this file directly" |
6 | #endif | 6 | #endif |
7 | 7 | ||
8 | typedef struct { | 8 | #include <linux/types.h> |
9 | |||
10 | #include <asm/byteorder.h> | ||
11 | |||
12 | typedef union { | ||
9 | /* | 13 | /* |
10 | * bits 0..13: serving_now | 14 | * bits 0..15 : serving_now |
11 | * bits 14 : junk data | 15 | * bits 16..31 : ticket |
12 | * bits 15..28: ticket | ||
13 | */ | 16 | */ |
14 | unsigned int lock; | 17 | u32 lock; |
18 | struct { | ||
19 | #ifdef __BIG_ENDIAN | ||
20 | u16 ticket; | ||
21 | u16 serving_now; | ||
22 | #else | ||
23 | u16 serving_now; | ||
24 | u16 ticket; | ||
25 | #endif | ||
26 | } h; | ||
15 | } arch_spinlock_t; | 27 | } arch_spinlock_t; |
16 | 28 | ||
17 | #define __ARCH_SPIN_LOCK_UNLOCKED { 0 } | 29 | #define __ARCH_SPIN_LOCK_UNLOCKED { .lock = 0 } |
18 | 30 | ||
19 | typedef struct { | 31 | typedef struct { |
20 | volatile unsigned int lock; | 32 | volatile unsigned int lock; |