All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
@ 2009-03-03 17:03 Neil Horman
  2009-03-04 13:54 ` Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Neil Horman @ 2009-03-03 17:03 UTC (permalink / raw)
  To: netdev; +Cc: nhorman, davem, kuznet, pekkas, jmorris, yoshfuji, kaber


Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>


 include/linux/skbuff.h |    4 +++-
 net/core/datagram.c    |    2 +-
 net/core/skbuff.c      |   22 ++++++++++++++++++++++
 net/ipv4/arp.c         |    2 +-
 net/ipv4/udp.c         |    2 +-
 net/packet/af_packet.c |    2 +-
 6 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 1f659e8..d328267 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -421,6 +421,7 @@ extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
 #endif
 
 extern void kfree_skb(struct sk_buff *skb);
+extern void kfree_skb_clean(struct sk_buff *skb);
 extern void	       __kfree_skb(struct sk_buff *skb);
 extern struct sk_buff *__alloc_skb(unsigned int size,
 				   gfp_t priority, int fclone, int node);
@@ -459,7 +460,8 @@ extern int	       skb_to_sgvec(struct sk_buff *skb,
 extern int	       skb_cow_data(struct sk_buff *skb, int tailbits,
 				    struct sk_buff **trailer);
 extern int	       skb_pad(struct sk_buff *skb, int pad);
-#define dev_kfree_skb(a)	kfree_skb(a)
+#define dev_kfree_skb(a)	kfree_skb_clean(a)
+#define dev_kfree_skb_clean(a)	kfree_skb_clean(a)
 extern void	      skb_over_panic(struct sk_buff *skb, int len,
 				     void *here);
 extern void	      skb_under_panic(struct sk_buff *skb, int len,
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 5e2ac0c..6cb2723 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -208,7 +208,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
 
 void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
 {
-	kfree_skb(skb);
+	kfree_skb_clean(skb);
 	sk_mem_reclaim_partial(sk);
 }
 
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e5e2111..4458ec8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -65,6 +65,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
+#include <trace/skb.h>
 
 #include "kmap_skb.h"
 
@@ -442,11 +443,32 @@ void kfree_skb(struct sk_buff *skb)
 		smp_rmb();
 	else if (likely(!atomic_dec_and_test(&skb->users)))
 		return;
+	trace_kfree_skb(skb, __builtin_return_address(0));
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(kfree_skb);
 
 /**
+ *	kfree_skb_clean - free an skbuff
+ *	@skb: buffer to free
+ *
+ *	Drop a reference to the buffer and free it if the usage count has hit zero
+ *	Functions identically to kfree_skb, but kfree_skb assumes that the frame
+ *	is being dropped after a failure and notes that
+ */
+void kfree_skb_clean(struct sk_buff *skb)
+{
+	if (unlikely(!skb))
+		return;
+	if (likely(atomic_read(&skb->users) == 1))
+		smp_rmb();
+	else if (likely(!atomic_dec_and_test(&skb->users)))
+		return;
+	__kfree_skb(skb);
+}
+EXPORT_SYMBOL(kfree_skb_clean);
+
+/**
  *	skb_recycle_check - check if skb can be reused for receive
  *	@skb: buffer
  *	@skb_size: minimum receive buffer size
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 3f6b735..61e45c1 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -892,7 +892,7 @@ static int arp_process(struct sk_buff *skb)
 out:
 	if (in_dev)
 		in_dev_put(in_dev);
-	kfree_skb(skb);
+	kfree_skb_clean(skb);
 	return 0;
 }
 
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 4bd178a..e99ee8c 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1184,7 +1184,7 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 			sk = sknext;
 		} while (sknext);
 	} else
-		kfree_skb(skb);
+		kfree_skb_clean(skb);
 	spin_unlock(&hslot->lock);
 	return 0;
 }
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index d8cc006..fdc9817 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -584,7 +584,7 @@ drop_n_restore:
 		skb->len = skb_len;
 	}
 drop:
-	kfree_skb(skb);
+	kfree_skb_clean(skb);
 	return 0;
 }
 

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-03 17:03 [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs Neil Horman
@ 2009-03-04 13:54 ` Arnaldo Carvalho de Melo
  2009-03-04 14:18   ` Neil Horman
  2009-03-05 21:01 ` Neil Horman
  2009-03-11 19:49 ` Neil Horman
  2 siblings, 1 reply; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2009-03-04 13:54 UTC (permalink / raw)
  To: Neil Horman; +Cc: netdev, davem, kuznet, pekkas, jmorris, yoshfuji, kaber

Em Tue, Mar 03, 2009 at 12:03:07PM -0500, Neil Horman escreveu:
> 
> Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

Why just not add a "drop_skb()" instead? kfree_skb_clean sounds as if we
will do some cleanup on the skb being freed. "drop_skb()" seems much
clearer.

- Arnaldo

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-04 13:54 ` Arnaldo Carvalho de Melo
@ 2009-03-04 14:18   ` Neil Horman
  2009-03-04 16:13     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 18+ messages in thread
From: Neil Horman @ 2009-03-04 14:18 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: netdev, davem, kuznet, pekkas, jmorris, yoshfuji, kaber

On Wed, Mar 04, 2009 at 10:54:15AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Mar 03, 2009 at 12:03:07PM -0500, Neil Horman escreveu:
> > 
> > Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
> > Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> 
> Why just not add a "drop_skb()" instead? kfree_skb_clean sounds as if we
> will do some cleanup on the skb being freed. "drop_skb()" seems much
> clearer.
> 
> - Arnaldo
> 

Check the RFC thread.  The cases in which we are dropping far outnumber the set
of cases in which we free the skb simply because its the end of the line.
Theres far less churn this way

Neil


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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-04 14:18   ` Neil Horman
@ 2009-03-04 16:13     ` Arnaldo Carvalho de Melo
  2009-03-04 21:06       ` David Miller
  0 siblings, 1 reply; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2009-03-04 16:13 UTC (permalink / raw)
  To: Neil Horman
  Cc: Arnaldo Carvalho de Melo, netdev, davem, kuznet, pekkas, jmorris,
	yoshfuji, kaber

