Commit 9b0c290e78d667e6a483bde8c7cef7dd15f49017

Authored by Eric Dumazet
Committed by David S. Miller
1 parent 7b5edbc4cf

fib: introduce fib_alias_accessed() helper

Perf tools session at NFWS 2010 pointed out a false sharing on struct
fib_alias that can be avoided pretty easily, if we set FA_S_ACCESSED bit
only if needed (ie : not already set)

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 4 changed files with 12 additions and 3 deletions Side-by-side Diff

... ... @@ -335,7 +335,8 @@
335 335 if (!next_fi->fib_nh[0].nh_gw ||
336 336 next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK)
337 337 continue;
338   - fa->fa_state |= FA_S_ACCESSED;
  338 +
  339 + fib_alias_accessed(fa);
339 340  
340 341 if (fi == NULL) {
341 342 if (next_fi != res->fi)
net/ipv4/fib_lookup.h
... ... @@ -17,6 +17,13 @@
17 17  
18 18 #define FA_S_ACCESSED 0x01
19 19  
  20 +/* Dont write on fa_state unless needed, to keep it shared on all cpus */
  21 +static inline void fib_alias_accessed(struct fib_alias *fa)
  22 +{
  23 + if (!(fa->fa_state & FA_S_ACCESSED))
  24 + fa->fa_state |= FA_S_ACCESSED;
  25 +}
  26 +
20 27 /* Exported by fib_semantics.c */
21 28 extern int fib_semantic_match(struct list_head *head,
22 29 const struct flowi *flp,
net/ipv4/fib_semantics.c
... ... @@ -901,7 +901,7 @@
901 901 if (fa->fa_scope < flp->fl4_scope)
902 902 continue;
903 903  
904   - fa->fa_state |= FA_S_ACCESSED;
  904 + fib_alias_accessed(fa);
905 905  
906 906 err = fib_props[fa->fa_type].error;
907 907 if (err == 0) {
... ... @@ -1838,7 +1838,8 @@
1838 1838 if (!next_fi->fib_nh[0].nh_gw ||
1839 1839 next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK)
1840 1840 continue;
1841   - fa->fa_state |= FA_S_ACCESSED;
  1841 +
  1842 + fib_alias_accessed(fa);
1842 1843  
1843 1844 if (fi == NULL) {
1844 1845 if (next_fi != res->fi)