From: Robert Olsson <Robert.Olsson@data.slu.se>
To: "David S. Miller" <davem@redhat.com>
Cc: Robert Olsson <Robert.Olsson@data.slu.se>,
sim@netnation.com, xerox@foonet.net, hadi@shell.cyberus.ca,
fw@deneb.enyo.de, netdev@oss.sgi.com, linux-net@vger.kernel.org
Subject: Re: Route cache performance under stress
Date: Tue, 17 Jun 2003 19:03:37 +0200 [thread overview]
Message-ID: <16111.18921.939537.978325@robur.slu.se> (raw)
In-Reply-To: <16105.43543.826589.672148@robur.slu.se>
> David S. Miller writes:
> Next, we should put similar metrics into fib_hash.c
A starting point...
Kernel hack enclosed and companion app from:
ftp://robur.slu.se/pub/Linux/net-development/fibstat
Just some hash metrics yet. Output below is from our DoS tests:
lookup_total == hash lookup/sec
zone_search == zones search/sec
chain_search == chain search/sec
lookup_total zone_search chain_search
0 0 0
0 0 0
0 0 0
475084 4513198 2454249
861704 8186188 4450394
867935 8245366 4480320
863319 8201514 4458924
864056 8208532 4463344
863788 8205986 4461238
861772 8186834 4449507
--- include/net/ip_fib.h.030617 2003-06-17 15:03:57.000000000 +0200
+++ include/net/ip_fib.h 2003-06-17 16:07:00.000000000 +0200
@@ -135,6 +135,21 @@
unsigned char tb_data[0];
};
+struct fib_stat
+{
+ unsigned int lookup_total;
+ unsigned int zone_search;
+ unsigned int chain_search;
+};
+
+extern struct fib_stat *fib_stat;
+#define FIB_STAT_INC(field) \
+ (per_cpu_ptr(fib_stat, smp_processor_id())->field++)
+
+
+extern int __init fib_stat_init(void);
+
+
#ifndef CONFIG_IP_MULTIPLE_TABLES
extern struct fib_table *ip_fib_local_table;
--- net/ipv4/fib_hash.c.030617 2003-06-15 23:02:21.000000000 +0200
+++ net/ipv4/fib_hash.c 2003-06-17 16:01:45.000000000 +0200
@@ -13,6 +13,11 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
+ *
+ *
+ * Fixes:
+ * Robert Olsson : Added statistics
+ *
*/
#include <linux/config.h>
@@ -107,6 +112,10 @@
struct fn_zone *fn_zone_list;
};
+
+struct fib_stat *fib_stat;
+
+
static __inline__ fn_hash_idx_t fn_hash(fn_key_t key, struct fn_zone *fz)
{
u32 h = ntohl(key.datum)>>(32 - fz->fz_order);
@@ -307,12 +316,19 @@
struct fn_zone *fz;
struct fn_hash *t = (struct fn_hash*)tb->tb_data;
+ FIB_STAT_INC(lookup_total);
+
read_lock(&fib_hash_lock);
for (fz = t->fn_zone_list; fz; fz = fz->fz_next) {
struct fib_node *f;
fn_key_t k = fz_key(flp->fl4_dst, fz);
+ FIB_STAT_INC(zone_search);
+
for (f = fz_chain(k, fz); f; f = f->fn_next) {
+
+ FIB_STAT_INC(chain_search);
+
if (!fn_key_eq(k, f->fn_key)) {
if (fn_key_leq(k, f->fn_key))
break;
@@ -1108,6 +1124,54 @@
.release = ip_seq_release,
};
+static int fib_stat_get_info(char *buffer, char **start, off_t offset, int length)
+{
+ int i;
+ int len = 0;
+
+ for (i = 0; i < NR_CPUS; i++) {
+ if (!cpu_possible(i))
+ continue;
+ len += sprintf(buffer+len, "%08x %08x %08x \n",
+ per_cpu_ptr(fib_stat, i)->lookup_total,
+ per_cpu_ptr(fib_stat, i)->zone_search,
+ per_cpu_ptr(fib_stat, i)->chain_search
+
+ );
+ }
+ len -= offset;
+
+ if (len > length)
+ len = length;
+ if (len < 0)
+ len = 0;
+
+ *start = buffer + offset;
+ return len;
+}
+
+int __init fib_stat_init(void)
+{
+ int i, rc = 0;
+
+ fib_stat = kmalloc_percpu(sizeof (struct fib_stat),
+ GFP_KERNEL);
+ if (!fib_stat) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ for (i = 0; i < NR_CPUS; i++) {
+ if (cpu_possible(i)) {
+ memset(per_cpu_ptr(fib_stat, i), 0,
+ sizeof (struct fib_stat));
+ }
+ }
+
+ out:
+ return rc;
+}
+
int __init fib_proc_init(void)
{
struct proc_dir_entry *p;
@@ -1116,13 +1180,27 @@
p = create_proc_entry("route", S_IRUGO, proc_net);
if (p)
p->proc_fops = &fib_seq_fops;
- else
+ else {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+
+
+ p = proc_net_create ("fib_stat", 0, fib_stat_get_info);
+
+ if (!p) {
rc = -ENOMEM;
+ remove_proc_entry("route", proc_net);
+ }
+
+ out:
return rc;
}
void __init fib_proc_exit(void)
{
remove_proc_entry("route", proc_net);
+ remove_proc_entry("fib_stat", proc_net);
}
#endif /* CONFIG_PROC_FS */
--- net/ipv4/route.c.030617 2003-06-16 16:56:34.000000000 +0200
+++ net/ipv4/route.c 2003-06-17 16:02:41.000000000 +0200
@@ -2754,7 +2754,8 @@
rt_cache_stat = kmalloc_percpu(sizeof (struct rt_cache_stat),
GFP_KERNEL);
if (!rt_cache_stat)
- goto out_enomem1;
+ goto out_enomem0;
+
for (i = 0; i < NR_CPUS; i++) {
if (cpu_possible(i)) {
memset(per_cpu_ptr(rt_cache_stat, i), 0,
@@ -2765,6 +2766,9 @@
devinet_init();
ip_fib_init();
+ if(fib_stat_init())
+ goto out_enomem1;
+
init_timer(&rt_flush_timer);
rt_flush_timer.function = rt_run_flush;
init_timer(&rt_periodic_timer);
@@ -2785,7 +2789,7 @@
#ifdef CONFIG_PROC_FS
if (rt_cache_proc_init())
- goto out_enomem;
+ goto out_enomem2;
proc_net_create ("rt_cache_stat", 0, rt_cache_stat_get_info);
#ifdef CONFIG_NET_CLS_ROUTE
create_proc_read_entry("net/rt_acct", 0, 0, ip_rt_acct_read, NULL);
@@ -2795,9 +2799,12 @@
xfrm4_init();
out:
return rc;
-out_enomem:
- kfree_percpu(rt_cache_stat);
+
+out_enomem2:
+ kfree_percpu(fib_stat);
out_enomem1:
+ kfree_percpu(rt_cache_stat);
+out_enomem0:
rc = -ENOMEM;
goto out;
}
Cheers.
--ro
next prev parent reply other threads:[~2003-06-17 17:03 UTC|newest]
Thread overview: 217+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87d6iit4g7.fsf@deneb.enyo.de>
[not found] ` <20030517.150933.74723581.davem@redhat.com>
[not found] ` <87iss87gqd.fsf@deneb.enyo.de>
2003-05-18 9:31 ` Route cache performance under stress David S. Miller
2003-05-19 17:36 ` Jamal Hadi
2003-05-19 19:18 ` Ralph Doncaster
2003-05-19 22:37 ` Jamal Hadi
2003-05-20 1:10 ` Simon Kirby
2003-05-20 1:14 ` David S. Miller
2003-05-20 1:23 ` Jamal Hadi
2003-05-20 1:24 ` David S. Miller
2003-05-20 2:13 ` Jamal Hadi
2003-05-20 5:01 ` Pekka Savola
2003-05-20 11:47 ` Jamal Hadi
2003-05-20 11:55 ` Pekka Savola
2003-05-20 6:46 ` David S. Miller
2003-05-20 12:04 ` Jamal Hadi
2003-05-21 0:36 ` David S. Miller
2003-05-21 13:03 ` Jamal Hadi
2003-05-23 5:42 ` David S. Miller
2003-05-22 8:40 ` Simon Kirby
2003-05-22 8:58 ` David S. Miller
2003-05-22 10:40 ` David S. Miller
2003-05-22 11:15 ` Martin Josefsson
2003-05-23 1:00 ` David S. Miller
2003-05-23 1:01 ` David S. Miller
2003-05-23 8:21 ` Andi Kleen
2003-05-23 8:22 ` David S. Miller
2003-05-23 9:03 ` Andi Kleen
2003-05-23 9:59 ` David S. Miller
2003-05-24 0:41 ` Andrew Morton
2003-05-26 2:29 ` David S. Miller
2003-05-22 11:44 ` Simon Kirby
2003-05-22 13:03 ` Martin Josefsson
2003-05-23 0:55 ` David S. Miller
2003-05-22 22:33 ` David S. Miller
2003-05-29 20:51 ` Simon Kirby
2003-06-02 10:58 ` Robert Olsson
2003-06-02 15:18 ` Simon Kirby
2003-06-02 16:36 ` Robert Olsson
2003-06-02 18:05 ` Simon Kirby
2003-06-09 17:21 ` David S. Miller
2003-06-09 17:19 ` David S. Miller
2003-05-23 0:59 ` David S. Miller
2003-05-26 7:18 ` Florian Weimer
2003-05-26 7:29 ` David S. Miller
2003-05-26 9:34 ` Florian Weimer
2003-05-27 6:32 ` David S. Miller
2003-06-08 11:39 ` Florian Weimer
2003-06-08 12:05 ` David S. Miller
2003-06-08 13:10 ` Florian Weimer
2003-06-08 23:49 ` Simon Kirby
2003-06-08 23:55 ` CIT/Paul
2003-06-09 3:15 ` Jamal Hadi
2003-06-09 5:27 ` CIT/Paul
2003-06-09 5:58 ` David S. Miller
2003-06-09 6:28 ` CIT/Paul
2003-06-09 6:28 ` David S. Miller
2003-06-09 16:23 ` Stephen Hemminger
2003-06-09 16:37 ` David S. Miller
2003-06-09 7:13 ` Simon Kirby
2003-06-09 8:10 ` CIT/Paul
2003-06-09 8:27 ` Simon Kirby
2003-06-09 19:38 ` CIT/Paul
2003-06-09 21:30 ` David S. Miller
2003-06-09 22:19 ` Simon Kirby
2003-06-09 22:54 ` Robert Olsson
2003-06-13 6:21 ` David S. Miller
2003-06-13 10:40 ` Robert Olsson
2003-06-15 6:36 ` David S. Miller
2003-06-17 17:03 ` Robert Olsson [this message]
2003-06-09 22:56 ` CIT/Paul
2003-06-09 23:05 ` David S. Miller
2003-06-10 13:41 ` Robert Olsson
2003-06-10 0:03 ` Jamal Hadi
2003-06-10 0:32 ` Ralph Doncaster
2003-06-10 1:15 ` Jamal Hadi
2003-06-10 2:45 ` Ralph Doncaster
2003-06-10 3:23 ` Ben Greear
2003-06-10 3:41 ` Ralph Doncaster
2003-06-10 18:10 ` Ralph Doncaster
2003-06-10 18:21 ` Ben Greear
2003-06-10 4:34 ` Simon Kirby
2003-06-10 11:01 ` Jamal Hadi
2003-06-10 11:28 ` Jamal Hadi
2003-06-10 13:18 ` Ralph Doncaster
2003-06-10 16:10 ` David S. Miller
2003-06-10 10:53 ` Jamal Hadi
2003-06-10 11:41 ` chas williams
2003-06-10 16:27 ` David S. Miller
2003-06-10 16:57 ` chas williams
2003-06-10 11:41 ` Pekka Savola
2003-06-10 11:58 ` John S. Denker
2003-06-10 12:12 ` Jamal Hadi
2003-06-10 16:33 ` David S. Miller
2003-06-10 12:07 ` Jamal Hadi
2003-06-10 15:29 ` Ralph Doncaster
2003-06-11 19:48 ` Florian Weimer
2003-06-11 19:40 ` CIT/Paul
2003-06-11 21:09 ` Florian Weimer
2003-06-10 13:10 ` Ralph Doncaster
2003-06-10 13:36 ` Jamal Hadi
2003-06-10 14:03 ` Ralph Doncaster
2003-06-10 16:38 ` David S. Miller
2003-06-10 16:39 ` David S. Miller
2003-06-10 18:41 ` Florian Weimer
2003-06-11 11:47 ` Was (Re: " Jamal Hadi
2003-06-11 18:41 ` Real World Routers 8-) Florian Weimer
2003-06-10 15:53 ` Route cache performance under stress David S. Miller
2003-06-10 16:15 ` 3c59x (was Route cache performance under stress) Bogdan Costescu
2003-06-10 16:20 ` Andi Kleen
2003-06-10 16:23 ` Jeff Garzik
2003-06-10 17:02 ` 3c59x David S. Miller
2003-06-10 17:16 ` 3c59x Jeff Garzik
2003-06-10 17:14 ` 3c59x David S. Miller
2003-06-10 17:25 ` 3c59x Jeff Garzik
2003-06-10 17:30 ` 3c59x David S. Miller
2003-06-10 19:20 ` 3c59x Jeff Garzik
2003-06-10 19:21 ` 3c59x David S. Miller
2003-06-10 17:18 ` 3c59x Andi Kleen
2003-06-10 17:29 ` 3c59x chas williams
2003-06-10 17:31 ` 3c59x David S. Miller
2003-06-10 17:39 ` 3c59x chas williams
2003-06-10 17:43 ` 3c59x David S. Miller
2003-06-11 17:52 ` Route cache performance under stress Robert Olsson
2003-06-10 1:53 ` Simon Kirby
2003-06-10 3:18 ` Ralph Doncaster
2003-06-10 16:06 ` David S. Miller
2003-06-10 15:56 ` David S. Miller
2003-06-10 16:45 ` 3c59x (was Route cache performance under stress) Bogdan Costescu
2003-06-10 16:49 ` Andi Kleen
2003-06-11 9:54 ` Robert Olsson
2003-06-11 10:05 ` Andi Kleen
2003-06-11 10:38 ` Robert Olsson
2003-06-11 12:08 ` Jamal Hadi
2003-06-10 17:12 ` 3c59x David S. Miller
2003-06-10 17:19 ` Route cache performance under stress Ralph Doncaster
2003-06-10 15:49 ` David S. Miller
2003-06-10 17:33 ` Ralph Doncaster
2003-06-10 17:32 ` David S. Miller
2003-06-10 18:34 ` Robert Olsson
2003-06-10 18:57 ` David S. Miller
2003-06-10 19:53 ` Robert Olsson
2003-06-10 21:36 ` CIT/Paul
2003-06-10 21:39 ` Ralph Doncaster
2003-06-10 22:20 ` David S. Miller
2003-06-10 23:58 ` Ralph Doncaster
2003-06-10 23:57 ` David S. Miller
2003-06-11 0:41 ` Ralph Doncaster
2003-06-11 0:58 ` David S. Miller
2003-06-11 0:58 ` David S. Miller
2003-06-11 0:51 ` Ben Greear
2003-06-11 1:01 ` David S. Miller
2003-06-11 1:15 ` Ben Greear
2003-06-11 1:22 ` David S. Miller
2003-06-11 1:51 ` Ben Greear
2003-06-11 3:33 ` David S. Miller
2003-06-11 11:54 ` gettime: Was (Re: " Jamal Hadi
2003-06-11 12:08 ` Andi Kleen
2003-06-12 3:30 ` David S. Miller
2003-06-12 6:32 ` Ben Greear
2003-06-12 8:46 ` David S. Miller
2003-06-11 15:57 ` Ben Greear
2003-06-12 3:29 ` David S. Miller
2003-06-11 1:17 ` Ralph Doncaster
2003-06-11 1:23 ` David S. Miller
2003-06-11 7:28 ` Andi Kleen
2003-06-11 7:25 ` Andi Kleen
2003-06-11 17:40 ` Robert Olsson
2003-06-13 5:38 ` David S. Miller
2003-06-13 10:22 ` Robert Olsson
2003-06-13 17:15 ` Robert Olsson
2003-06-12 6:45 ` David S. Miller
2003-06-12 13:56 ` Robert Olsson
2003-06-12 21:35 ` David S. Miller
2003-06-13 10:50 ` Robert Olsson
2003-06-10 0:56 ` Ralph Doncaster
2003-06-09 11:38 ` Jamal Hadi
2003-06-09 11:55 ` David S. Miller
2003-06-09 12:18 ` Jamal Hadi
2003-06-09 12:32 ` David S. Miller
2003-06-09 13:22 ` Jamal Hadi
2003-06-09 13:22 ` David S. Miller
2003-06-09 8:56 ` David S. Miller
2003-06-09 22:39 ` Robert Olsson
2003-06-09 6:25 ` David S. Miller
2003-06-09 6:59 ` Simon Kirby
2003-06-09 7:03 ` David S. Miller
2003-06-09 13:04 ` Ralph Doncaster
2003-06-09 13:26 ` Jamal Hadi
2003-06-09 5:44 ` David S. Miller
2003-06-09 5:51 ` CIT/Paul
2003-06-09 6:03 ` David S. Miller
2003-06-09 6:52 ` Simon Kirby
2003-06-09 6:56 ` David S. Miller
2003-06-09 7:36 ` Simon Kirby
2003-06-09 8:18 ` Simon Kirby
2003-06-09 8:22 ` David S. Miller
2003-06-09 8:31 ` Simon Kirby
2003-06-09 9:01 ` David S. Miller
2003-06-09 9:47 ` Andi Kleen
2003-06-09 10:03 ` David S. Miller
2003-06-09 10:13 ` Andi Kleen
2003-06-09 10:13 ` David S. Miller
2003-06-09 10:40 ` YOSHIFUJI Hideaki / 吉藤英明
2003-06-09 10:40 ` David S. Miller
2003-06-09 14:14 ` David S. Miller
2003-06-09 6:47 ` Simon Kirby
2003-06-09 6:49 ` David S. Miller
2003-06-09 13:28 ` Ralph Doncaster
2003-06-09 16:30 ` Simon Kirby
2003-06-17 20:58 ` Florian Weimer
2003-06-09 5:38 ` David S. Miller
2003-06-10 3:05 ` Steven Blake
2003-06-12 6:31 ` David S. Miller
2003-06-08 17:58 ` Pekka Savola
2003-05-21 0:09 ` Simon Kirby
2003-05-21 0:13 ` David S. Miller
2003-05-26 9:29 ` Florian Weimer
[not found] <8765pshpd4.fsf@deneb.enyo.de>
2003-04-05 18:17 ` Martin Josefsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16111.18921.939537.978325@robur.slu.se \
--to=robert.olsson@data.slu.se \
--cc=davem@redhat.com \
--cc=fw@deneb.enyo.de \
--cc=hadi@shell.cyberus.ca \
--cc=linux-net@vger.kernel.org \
--cc=netdev@oss.sgi.com \
--cc=sim@netnation.com \
--cc=xerox@foonet.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).