netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Olsson <Robert.Olsson@data.slu.se>
To: "Milam, Chad" <Chad_Milam@nyc.yr.com>
Cc: <netdev@oss.sgi.com>,
	"Julian Anastasov <ja@ssi.bg>"
	<IMCEANOTES-+22Julian+20Anastasov+20+3Cja+40ssi+2Ebg+3E+22@avee-health.com>
Subject: RE: dst cache overflow 2.2.x; x>=16
Date: Mon, 15 Apr 2002 23:47:07 +0200	[thread overview]
Message-ID: <15547.19035.479704.356417@robur.slu.se> (raw)
In-Reply-To: <D4CA6B275AA33241AC771F0C0B43A921011BE86B@nyc285ex01.nyc.corp.yr.com>

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 455 bytes --]


Milam, Chad writes:
 > 
 > The box is a router, no ip masq, no ip chains, no ip fw, just a router.

 Weird. Julian has a useful program testlvs for testing route
 cache. I just tested this w. linux-2.2.17 many srcnum (80000) but 
 cannot force cache overflow. Ok it was not for hours. And 2.2.X 
 has recent cache code I was wrong here. I have used it for just 
 for routers for pretty demanding jobs.

 I would look for grows in /proc/slabinfo too...

 

[-- Attachment #2: rt_cache_stat-2.2.17.pat --]
[-- Type: application/octet-stream, Size: 5850 bytes --]

--- linux/include/net/route.h.orig	Sun Nov  5 22:18:35 2000
+++ linux/include/net/route.h	Mon Apr 15 22:19:18 2002
@@ -14,6 +14,7 @@
  *		Alan Cox	:	Support for TCP parameters.
  *		Alexey Kuznetsov:	Major changes for new routing code.
  *		Mike McLagan    :	Routing by source
+ *		Robert Olsson   :	Added rt_cache statistics
  *
  *		This program is free software; you can redistribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -102,6 +103,20 @@
 	__u32 	o_packets;
 	__u32 	i_bytes;
 	__u32 	i_packets;
+};
+
+struct rt_cache_stat 
+{
+        unsigned in_hit;
+        unsigned in_slow_tot;
+        unsigned in_slow_mc;
+        unsigned in_no_route;
+        unsigned in_brd;
+        unsigned in_martian_dst;
+        unsigned in_martian_src;
+        unsigned out_hit;
+        unsigned out_slow_tot;
+        unsigned out_slow_mc;
 };
 
 extern struct ip_rt_acct ip_rt_acct[256];
--- linux/net/ipv4/route.c.orig	Tue Jan  4 19:12:26 2000
+++ linux/net/ipv4/route.c	Mon Apr 15 23:55:37 2002
@@ -52,6 +52,7 @@
  *	Tobias Ringstrom	:	Uninitialized res.type in ip_route_output_slow.
  *	Vladimir V. Ivanov	:	IP rule info (flowid) is really useful.
  *		Marc Boucher	:	routing by fwmark
+ *	Robert Olsson		:	Added rt_cache statistics
  *
  *		This program is free software; you can redistribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -176,6 +177,8 @@
 
 struct rtable 	*rt_hash_table[RT_HASH_DIVISOR];
 
+struct rt_cache_stat rt_cache_stat[NR_CPUS];
+
 static int rt_intern_hash(unsigned hash, struct rtable * rth, struct rtable ** res);
 
 static __inline__ unsigned rt_hash_code(u32 daddr, u32 saddr, u8 tos)
@@ -357,6 +360,44 @@
 	}
 	end_bh_atomic();
 }
