NET : align inet_protos[] on SMP
Subsystems (2)
PATCH 1/1 NET : align inet_protos[] on SMP
As IPPROTO_TCP is 6, it makes sense to make sure inet_protos[] array is properly cache line aligned to avoid false sharing on SMP.
c0680540 b peer_totalc0680544 b inet_peer_unused_headc0680560 B inet_protos
On i386 this example, we can see that inet_protos[IPPROTO_TCP] shares a potentially hot (and modified) cache line.
net/ipv4/protocol.c +1 -1
@@ -45,7 +45,7 @@ #include <net/udp.h>#include <net/ipip.h> #include <linux/igmp.h> -struct net_protocol *inet_protos[MAX_INET_PROTOS ]; +struct net_protocol *inet_protos[MAX_INET_PROTOS ]____cacheline_aligned_in_smp ;static DEFINE_SPINLOCK (inet_proto_lock);/*
From: Eric Dumazet <[email protected]>
Date: Tue, 27 Mar 2007 15:47:04 +0200
Quoted 9 lines
As
IPPROTO_TCPis 6, it makes sense to make sure inet_protos[] array is properly cache line aligned to avoid false sharing on SMP.
c0680540bpeer_totalc0680544binet_peer_unused_headc0680560Binet_protosOn i386 this example, we can see that inet_protos[IPPROTO_TCP] shares a potentially hot (and modified) cache line.
Signed-off-by Eric Dumazet <[email protected]>
Applied, thanks again Eric.
We could probably add some const markings to these things as well.