Em Wed, Mar 04, 2009 at 09:18:31AM -0500, Neil Horman escreveu:
> On Wed, Mar 04, 2009 at 10:54:15AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Mar 03, 2009 at 12:03:07PM -0500, Neil Horman escreveu:
> > > 
> > > Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
> > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> > 
> > Why just not add a "drop_skb()" instead? kfree_skb_clean sounds as if we
> > will do some cleanup on the skb being freed. "drop_skb()" seems much
> > clearer.
> > 
> > - Arnaldo
> > 
> 
> Check the RFC thread.  The cases in which we are dropping far outnumber the set
> of cases in which we free the skb simply because its the end of the line.
> Theres far less churn this way

I wouldn't mind the churn, as I really think drop_skb() would be
clearer, but then this is up to Dave.

- Arnaldo

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-04 16:13     ` Arnaldo Carvalho de Melo
@ 2009-03-04 21:06       ` David Miller
  2009-03-04 22:45         ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 18+ messages in thread
From: David Miller @ 2009-03-04 21:06 UTC (permalink / raw)
  To: acme; +Cc: nhorman, netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Wed, 4 Mar 2009 13:13:35 -0300

> I wouldn't mind the churn, as I really think drop_skb() would be
> clearer, but then this is up to Dave.

I mind the churn, I have to apply this thing and deal with
the merge conflicts :-)