+
+
+#ifdef CONFIG_PROC_FS
+static int rt_cache_stat_get_info(char *buffer, char **start, off_t offset, int length)
+{
+	int i, lcpu;
+        int len=0;
+	unsigned int dst_entries = atomic_read(&ipv4_dst_ops.entries);
+
+        for (lcpu=0; lcpu<smp_num_cpus; lcpu++) {
+                i = cpu_logical_map(lcpu);
+
+		len += sprintf(buffer+len, "%08x  %08x %08x %08x %08x %08x %08x %08x  %08x %08x %08x\n",
+			       dst_entries,		       
+			       rt_cache_stat[i].in_hit,
+			       rt_cache_stat[i].in_slow_tot,
+			       rt_cache_stat[i].in_slow_mc,
+			       rt_cache_stat[i].in_no_route,
+			       rt_cache_stat[i].in_brd,
+			       rt_cache_stat[i].in_martian_dst,
+			       rt_cache_stat[i].in_martian_src,
+
+			       rt_cache_stat[i].out_hit,
+			       rt_cache_stat[i].out_slow_tot,
+			       rt_cache_stat[i].out_slow_mc
+			);
+	}
+	len -= offset;
+
+	if (len > length)
+		len = length;
+	if (len < 0)
+		len = 0;
+
+	*start = buffer + offset;
+  	return len;
+}
+#endif
   
 void rt_cache_flush(int delay)
 {
@@ -1027,6 +1068,7 @@
 	struct in_device *in_dev = dev->ip_ptr;
 	u32 itag = 0;
 
+
 	/* Primary sanity checks. */
 
 	if (MULTICAST(saddr) || BADCLASS(saddr) || LOOPBACK(saddr) ||
@@ -1078,6 +1120,7 @@
 #ifdef CONFIG_IP_MROUTE
 	if (!LOCAL_MCAST(daddr) && IN_DEV_MFORWARD(in_dev))
 		rth->u.dst.input = ip_mr_input;
+ 	rt_cache_stat[smp_processor_id()].in_slow_mc++;
 #endif
 
 	hash = rt_hash_code(daddr, saddr^(dev->ifindex<<5), tos);
@@ -1155,6 +1198,8 @@
 		goto no_route;
 	}
 
+	rt_cache_stat[smp_processor_id()].in_slow_tot++;
+
 #ifdef CONFIG_IP_ROUTE_NAT
 	/* Policy is applied before mapping destination,
 	   but rerouting after map should be made with old source.
@@ -1287,6 +1332,7 @@
 	}
 	flags |= RTCF_BROADCAST;
 	res.type = RTN_BROADCAST;
+	rt_cache_stat[smp_processor_id()].in_brd++;
 
 local_input:
 	rth = dst_alloc(sizeof(struct rtable), &ipv4_dst_ops);
@@ -1328,6 +1374,7 @@
 	return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
 
 no_route:
+	rt_cache_stat[smp_processor_id()].in_no_route++;
 	spec_dst = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
 	res.type = RTN_UNREACHABLE;
 	goto local_input;
@@ -1336,6 +1383,7 @@
 	 *	Do not cache martian addresses: they should be logged (RFC1812)
 	 */
 martian_destination:
+	rt_cache_stat[smp_processor_id()].in_martian_dst++;
 #ifdef CONFIG_IP_ROUTE_VERBOSE
 	if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
 		printk(KERN_WARNING "martian destination %08x from %08x, dev %s\n", daddr, saddr, dev->name);
@@ -1343,6 +1391,8 @@
 	return -EINVAL;
 
 martian_source:
+
+	rt_cache_stat[smp_processor_id()].in_martian_src++;
 #ifdef CONFIG_IP_ROUTE_VERBOSE
 	if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) {
 		/*
@@ -1384,6 +1434,7 @@
 		    rth->key.tos == tos) {
 			rth->u.dst.lastuse = jiffies;
 			atomic_inc(&rth->u.dst.use);
+ 			rt_cache_stat[smp_processor_id()].in_hit++;
 			atomic_inc(&rth->u.dst.refcnt);
 			skb->dst = (struct dst_entry*)rth;
 			return 0;
@@ -1634,14 +1685,18 @@
 
 	rth->u.dst.output=ip_output;
 
+	rt_cache_stat[smp_processor_id()].out_slow_tot++;
+
 	if (flags&RTCF_LOCAL) {
 		rth->u.dst.input = ip_local_deliver;
 		rth->rt_spec_dst = key.dst;
 	}
 	if (flags&(RTCF_BROADCAST|RTCF_MULTICAST)) {
 		rth->rt_spec_dst = key.src;
-		if (flags&RTCF_LOCAL && !(dev_out->flags&IFF_LOOPBACK))
+		if (flags&RTCF_LOCAL && !(dev_out->flags&IFF_LOOPBACK)) {
 			rth->u.dst.output = ip_mc_output;
+			rt_cache_stat[smp_processor_id()].out_slow_mc++;
+		}
 #ifdef CONFIG_IP_MROUTE
 		if (res.type == RTN_MULTICAST && dev_out->ip_ptr) {
 			struct in_device *in_dev = dev_out->ip_ptr;
@@ -1683,6 +1738,7 @@
 		) {
 			rth->u.dst.lastuse = jiffies;
 			atomic_inc(&rth->u.dst.use);
+			rt_cache_stat[smp_processor_id()].out_hit++;
 			atomic_inc(&rth->u.dst.refcnt);
 			end_bh_atomic();
 			*rp = rth;
@@ -2041,6 +2097,8 @@
 		rt_cache_get_info
 	});
 #ifdef CONFIG_NET_CLS_ROUTE
+ 	ent = create_proc_entry ("net/rt_cache_stat", 0, 0);
+	ent->read_proc = rt_cache_stat_get_info;
 	ent = create_proc_entry("net/rt_acct", 0, 0);
 	ent->read_proc = ip_rt_acct_read;
 #endif

[-- Attachment #3: message body text --]
[-- Type: text/plain, Size: 193 bytes --]


 With the patch you can monitor ipv4_dst_ops.entries wich rtstat and 
 testlvs is good exerciser.

 Cheers.

					--ro

 BTW. I think rtstat can hold have some stats about the GC process too.

  reply	other threads:[~2002-04-15 21:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-15 19:58 dst cache overflow 2.2.x; x>=16 Milam, Chad
2002-04-15 21:47 ` Robert Olsson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-04-15 19:07 Milam, Chad
2002-04-15 22:53 ` Julian Anastasov
2002-04-15 19:53   ` Andi Kleen
2002-04-15 18:10 Milam, Chad
2002-04-15 18:27 ` jamal
2002-04-15 18:31 ` Julian Anastasov
2002-04-15 15:21 Milam, Chad
2002-04-15 17:53 ` jamal
2002-04-14 20:44 Milam, Chad
2002-04-14 20:53 ` jamal
2002-04-14 21:38   ` Robert Olsson
2002-04-14 20:25 Milam, Chad
2002-04-14 20:32 ` jamal
2002-04-14 20:38   ` jamal
2002-04-14 19:54 Milam, Chad
2002-04-14 20:04 ` jamal
2002-04-14 17:51 Milam, Chad
2002-04-14 19:39 ` jamal
2002-04-14 19:43   ` jamal

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=15547.19035.479704.356417@robur.slu.se \
    --to=robert.olsson@data.slu.se \
    --cc=Chad_Milam@nyc.yr.com \
    --cc=IMCEANOTES-+22Julian+20Anastasov+20+3Cja+40ssi+2Ebg+3E+22@avee-health.com \
    --cc=netdev@oss.sgi.com \
    /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).