aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-01-13 00:23:17 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:01:56 -0500
commit66a2f7fd2fddee1ddc5d1d286cd832e50a97258e (patch)
tree5ed7bfa39716de4b1724873c1c797ed696ee0253 /net/ipv4
parenta6db9010922f2c02db2bbea8c17c50e451be38d9 (diff)
[IPV4] fib_trie: Add statistics.
The FIB TRIE code has a bunch of statistics, but the code is hidden behind an ifdef that was never implemented. Since it was dead code, it was broken as well. This patch fixes that by making it a config option. Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/Kconfig7
-rw-r--r--net/ipv4/fib_trie.c31
2 files changed, 26 insertions, 12 deletions
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 9f9fd2c6f6e2..24e2b7294bf8 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -85,6 +85,13 @@ endchoice
85config IP_FIB_HASH 85config IP_FIB_HASH
86 def_bool ASK_IP_FIB_HASH || !IP_ADVANCED_ROUTER 86 def_bool ASK_IP_FIB_HASH || !IP_ADVANCED_ROUTER
87 87
88config IP_FIB_TRIE_STATS
89 bool "FIB TRIE statistics"
90 depends on IP_FIB_TRIE
91 ---help---
92 Keep track of statistics on structure of FIB TRIE table.
93 Useful for testing and measuring TRIE performance.
94
88config IP_MULTIPLE_TABLES 95config IP_MULTIPLE_TABLES
89 bool "IP: policy routing" 96 bool "IP: policy routing"
90 depends on IP_ADVANCED_ROUTER 97 depends on IP_ADVANCED_ROUTER
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index e047de6873bd..2075eea7eea7 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -82,7 +82,6 @@
82#include <net/ip_fib.h> 82#include <net/ip_fib.h>
83#include "fib_lookup.h" 83#include "fib_lookup.h"
84 84
85#undef CONFIG_IP_FIB_TRIE_STATS
86#define MAX_STAT_DEPTH 32 85#define MAX_STAT_DEPTH 32
87 86
88#define KEYLENGTH (8*sizeof(t_key)) 87#define KEYLENGTH (8*sizeof(t_key))
@@ -2119,20 +2118,22 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
2119 bytes += sizeof(struct node *) * pointers; 2118 bytes += sizeof(struct node *) * pointers;
2120 seq_printf(seq, "Null ptrs: %u\n", stat->nullpointers); 2119 seq_printf(seq, "Null ptrs: %u\n", stat->nullpointers);
2121 seq_printf(seq, "Total size: %u kB\n", (bytes + 1023) / 1024); 2120 seq_printf(seq, "Total size: %u kB\n", (bytes + 1023) / 1024);
2121}
2122 2122
2123#ifdef CONFIG_IP_FIB_TRIE_STATS 2123#ifdef CONFIG_IP_FIB_TRIE_STATS
2124 seq_printf(seq, "Counters:\n---------\n"); 2124static void trie_show_usage(struct seq_file *seq,
2125 seq_printf(seq,"gets = %d\n", t->stats.gets); 2125 const struct trie_use_stats *stats)
2126 seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); 2126{
2127 seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed); 2127 seq_printf(seq, "\nCounters:\n---------\n");
2128 seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss); 2128 seq_printf(seq,"gets = %u\n", stats->gets);
2129 seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit); 2129 seq_printf(seq,"backtracks = %u\n", stats->backtrack);
2130 seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped); 2130 seq_printf(seq,"semantic match passed = %u\n", stats->semantic_match_passed);
2131#ifdef CLEAR_STATS 2131 seq_printf(seq,"semantic match miss = %u\n", stats->semantic_match_miss);
2132 memset(&(t->stats), 0, sizeof(t->stats)); 2132 seq_printf(seq,"null node hit= %u\n", stats->null_node_hit);
2133#endif 2133 seq_printf(seq,"skipped node resize = %u\n\n", stats->resize_node_skipped);
2134#endif /* CONFIG_IP_FIB_TRIE_STATS */
2135} 2134}
2135#endif /* CONFIG_IP_FIB_TRIE_STATS */
2136
2136 2137
2137static int fib_triestat_seq_show(struct seq_file *seq, void *v) 2138static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2138{ 2139{
@@ -2163,12 +2164,18 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2163 seq_printf(seq, "Local:\n"); 2164 seq_printf(seq, "Local:\n");
2164 trie_collect_stats(trie_local, stat); 2165 trie_collect_stats(trie_local, stat);
2165 trie_show_stats(seq, stat); 2166 trie_show_stats(seq, stat);
2167#ifdef CONFIG_IP_FIB_TRIE_STATS
2168 trie_show_usage(seq, &trie_local->stats);
2169#endif
2166 } 2170 }
2167 2171
2168 if (trie_main) { 2172 if (trie_main) {
2169 seq_printf(seq, "Main:\n"); 2173 seq_printf(seq, "Main:\n");
2170 trie_collect_stats(trie_main, stat); 2174 trie_collect_stats(trie_main, stat);
2171 trie_show_stats(seq, stat); 2175 trie_show_stats(seq, stat);
2176#ifdef CONFIG_IP_FIB_TRIE_STATS
2177 trie_show_usage(seq, &trie_main->stats);
2178#endif
2172 } 2179 }
2173 kfree(stat); 2180 kfree(stat);
2174 2181