Why not come up with a clever alternative name for kfree_skb_clean()?

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-04 21:06       ` David Miller
@ 2009-03-04 22:45         ` Arnaldo Carvalho de Melo
  2009-03-04 22:47           ` David Miller
  0 siblings, 1 reply; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2009-03-04 22:45 UTC (permalink / raw)
  To: David Miller
  Cc: acme, nhorman, netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

Em Wed, Mar 04, 2009 at 01:06:14PM -0800, David Miller escreveu:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> Date: Wed, 4 Mar 2009 13:13:35 -0300
> 
> > I wouldn't mind the churn, as I really think drop_skb() would be
> > clearer, but then this is up to Dave.
> 
> I mind the churn, I have to apply this thing and deal with
> the merge conflicts :-)
> 
> Why not come up with a clever alternative name for kfree_skb_clean()?

Oh well, sometimes churn is inevitable, but lemme try to figure out some
more clearer names for kfree_skb_clean:

rest_in_peace_skb()
here_lies_a_productive_skb()
kfree_not_dropped_skb()
kfree_worthy_skb()
consumed_skb()
hasta_la_vista_skbaby()
kfree_used_skb()

Perhaps the last one, huh? :-)

- Arnaldo

P.S.: </joke'ishy moment>

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-04 22:45         ` Arnaldo Carvalho de Melo
@ 2009-03-04 22:47           ` David Miller
  2009-03-04 22:51             ` Arnaldo Carvalho de Melo
  2009-03-04 23:57             ` Patrick McHardy
  0 siblings, 2 replies; 18+ messages in thread
From: David Miller @ 2009-03-04 22:47 UTC (permalink / raw)
  To: acme; +Cc: nhorman, netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Wed, 4 Mar 2009 19:45:05 -0300

> hasta_la_vista_skbaby()

This is my personal favorite, it's very Mexifornia.

> consumed_skb()

But more seriously I like something like "consume_skb()" the best (ie.
drop the 'd').  It has the implication that an application or other
entity "consumed" and used the data before we freed the SKB.

What do you think?

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-04 22:47           ` David Miller
@ 2009-03-04 22:51             ` Arnaldo Carvalho de Melo
  2009-03-04 23:57             ` Patrick McHardy
  1 sibling, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2009-03-04 22:51 UTC (permalink / raw)
  To: David Miller; +Cc: nhorman, netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

Em Wed, Mar 04, 2009 at 02:47:22PM -0800, David Miller escreveu:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> Date: Wed, 4 Mar 2009 19:45:05 -0300
> 
> > hasta_la_vista_skbaby()
> 
> This is my personal favorite, it's very Mexifornia.

ROTFL, I have to get that book someday... For now I'm reading a brick
about post-'45 Europe :-)
 
> > consumed_skb()
> 
> But more seriously I like something like "consume_skb()" the best (ie.
> drop the 'd').  It has the implication that an application or other
> entity "consumed" and used the data before we freed the SKB.
> 
> What do you think?

That would be better than kfree_skb_clean, yes.

- Arnaldo

P.S.: Neil, I didn't managed to get to the other aspects of your work,
sorry about being so picky :-\

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-04 22:47           ` David Miller
  2009-03-04 22:51             ` Arnaldo Carvalho de Melo
@ 2009-03-04 23:57             ` Patrick McHardy
  1 sibling, 0 replies; 18+ messages in thread
From: Patrick McHardy @ 2009-03-04 23:57 UTC (permalink / raw)
  To: David Miller; +Cc: acme, nhorman, netdev, kuznet, pekkas, jmorris, yoshfuji

David Miller wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> Date: Wed, 4 Mar 2009 19:45:05 -0300
> 
>> hasta_la_vista_skbaby()
> 
> This is my personal favorite, it's very Mexifornia.

My clear favourite as well. Maybe for some procedure that leaks
the skb :)

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-03 17:03 [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs Neil Horman
  2009-03-04 13:54 ` Arnaldo Carvalho de Melo
