080-23-fib_trie-Use-empty_children-instead-of-counting-empt.patch 1023 B

12345678910111213141516171819202122232425262728293031323334
  1. From: Alexander Duyck <alexander.h.duyck@redhat.com>
  2. Date: Thu, 22 Jan 2015 15:51:33 -0800
  3. Subject: [PATCH] fib_trie: Use empty_children instead of counting empty nodes
  4. in stats collection
  5. It doesn't make much sense to count the pointers ourselves when
  6. empty_children already has a count for the number of NULL pointers stored
  7. in the tnode. As such save ourselves the cycles and just use
  8. empty_children.
  9. Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
  10. Signed-off-by: David S. Miller <davem@davemloft.net>
  11. ---
  12. --- a/net/ipv4/fib_trie.c
  13. +++ b/net/ipv4/fib_trie.c
  14. @@ -1954,16 +1954,10 @@ static void trie_collect_stats(struct tr
  15. hlist_for_each_entry_rcu(li, &n->list, hlist)
  16. ++s->prefixes;
  17. } else {
  18. - unsigned long i;
  19. -
  20. s->tnodes++;
  21. if (n->bits < MAX_STAT_DEPTH)
  22. s->nodesizes[n->bits]++;
  23. -
  24. - for (i = tnode_child_length(n); i--;) {
  25. - if (!rcu_access_pointer(n->child[i]))
  26. - s->nullpointers++;
  27. - }
  28. + s->nullpointers += n->empty_children;
  29. }
  30. }
  31. rcu_read_unlock();