netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: avoid reloads in SNMP_UPD_PO_STATS
@ 2012-08-05  6:26 Eric Dumazet
  2012-08-06 20:40 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2012-08-05  6:26 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

Avoid two instructions to reload dev->nd_net->mib.ip_statistics pointer,
unsing a temp variable, in ip_rcv(), ip_output() paths for example.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/snmp.h |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/net/snmp.h b/include/net/snmp.h
index 0147b90..7159626 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -154,13 +154,15 @@ struct linux_xfrm_mib {
  */
 #define SNMP_UPD_PO_STATS(mib, basefield, addend)	\
 	do { \
-		this_cpu_inc(mib[0]->mibs[basefield##PKTS]);		\
-		this_cpu_add(mib[0]->mibs[basefield##OCTETS], addend);	\
+		__typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs;	\
+		this_cpu_inc(ptr[basefield##PKTS]);		\
+		this_cpu_add(ptr[basefield##OCTETS], addend);	\
 	} while (0)
 #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend)	\
 	do { \
-		__this_cpu_inc(mib[0]->mibs[basefield##PKTS]);		\
-		__this_cpu_add(mib[0]->mibs[basefield##OCTETS], addend);	\
+		__typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs;	\
+		__this_cpu_inc(ptr[basefield##PKTS]);		\
+		__this_cpu_add(ptr[basefield##OCTETS], addend);	\
 	} while (0)
 
 

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

* Re: [PATCH] net: avoid reloads in SNMP_UPD_PO_STATS
  2012-08-05  6:26 [PATCH] net: avoid reloads in SNMP_UPD_PO_STATS Eric Dumazet
@ 2012-08-06 20:40 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-08-06 20:40 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sun, 05 Aug 2012 08:26:13 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> Avoid two instructions to reload dev->nd_net->mib.ip_statistics pointer,
> unsing a temp variable, in ip_rcv(), ip_output() paths for example.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied to net-next

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

end of thread, other threads:[~2012-08-06 20:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-05  6:26 [PATCH] net: avoid reloads in SNMP_UPD_PO_STATS Eric Dumazet
2012-08-06 20:40 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).