@ 2009-03-05 21:01 ` Neil Horman
  2009-03-11 16:18   ` David Miller
  2009-03-11 19:49 ` Neil Horman
  2 siblings, 1 reply; 18+ messages in thread
From: Neil Horman @ 2009-03-05 21:01 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuznet, pekkas, jmorris, yoshfuji, kaber

Ok, as requested, new version of this patch to add in bifurcation of kfree_skb
into two versions, one for legitimate kfree's, and one for drops

Modification Notes:
1) Renamed kfree_skb_clean to consume_skb, to better identify points where we
are finished with an skb

2) checkpatch cleanups

Thanks!

Neil

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>


 include/linux/skbuff.h |    4 +++-
 net/core/datagram.c    |    2 +-
 net/core/skbuff.c      |   22 ++++++++++++++++++++++
 net/ipv4/arp.c         |    2 +-
 net/ipv4/udp.c         |    2 +-
 net/packet/af_packet.c |    2 +-
 6 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 1f659e8..1fbab2a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -421,6 +421,7 @@ extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
 #endif
 
 extern void kfree_skb(struct sk_buff *skb);
+extern void consume_skb(struct sk_buff *skb);
 extern void	       __kfree_skb(struct sk_buff *skb);
 extern struct sk_buff *__alloc_skb(unsigned int size,
 				   gfp_t priority, int fclone, int node);
@@ -459,7 +460,8 @@ extern int	       skb_to_sgvec(struct sk_buff *skb,
 extern int	       skb_cow_data(struct sk_buff *skb, int tailbits,
 				    struct sk_buff **trailer);
 extern int	       skb_pad(struct sk_buff *skb, int pad);
-#define dev_kfree_skb(a)	kfree_skb(a)
+#define dev_kfree_skb(a)	consume_skb(a)
+#define dev_consume_skb(a)	kfree_skb_clean(a)
 extern void	      skb_over_panic(struct sk_buff *skb, int len,
 				     void *here);
 extern void	      skb_under_panic(struct sk_buff *skb, int len,
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 5e2ac0c..d0de644 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -208,7 +208,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
 
 void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
 {
-	kfree_skb(skb);
+	consume_skb(skb);
 	sk_mem_reclaim_partial(sk);
 }
 
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e5e2111..6acbf9e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -65,6 +65,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
+#include <trace/skb.h>
 
 #include "kmap_skb.h"
 
@@ -442,11 +443,32 @@ void kfree_skb(struct sk_buff *skb)
 		smp_rmb();
 	else if (likely(!atomic_dec_and_test(&skb->users)))
 		return;
+	trace_kfree_skb(skb, __builtin_return_address(0));
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(kfree_skb);
 
 /**
+ *	consume_skb - free an skbuff
+ *	@skb: buffer to free
+ *
+ *	Drop a ref to the buffer and free it if the usage count has hit zero
+ *	Functions identically to kfree_skb, but kfree_skb assumes that the frame
+ *	is being dropped after a failure and notes that
+ */
+void consume_skb(struct sk_buff *skb)
+{
+	if (unlikely(!skb))
+		return;
+	if (likely(atomic_read(&skb->users) == 1))
+		smp_rmb();
+	else if (likely(!atomic_dec_and_test(&skb->users)))
+		return;
+	__kfree_skb(skb);
+}
+EXPORT_SYMBOL(consume_skb);
+
+/**
  *	skb_recycle_check - check if skb can be reused for receive
  *	@skb: buffer
  *	@skb_size: minimum receive buffer size
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 3f6b735..e89f7b7 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -892,7 +892,7 @@ static int arp_process(struct sk_buff *skb)
 out:
 	if (in_dev)
 		in_dev_put(in_dev);
-	kfree_skb(skb);
+	consume_skb(skb);
 	return 0;
 }
 
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 4bd178a..05b7abb 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1184,7 +1184,7 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 			sk = sknext;
 		} while (sknext);
 	} else
-		kfree_skb(skb);
+		consume_skb(skb);
 	spin_unlock(&hslot->lock);
 	return 0;
 }
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index d8cc006..74776de 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -584,7 +584,7 @@ drop_n_restore:
 		skb->len = skb_len;
 	}
 drop:
-	kfree_skb(skb);
+	consume_skb(skb);
 	return 0;
 }
 

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-05 21:01 ` Neil Horman
@ 2009-03-11 16:18   ` David Miller
  2009-03-11 16:34     ` Eric Dumazet
  0 siblings, 1 reply; 18+ messages in thread
From: David Miller @ 2009-03-11 16:18 UTC (permalink / raw)
  To: nhorman; +Cc: netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

From: Neil Horman <nhorman@tuxdriver.com>
Date: Thu, 5 Mar 2009 16:01:05 -0500

> Ok, as requested, new version of this patch to add in bifurcation of kfree_skb
> into two versions, one for legitimate kfree's, and one for drops
> 
> Modification Notes:
> 1) Renamed kfree_skb_clean to consume_skb, to better identify points where we
> are finished with an skb
> 
> 2) checkpatch cleanups

Looks good.

Respin everything with the requested changes I asked for in #4
and I can likely toss this into net-next-2.6, thanks!

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-11 16:18   ` David Miller
@ 2009-03-11 16:34     ` Eric Dumazet
  2009-03-11 16:48       ` David Miller
  2009-03-11 17:07       ` Neil Horman
  0 siblings, 2 replies; 18+ messages in thread
