linux/net
Eric Dumazet 2f970d8357 [IPV4]: rt_cache_stat can be statically defined
Using __get_cpu_var(obj) is slightly faster than per_cpu_ptr(obj, 
raw_smp_processor_id()).

1) Smaller code and memory use
For static and small objects, DEFINE_PER_CPU(type, object) is preferred over a 
alloc_percpu() : Better and smaller code to access them, and no extra memory 
(storing the pointer, and the percpu array of pointers)

x86_64 code before patch

mov    1237577(%rip),%rax        # ffffffff803e5990 <rt_cache_stat>
not    %rax  # part of per_cpu machinery
mov    %gs:0x3c,%edx # get cpu number
movslq %edx,%rdx # extend 32 bits cpu number to 64 bits
mov    (%rax,%rdx,8),%rax # get the pointer for this cpu
incl   0x38(%rax)

x86_64 code after patch

mov    $per_cpu__rt_cache_stat,%rdx
mov    %gs:0x48,%rax # get percpu data offset
incl   0x38(%rax,%rdx,1)

2) False sharing avoidance for SMP :
For a small NR_CPUS, the array of per cpu pointers allocated in alloc_percpu() 
can be <= 32 bytes. This let slab code gives a part of a cache line. If the 
other part of this 64 bytes (or 128 bytes) cache line is used by a mostly 
written object, we can have false sharing and expensive per_cpu_ptr() operations.

Size of rt_cache_stat is 64 bytes, so this patch is not a danger of a too big 
increase of bss (in UP mode) or static per_cpu data for SMP 
(PERCPU_ENOUGH_ROOM is currently 32768 bytes)

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-01-17 02:54:36 -08:00
..
802 [PATCH] tiny: Trim non-IPX builds 2006-01-08 20:14:10 -08:00
8021q [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
appletalk [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
atm [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
ax25 [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
bluetooth [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
bridge [NETFILTER] x_tables: Abstraction layer for {ip,ip6,arp}_tables 2006-01-12 14:06:43 -08:00
core [NET]: Fix whitespace issues in net/core/filter.c 2006-01-17 02:25:52 -08:00
dccp [NETFILTER]: Handle NAT in IPsec policy checks 2006-01-07 12:57:37 -08:00
decnet [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
econet [ECONET]: Use macro for spinlock_t definition. 2006-01-04 13:56:08 -08:00
ethernet [NET]: Use newer is_multicast_ether_addr() in some files 2006-01-06 13:05:58 -08:00
ieee80211 [PATCH] Unlinline a bunch of other functions 2006-01-14 18:27:06 -08:00
ipv4 [IPV4]: rt_cache_stat can be statically defined 2006-01-17 02:54:36 -08:00
ipv6 [NETFILTER] ip6tables: whitespace and indent cosmetic cleanup 2006-01-17 02:39:39 -08:00
ipx [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
irda [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
key [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
lapb [NET]: Kill skb->list 2005-08-29 15:31:14 -07:00
llc [NET]: Add a dev_ioctl() fallback to sock_ioctl() 2006-01-03 14:18:33 -08:00
netfilter [PATCH] Unlinline a bunch of other functions 2006-01-14 18:27:06 -08:00
netlink [PATCH] genetlink: don't touch module ref count 2006-01-13 13:06:40 -08:00
netrom [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
packet [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
rose [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
rxrpc [RXRPC]: Decrease number of pointer derefs in connection.c 2006-01-10 13:07:44 -08:00
sched [PKT_SCHED] sch_prio: fix qdisc bands init 2006-01-17 02:24:26 -08:00
sctp [NET]: Use NIP6_FMT in kernel.h 2006-01-13 14:29:07 -08:00
sunrpc [NET]: Remove more unneeded typecasts on *malloc() 2006-01-11 16:32:14 -08:00
tipc [PATCH] genetlink: don't touch module ref count 2006-01-13 13:06:40 -08:00
unix [PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem 2006-01-09 15:59:24 -08:00
wanrouter [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
x25 [PATCH] capable/capability.h (net/) 2006-01-11 18:42:14 -08:00
xfrm [NET]: Change some "if (x) BUG();" to "BUG_ON(x);" 2006-01-09 14:16:18 -08:00
compat.c [PATCH] Fix 32bit sendmsg() flaw 2005-09-08 08:14:11 -07:00
Kconfig [TIPC] Initial merge 2006-01-12 14:06:31 -08:00
Makefile [TIPC] Initial merge 2006-01-12 14:06:31 -08:00
nonet.c [NET]: Fix sock_init() return value. 2006-01-03 13:11:17 -08:00
socket.c [NET]: Remove more unneeded typecasts on *malloc() 2006-01-11 16:32:14 -08:00
sysctl_net.c [NET]: Fix "sysctl_net.c:36: error: 'core_table' undeclared here" 2005-10-03 14:16:34 -07:00
TUNABLE Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00