]> git.baikalelectronics.ru Git - kernel.git/commit
net: reorder struct Qdisc for better SMP performance
authorEric Dumazet <dada1@cosmosbay.com>
Fri, 20 Mar 2009 08:33:32 +0000 (01:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Mar 2009 08:33:32 +0000 (01:33 -0700)
commit3064a54a773f5c0e56e7be230a4f74aa12bab832
treea38240220f71ac128576cd8f432248442bac2deb
parentd1487ea22a5caed8b0e261fdfc67a275883e3833
net: reorder struct Qdisc for better SMP performance

dev_queue_xmit() needs to dirty fields "state", "q", "bstats" and "qstats"

On x86_64 arch, they currently span three cache lines, involving more
cache line ping pongs than necessary, making longer holding of queue spinlock.

We can reduce this to one cache line, by grouping all read-mostly fields
at the beginning of structure. (Or should I say, all highly modified fields
at the end :) )

Before patch :

offsetof(struct Qdisc, state)=0x38
offsetof(struct Qdisc, q)=0x48
offsetof(struct Qdisc, bstats)=0x80
offsetof(struct Qdisc, qstats)=0x90
sizeof(struct Qdisc)=0xc8

After patch :

offsetof(struct Qdisc, state)=0x80
offsetof(struct Qdisc, q)=0x88
offsetof(struct Qdisc, bstats)=0xa0
offsetof(struct Qdisc, qstats)=0xac
sizeof(struct Qdisc)=0xc0

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/gen_stats.h
include/net/sch_generic.h