From: Eric Dumazet @ 2009-03-11 16:34 UTC (permalink / raw)
  To: David Miller; +Cc: nhorman, netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

David Miller a écrit :
> From: Neil Horman <nhorman@tuxdriver.com>
> Date: Thu, 5 Mar 2009 16:01:05 -0500
> 
>> Ok, as requested, new version of this patch to add in bifurcation of kfree_skb
>> into two versions, one for legitimate kfree's, and one for drops
>>
>> Modification Notes:
>> 1) Renamed kfree_skb_clean to consume_skb, to better identify points where we
>> are finished with an skb
>>
>> 2) checkpatch cleanups
> 
> Looks good.
> 
> Respin everything with the requested changes I asked for in #4
> and I can likely toss this into net-next-2.6, thanks!

I was wondering if packets droped at NIC level are handled by "Network Drop Monitor".
(See recent discussion about Multicast packet loss)

I believe not, maybe I missed something ...


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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-11 16:34     ` Eric Dumazet
@ 2009-03-11 16:48       ` David Miller
  2009-03-11 17:07       ` Neil Horman
  1 sibling, 0 replies; 18+ messages in thread
From: David Miller @ 2009-03-11 16:48 UTC (permalink / raw)
  To: dada1; +Cc: nhorman, netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

From: Eric Dumazet <dada1@cosmosbay.com>
Date: Wed, 11 Mar 2009 17:34:47 +0100

> David Miller a écrit :
> > From: Neil Horman <nhorman@tuxdriver.com>
> > Date: Thu, 5 Mar 2009 16:01:05 -0500
> > 
> >> Ok, as requested, new version of this patch to add in bifurcation of kfree_skb
> >> into two versions, one for legitimate kfree's, and one for drops
> >>
> >> Modification Notes:
> >> 1) Renamed kfree_skb_clean to consume_skb, to better identify points where we
> >> are finished with an skb
> >>
> >> 2) checkpatch cleanups
> > 
> > Looks good.
> > 
> > Respin everything with the requested changes I asked for in #4
> > and I can likely toss this into net-next-2.6, thanks!
> 
> I was wondering if packets droped at NIC level are handled by "Network Drop Monitor".
> (See recent discussion about Multicast packet loss)
> 
> I believe not, maybe I missed something ...

No, it's just a "software network drop monitor"

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-11 16:34     ` Eric Dumazet
  2009-03-11 16:48       ` David Miller
@ 2009-03-11 17:07       ` Neil Horman
  2009-03-11 21:39         ` Evgeniy Polyakov
  1 sibling, 1 reply; 18+ messages in thread
From: Neil Horman @ 2009-03-11 17:07 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Miller, netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

On Wed, Mar 11, 2009 at 05:34:47PM +0100, Eric Dumazet wrote:
> David Miller a écrit :
> > From: Neil Horman <nhorman@tuxdriver.com>
> > Date: Thu, 5 Mar 2009 16:01:05 -0500
> > 
> >> Ok, as requested, new version of this patch to add in bifurcation of kfree_skb
> >> into two versions, one for legitimate kfree's, and one for drops
> >>
> >> Modification Notes:
> >> 1) Renamed kfree_skb_clean to consume_skb, to better identify points where we
> >> are finished with an skb
> >>
> >> 2) checkpatch cleanups
> > 
> > Looks good.
> > 
> > Respin everything with the requested changes I asked for in #4
> > and I can likely toss this into net-next-2.6, thanks!
> 
> I was wondering if packets droped at NIC level are handled by "Network Drop Monitor".
> (See recent discussion about Multicast packet loss)
> 
> I believe not, maybe I missed something ...
> 
No, unfortunately, theres no really good way to detect drops at the driver level
without polling them periodically, which I think is somewhat in opposition to the
point of this utility.  I'd welcome suggestions however.
Neil

> 

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-03 17:03 [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs Neil Horman
  2009-03-04 13:54 ` Arnaldo Carvalho de Melo
  2009-03-05 21:01 ` Neil Horman
@ 2009-03-11 19:49 ` Neil Horman
  2009-03-13 19:10   ` David Miller
  2 siblings, 1 reply; 18+ messages in thread
From: Neil Horman @ 2009-03-11 19:49 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuznet, pekkas, jmorris, yoshfuji, kaber

On Tue, Mar 03, 2009 at 12:03:07PM -0500, Neil Horman wrote:
> 
> 
As requested, respinning against latest net-next tree.

Modification notes:

None, simple respin

Neil


Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>


 include/linux/skbuff.h |    4 +++-
 net/core/datagram.c    |    2 +-
 net/core/skbuff.c      |   22 ++++++++++++++++++++++
 net/ipv4/arp.c         |    2 +-
 net/ipv4/udp.c         |    2 +-
 net/packet/af_packet.c |    2 +-
 6 files changed, 29 insertions(+), 5 deletions(-)


diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 1f659e8..1fbab2a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -421,6 +421,7 @@ extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
 #endif
 
 extern void kfree_skb(struct sk_buff *skb);
+extern void consume_skb(struct sk_buff *skb);
 extern void	       __kfree_skb(struct sk_buff *skb);
 extern struct sk_buff *__alloc_skb(unsigned int size,
 				   gfp_t priority, int fclone, int node);
@@ -459,7 +460,8 @@ extern int	       skb_to_sgvec(struct sk_buff *skb,
 extern int	       skb_cow_data(struct sk_buff *skb, int tailbits,
 				    struct sk_buff **trailer);
 extern int	       skb_pad(struct sk_buff *skb, int pad);
-#define dev_kfree_skb(a)	kfree_skb(a)
+#define dev_kfree_skb(a)	consume_skb(a)
+#define dev_consume_skb(a)	kfree_skb_clean(a)
 extern void	      skb_over_panic(struct sk_buff *skb, int len,
 				     void *here);
 extern void	      skb_under_panic(struct sk_buff *skb, int len,
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 5e2ac0c..d0de644 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -208,7 +208,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
 
 void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
 {
-	kfree_skb(skb);
+	consume_skb(skb);
 	sk_mem_reclaim_partial(sk);
 }
 
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e5e2111..6acbf9e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -65,6 +65,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
+#include <trace/skb.h>
 
 #include "kmap_skb.h"
 
@@ -442,11 +443,32 @@ void kfree_skb(struct sk_buff *skb)
 		smp_rmb();
 	else if (likely(!atomic_dec_and_test(&skb->users)))
 		return;
+	trace_kfree_skb(skb, __builtin_return_address(0));
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(kfree_skb);
 
 /**
+ *	consume_skb - free an skbuff
+ *	@skb: buffer to free
+ *
+ *	Drop a ref to the buffer and free it if the usage count has hit zero
+ *	Functions identically to kfree_skb, but kfree_skb assumes that the frame
+ *	is being dropped after a failure and notes that
+ */
+void consume_skb(struct sk_buff *skb)
+{
+	if (unlikely(!skb))
+		return;
+	if (likely(atomic_read(&skb->users) == 1))
+		smp_rmb();
+	else if (likely(!atomic_dec_and_test(&skb->users)))
+		return;
+	__kfree_skb(skb);
+}
+EXPORT_SYMBOL(consume_skb);
+
+/**
  *	skb_recycle_check - check if skb can be reused for receive
  *	@skb: buffer
  *	@skb_size: minimum receive buffer size
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 3d67d1f..9c22032 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -892,7 +892,7 @@ static int arp_process(struct sk_buff *skb)
 out:
 	if (in_dev)
 		in_dev_put(in_dev);
-	kfree_skb(skb);
+	consume_skb(skb);
 	return 0;
 }
 
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 4bd178a..05b7abb 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1184,7 +1184,7 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 			sk = sknext;
 		} while (sknext);
 	} else
-		kfree_skb(skb);
+		consume_skb(skb);
 	spin_unlock(&hslot->lock);
 	return 0;
 }
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index d8cc006..74776de 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -584,7 +584,7 @@ drop_n_restore:
 		skb->len = skb_len;
 	}
 drop:
-	kfree_skb(skb);
+	consume_skb(skb);
 	return 0;
 }
 

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-11 17:07       ` Neil Horman
@ 2009-03-11 21:39         ` Evgeniy Polyakov
  2009-03-12  0:30           ` Neil Horman
  0 siblings, 1 reply; 18+ messages in thread
