提交 66a2f7fd 编写于 作者: S Stephen Hemminger 提交者: David S. Miller

[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: NStephen Hemminger <stephen.hemminger@vyatta.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a6db9010
...@@ -85,6 +85,13 @@ endchoice ...@@ -85,6 +85,13 @@ endchoice
config IP_FIB_HASH config IP_FIB_HASH
def_bool ASK_IP_FIB_HASH || !IP_ADVANCED_ROUTER def_bool ASK_IP_FIB_HASH || !IP_ADVANCED_ROUTER
config IP_FIB_TRIE_STATS
bool "FIB TRIE statistics"
depends on IP_FIB_TRIE
---help---
Keep track of statistics on structure of FIB TRIE table.
Useful for testing and measuring TRIE performance.
config IP_MULTIPLE_TABLES config IP_MULTIPLE_TABLES
bool "IP: policy routing" bool "IP: policy routing"
depends on IP_ADVANCED_ROUTER depends on IP_ADVANCED_ROUTER
......
...@@ -82,7 +82,6 @@ ...@@ -82,7 +82,6 @@
#include <net/ip_fib.h> #include <net/ip_fib.h>
#include "fib_lookup.h" #include "fib_lookup.h"
#undef CONFIG_IP_FIB_TRIE_STATS
#define MAX_STAT_DEPTH 32 #define MAX_STAT_DEPTH 32
#define KEYLENGTH (8*sizeof(t_key)) #define KEYLENGTH (8*sizeof(t_key))
...@@ -2119,20 +2118,22 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat) ...@@ -2119,20 +2118,22 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
bytes += sizeof(struct node *) * pointers; bytes += sizeof(struct node *) * pointers;
seq_printf(seq, "Null ptrs: %u\n", stat->nullpointers); seq_printf(seq, "Null ptrs: %u\n", stat->nullpointers);
seq_printf(seq, "Total size: %u kB\n", (bytes + 1023) / 1024); seq_printf(seq, "Total size: %u kB\n", (bytes + 1023) / 1024);
}
#ifdef CONFIG_IP_FIB_TRIE_STATS #ifdef CONFIG_IP_FIB_TRIE_STATS
seq_printf(seq, "Counters:\n---------\n"); static void trie_show_usage(struct seq_file *seq,
seq_printf(seq,"gets = %d\n", t->stats.gets); const struct trie_use_stats *stats)
seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); {
seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed); seq_printf(seq, "\nCounters:\n---------\n");
seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss); seq_printf(seq,"gets = %u\n", stats->gets);
seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit); seq_printf(seq,"backtracks = %u\n", stats->backtrack);
seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped); seq_printf(seq,"semantic match passed = %u\n", stats->semantic_match_passed);
#ifdef CLEAR_STATS seq_printf(seq,"semantic match miss = %u\n", stats->semantic_match_miss);
memset(&(t->stats), 0, sizeof(t->stats)); seq_printf(seq,"null node hit= %u\n", stats->null_node_hit);
#endif seq_printf(seq,"skipped node resize = %u\n\n", stats->resize_node_skipped);
#endif /* CONFIG_IP_FIB_TRIE_STATS */
} }
#endif /* CONFIG_IP_FIB_TRIE_STATS */
static int fib_triestat_seq_show(struct seq_file *seq, void *v) static int fib_triestat_seq_show(struct seq_file *seq, void *v)
{ {
...@@ -2163,12 +2164,18 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v) ...@@ -2163,12 +2164,18 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "Local:\n"); seq_printf(seq, "Local:\n");
trie_collect_stats(trie_local, stat); trie_collect_stats(trie_local, stat);
trie_show_stats(seq, stat); trie_show_stats(seq, stat);
#ifdef CONFIG_IP_FIB_TRIE_STATS
trie_show_usage(seq, &trie_local->stats);
#endif
} }
if (trie_main) { if (trie_main) {
seq_printf(seq, "Main:\n"); seq_printf(seq, "Main:\n");
trie_collect_stats(trie_main, stat); trie_collect_stats(trie_main, stat);
trie_show_stats(seq, stat); trie_show_stats(seq, stat);
#ifdef CONFIG_IP_FIB_TRIE_STATS
trie_show_usage(seq, &trie_main->stats);
#endif
} }
kfree(stat); kfree(stat);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册