All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NET : align inet_protos[] on SMP
@ 2007-03-27 13:47 Eric Dumazet
  2007-03-27 21:20 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2007-03-27 13:47 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

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_total
c0680544 b inet_peer_unused_head
c0680560 B inet_protos

On i386 this example, we can see that inet_protos[IPPROTO_TCP] shares a potentially hot (and modified) cache line.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c
index da70fef..971ab93 100644
--- a/net/ipv4/protocol.c
+++ b/net/ipv4/protocol.c
@@ -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);
 
 /*

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] NET : align inet_protos[] on SMP
  2007-03-27 13:47 [PATCH] NET : align inet_protos[] on SMP Eric Dumazet
@ 2007-03-27 21:20 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-03-27 21:20 UTC (permalink / raw)
  To: dada1; +Cc: netdev

From: Eric Dumazet <dada1@cosmosbay.com>
Date: Tue, 27 Mar 2007 15:47:04 +0200

> 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_total
> c0680544 b inet_peer_unused_head
> c0680560 B inet_protos
> 
> On i386 this example, we can see that inet_protos[IPPROTO_TCP] shares a potentially hot (and modified) cache line.
> 
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

Applied, thanks again Eric.

We could probably add some const markings to these things as well.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-27 21:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-27 13:47 [PATCH] NET : align inet_protos[] on SMP Eric Dumazet
2007-03-27 21:20 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.