From: Evgeniy Polyakov @ 2009-03-11 21:39 UTC (permalink / raw)
  To: Neil Horman
  Cc: Eric Dumazet, David Miller, netdev, kuznet, pekkas, jmorris,
	yoshfuji, kaber

On Wed, Mar 11, 2009 at 01:07:01PM -0400, Neil Horman (nhorman@tuxdriver.com) wrote:
> > I was wondering if packets droped at NIC level are handled by "Network Drop Monitor".
> > (See recent discussion about Multicast packet loss)
> > 
> > I believe not, maybe I missed something ...
> > 
> No, unfortunately, theres no really good way to detect drops at the driver level
> without polling them periodically, which I think is somewhat in opposition to the
> point of this utility.  I'd welcome suggestions however.

It could be possible to check softnet stats difference when napi is
scheduled or drop monitor is about to send a packet to the userspace
about different drop.

-- 
	Evgeniy Polyakov

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-11 21:39         ` Evgeniy Polyakov
@ 2009-03-12  0:30           ` Neil Horman
  0 siblings, 0 replies; 18+ messages in thread
From: Neil Horman @ 2009-03-12  0:30 UTC (permalink / raw)
  To: Evgeniy Polyakov
  Cc: Eric Dumazet, David Miller, netdev, kuznet, pekkas, jmorris,
	yoshfuji, kaber

