netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
[parent not found: <5.1.0.14.2.20020613183120.03222cb8@mira-sjcm-3.cisco.com>]
[parent not found: <5.1.0.14.2.20020612221925.0283fb18@mira-sjcm-3.cisco.com>]
* RE: RFC: per-socket statistics on received/dropped packets
@ 2002-06-12 20:30 Yan-Fa Li
  0 siblings, 0 replies; 53+ messages in thread
From: Yan-Fa Li @ 2002-06-12 20:30 UTC (permalink / raw)
  To: 'Ben Greear', Pekka Savola; +Cc: Mark Mielke, linux-kernel, netdev

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

Does this do what is needed ?  I've used it and it does have an impact on
stack performance while the application is running, but it tells you about
retransmits and what not, and does not seem to affect  performance much
until you actually want to inspect the values.  I agree with DaveM that it
should not go into the mainline kernel unless you can turn it off with a
sysctl, but it is useful for debugging and network health monitoring.

Y

http://heron.ucsd.edu/tcphealth/


[-- Attachment #2: Type: text/html, Size: 969 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread
* RE: RFC: per-socket statistics on received/dropped packets
@ 2002-06-12 20:30 Yan-Fa Li
  0 siblings, 0 replies; 53+ messages in thread
From: Yan-Fa Li @ 2002-06-12 20:30 UTC (permalink / raw)
  To: 'Ben Greear', Pekka Savola; +Cc: Mark Mielke, linux-kernel, netdev

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

Does this do what is needed ?  I've used it and it does have an impact on
stack performance while the application is running, but it tells you about
retransmits and what not, and does not seem to affect  performance much
until you actually want to inspect the values.  I agree with DaveM that it
should not go into the mainline kernel unless you can turn it off with a
sysctl, but it is useful for debugging and network health monitoring.

Y

http://heron.ucsd.edu/tcphealth/


[-- Attachment #2: Type: text/html, Size: 969 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread
[parent not found: <20020612105355.A20760@mark.mielke.cc>]
[parent not found: <Message from Ben Greear <greearb@candelatech.com>]
[parent not found: <Pine.LNX.4.44.0206120930160.29780-100000@netcore.fi>]
[parent not found: <Pine.LNX.4.44.0206120905510.29780-100000@netcore.fi>]
* RFC: per-socket statistics on received/dropped packets
@ 2002-06-06 19:37 Chris Friesen
  2002-06-07  3:21 ` David S. Miller
  0 siblings, 1 reply; 53+ messages in thread
From: Chris Friesen @ 2002-06-06 19:37 UTC (permalink / raw)
  To: linux-kernel, netdev

[-- Attachment #1: Type: text/plain, Size: 1409 bytes --]


For a while I've been wanting a way for a program to find out if any of its
socket buffers were overflowing due to too much incoming traffic.  Finally, I
decided to code it up and try it out.

As it turns out, it was relatively simple to add, although it required the
addition of two new entries in sockios.h.

Basically, inside of sock_queue_rcv_skb() and sock_queue_err_skb() the receive
counter gets incremented unconditionally, and then if there is no free space in
the socket buffer then we also increment the counter for messages dropped due to
out of memory.

The stats are stored as part of a socket_stats struct, making it easy to add
other counters in the future.

To access and reset the counters, two ioctl commands were added to the socket
ioctl. GIOCSOCKSTATS is used to get the stats, while SIOCZEROSOCKSTATS is used
to reset them.  I haven't bothered with trying to reset them both atomically as
I don't think it's that critical.

The patch was coded and tested for 2.4.18, but it is known to at least apply
(with offsets) on 2.5.20.

Feel free to bash on it a bit, once the issues are worked out I'll submit to the
appropriate maintainer.

Chris
 
-- 
Chris Friesen                    | MailStop: 043/33/F10  
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com

[-- Attachment #2: sockstats.patch --]
[-- Type: text/plain, Size: 3589 bytes --]

diff -Nur 2.4.18/include/linux/sockios.h 2.4.18/include/linux/sockios.h
--- 2.4.18/include/linux/sockios.h	Wed Nov  7 17:39:36 2001
+++ 2.4.18/include/linux/sockios.h	Wed Jun  5 15:55:54 2002
@@ -113,6 +113,10 @@
 #define SIOCBONDSLAVEINFOQUERY 0x8993   /* rtn info about slave state   */
 #define SIOCBONDINFOQUERY      0x8994	/* rtn info about bond state    */
 #define SIOCBONDCHANGEACTIVE   0x8995   /* update to a new active slave */
+
+/* per-socket statistics manipulation */
+#define GIOCSOCKSTATS		0x8996	/* get the per-socket statistics */
+#define  SIOCZEROSOCKSTATS	0x8997	/* zero out the per-socket statistics */
 			
 /* Device private ioctl calls */
 
diff -Nur 2.4.18/include/net/sock.h 2.4.18/include/net/sock.h
--- 2.4.18/include/net/sock.h	Thu May  2 15:32:20 2002
+++ 2.4.18/include/net/sock.h	Wed Jun  5 15:58:24 2002
@@ -480,6 +480,16 @@
 	wait_queue_head_t	wq;
 } socket_lock_t;
 
+/* per-socket statistics.  received is the total number of skbuffs received
+ * on that socket.  dropped_no_mem is the number of packets dropped due
+ * to a lack of space on the socket receive buffer
+ */
+typedef struct {
+	__u64			received;
+	__u32			dropped_no_mem;
+} socket_stats;
+
+
 #define sock_lock_init(__sk) \
 do {	spin_lock_init(&((__sk)->lock.slock)); \
 	(__sk)->lock.users = 0; \
@@ -678,6 +688,10 @@
   	int			(*backlog_rcv) (struct sock *sk,
 						struct sk_buff *skb);  
 	void                    (*destruct)(struct sock *sk);
+	
+	
+	/* per-socket statistics */
+	socket_stats		stats;
 };
 
 /* The per-socket spinlock must be held here. */
@@ -1145,11 +1159,15 @@
 
 static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 {
+	sk->stats.received++;
+
 	/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
 	   number of warnings when compiling with -W --ANK
 	 */
-	if (atomic_read(&sk->rmem_alloc) + skb->truesize >= (unsigned)sk->rcvbuf)
+	if (atomic_read(&sk->rmem_alloc) + skb->truesize >= (unsigned)sk->rcvbuf) {
+		sk->stats.dropped_no_mem++;
                 return -ENOMEM;
+	}
 
 #ifdef CONFIG_FILTER
 	if (sk->filter) {
@@ -1179,11 +1197,16 @@
 
 static inline int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
 {
+	sk->stats.received++;
+	
 	/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
 	   number of warnings when compiling with -W --ANK
 	 */
-	if (atomic_read(&sk->rmem_alloc) + skb->truesize >= (unsigned)sk->rcvbuf)
+	if (atomic_read(&sk->rmem_alloc) + skb->truesize >= (unsigned)sk->rcvbuf) {
+		sk->stats.dropped_no_mem++;
 		return -ENOMEM;
+	}
+	
 	skb_set_owner_r(skb, sk);
 	skb_queue_tail(&sk->error_queue,skb);
 	if (!sk->dead)
diff -Nur 2.4.18/net/core/sock.c 2.4.18/net/core/sock.c
--- 2.4.18/net/core/sock.c	Fri Dec 21 12:42:05 2001
+++ 2.4.18/net/core/sock.c	Wed Jun  5 13:59:37 2002
@@ -1202,6 +1202,9 @@
 	sk->rcvlowat		=	1;
 	sk->rcvtimeo		=	MAX_SCHEDULE_TIMEOUT;
 	sk->sndtimeo		=	MAX_SCHEDULE_TIMEOUT;
+	
+	sk->stats.received	=	0;
+	sk->stats.dropped_no_mem	=	0;
 
 	atomic_set(&sk->refcnt, 1);
 }
diff -Nur 2.4.18/net/ipv4/af_inet.c 2.4.18/net/ipv4/af_inet.c
--- 2.4.18/net/ipv4/af_inet.c	Fri Dec 21 12:42:05 2001
+++ 2.4.18/net/ipv4/af_inet.c	Wed Jun  5 15:56:20 2002
@@ -834,6 +834,16 @@
 	int pid;
 
 	switch(cmd) {
+		case GIOCSOCKSTATS:
+			return copy_to_user((void *)arg, &sk->stats, sizeof(sk->stats));
+		case SIOCZEROSOCKSTATS:
+			if (!capable(CAP_NET_ADMIN))
+				return -EPERM;
+			else {
+				sk->stats.dropped_no_mem = 0;
+				sk->stats.received = 0;
+				return (0);
+			}
 		case FIOSETOWN:
 		case SIOCSPGRP:
 			err = get_user(pid, (int *) arg);

^ permalink raw reply	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2002-06-23  2:05 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <5.1.0.14.2.20020612224038.0251bd08@mira-sjcm-3.cisco.com>
2002-06-12 13:00 ` RFC: per-socket statistics on received/dropped packets jamal
     [not found] ` <Pine.GSO.4.30.0206120853320.799-100000@shell.cyberus.ca>
2002-06-12 14:53   ` Mark Mielke
2002-06-12 14:53   ` Mark Mielke
     [not found] ` <5.1.0.14.2.20020614100914.01adca48@mira-sjcm-3.cisco.com>
2002-06-14 15:51   ` Stephen Hemminger
     [not found]   ` <1024069878.20676.1.camel@dell_ss3.pdx.osdl.net>
2002-06-14 18:09     ` Ben Greear
     [not found] <5.1.0.14.2.20020613183120.03222cb8@mira-sjcm-3.cisco.com>
2002-06-13 10:10 ` David Schwartz
     [not found] <5.1.0.14.2.20020612221925.0283fb18@mira-sjcm-3.cisco.com>
2002-06-12 12:33 ` jamal
2002-06-12 12:44   ` Lincoln Dale
2002-06-12 12:44   ` Lincoln Dale
2002-06-12 12:44   ` Lincoln Dale
2002-06-13  7:21 ` David Schwartz
     [not found] ` <20020613072155.AAA14363@shell.webmaster.com@whenever>
2002-06-13  8:44   ` Lincoln Dale
2002-06-23  2:03 ` Alan Cox
     [not found] ` <E17LwjD-0003hT-00@the-village.bc.nu>
2002-06-23  2:05   ` Lincoln Dale
2002-06-12 20:30 Yan-Fa Li
  -- strict thread matches above, loose matches on Subject: below --
2002-06-12 20:30 Yan-Fa Li
     [not found] <20020612105355.A20760@mark.mielke.cc>
2002-06-12 15:57 ` jamal
2002-06-12 17:00 ` Horst von Brand
     [not found] <Message from Ben Greear <greearb@candelatech.com>
     [not found] ` <3D06E9A0.5060801@candelatech.com>
2002-06-12  6:32   ` Pekka Savola
2002-06-12 12:11   ` Horst von Brand
     [not found]   ` <200206121211.g5CCBjZt030139@pincoya.inf.utfsm.cl>
2002-06-12 12:28     ` Lincoln Dale
     [not found] <Pine.LNX.4.44.0206120930160.29780-100000@netcore.fi>
2002-06-12  6:49 ` Ben Greear
     [not found] <Pine.LNX.4.44.0206120905510.29780-100000@netcore.fi>
2002-06-12  6:26 ` Ben Greear
2002-06-06 19:37 Chris Friesen
2002-06-07  3:21 ` David S. Miller
2002-06-07 15:34   ` Chris Friesen
2002-06-07 22:15   ` Ben Greear
     [not found]   ` <3D01307C.4090503@candelatech.com>
2002-06-08 21:05     ` Mark Mielke
2002-06-08 23:04       ` David S. Miller
     [not found]       ` <20020608.160407.101346167.davem@redhat.com>
2002-06-09  0:13         ` Ben Greear
     [not found]         ` <3D029DAF.5040006@candelatech.com>
2002-06-09  0:51           ` David S. Miller
     [not found]           ` <20020608.175108.84748597.davem@redhat.com>
2002-06-09 18:23             ` Ben Greear
2002-06-10  4:34               ` David S. Miller
     [not found]               ` <20020609.213440.04716391.davem@redhat.com>
2002-06-10  5:55                 ` Mark Mielke
2002-06-10  6:08                 ` Ben Greear
2002-06-10 12:03                 ` Lincoln Dale
2002-06-10 12:18                   ` David S. Miller
2002-06-10 12:24                     ` jamal
2002-06-10 13:57                       ` Mark Mielke
2002-06-10 14:45                         ` jamal
2002-06-10 14:56                           ` jamal
2002-06-10 19:28                           ` Chris Friesen
2002-06-10 19:28                           ` Chris Friesen
2002-06-10 19:28                           ` Chris Friesen
2002-06-10 19:28                           ` Chris Friesen
2002-06-10 19:28                           ` Chris Friesen
2002-06-11 22:41                 ` Bill Davidsen
     [not found]                 ` <Pine.LNX.3.96.1020611183218.29598A-100000@gatekeeper.tmr.com>
2002-06-12  3:41                   ` David S. Miller
2002-06-12  3:57                     ` Richard Guy Briggs
2002-06-12  5:20                       ` Mark Mielke
     [not found]                       ` <20020612012004.A15773@mark.mielke.cc>
2002-06-12  6:08                         ` Pekka Savola
2002-06-12  9:18                         ` Sean Hunter
2002-06-09 14:47       ` Pekka Pietikäinen

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).