Commit d25398df59b561a26cb4000ceb4dea8a3ff94d22

Authored by Eric Dumazet
Committed by David S. Miller
1 parent 9eb43e7653

net: avoid reloads in SNMP_UPD_PO_STATS

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff

... ... @@ -154,13 +154,15 @@
154 154 */
155 155 #define SNMP_UPD_PO_STATS(mib, basefield, addend) \
156 156 do { \
157   - this_cpu_inc(mib[0]->mibs[basefield##PKTS]); \
158   - this_cpu_add(mib[0]->mibs[basefield##OCTETS], addend); \
  157 + __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \
  158 + this_cpu_inc(ptr[basefield##PKTS]); \
  159 + this_cpu_add(ptr[basefield##OCTETS], addend); \
159 160 } while (0)
160 161 #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
161 162 do { \
162   - __this_cpu_inc(mib[0]->mibs[basefield##PKTS]); \
163   - __this_cpu_add(mib[0]->mibs[basefield##OCTETS], addend); \
  163 + __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \
  164 + __this_cpu_inc(ptr[basefield##PKTS]); \
  165 + __this_cpu_add(ptr[basefield##OCTETS], addend); \
164 166 } while (0)
165 167  
166 168