On Thu, Mar 12, 2009 at 12:39:02AM +0300, Evgeniy Polyakov wrote:
> On Wed, Mar 11, 2009 at 01:07:01PM -0400, Neil Horman (nhorman@tuxdriver.com) wrote:
> > > I was wondering if packets droped at NIC level are handled by "Network Drop Monitor".
> > > (See recent discussion about Multicast packet loss)
> > > 
> > > I believe not, maybe I missed something ...
> > > 
> > No, unfortunately, theres no really good way to detect drops at the driver level
> > without polling them periodically, which I think is somewhat in opposition to the
> > point of this utility.  I'd welcome suggestions however.
> 
> It could be possible to check softnet stats difference when napi is
> scheduled or drop monitor is about to send a packet to the userspace
> about different drop.
> 
Those are both good ideas.  I think I like the former suggestion, since the
latter requires that a drop in the stack must occur to detect a stack closer to
the hardware.  Thank you, I'll keep that in mind for a subsequent enhancement.

Regards
Neil

> -- 
> 	Evgeniy Polyakov
> 

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

* Re: [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs
  2009-03-11 19:49 ` Neil Horman
@ 2009-03-13 19:10   ` David Miller
  0 siblings, 0 replies; 18+ messages in thread
From: David Miller @ 2009-03-13 19:10 UTC (permalink / raw)
  To: nhorman; +Cc: netdev, kuznet, pekkas, jmorris, yoshfuji, kaber

From: Neil Horman <nhorman@tuxdriver.com>
Date: Wed, 11 Mar 2009 15:49:55 -0400

> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

Applied.

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

end of thread, other threads:[~2009-03-13 19:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-03 17:03 [Patch 3/5] Network Drop Monitor: Adding kfree_skb_clean for non-drops and modifying end-of-line points for skbs Neil Horman
2009-03-04 13:54 ` Arnaldo Carvalho de Melo
2009-03-04 14:18   ` Neil Horman
2009-03-04 16:13     ` Arnaldo Carvalho de Melo
2009-03-04 21:06       ` David Miller
2009-03-04 22:45         ` Arnaldo Carvalho de Melo
2009-03-04 22:47           ` David Miller
2009-03-04 22:51             ` Arnaldo Carvalho de Melo
2009-03-04 23:57             ` Patrick McHardy
2009-03-05 21:01 ` Neil Horman
2009-03-11 16:18   ` David Miller
2009-03-11 16:34     ` Eric Dumazet
2009-03-11 16:48       ` David Miller
2009-03-11 17:07       ` Neil Horman
2009-03-11 21:39         ` Evgeniy Polyakov
2009-03-12  0:30           ` Neil Horman
2009-03-11 19:49 ` Neil Horman
2009-03-13 19:10   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.