Patchwork usbnet: ratelimit kevent may have been dropped warnings

login
register
mail settings
Submitter Steve Glendinning
Date Nov. 8, 2012, 4:26 p.m.
Message ID <1352391981-15692-1-git-send-email-steve.glendinning@shawell.net>
Download mbox | patch
Permalink /patch/197855/
State Accepted
Delegated to: David Miller
Headers show

Comments

Steve Glendinning - Nov. 8, 2012, 4:26 p.m.
when something goes wrong, a flood of these messages can be
generated by usbnet (thousands per second).  This doesn't
generally *help* the condition so this patch ratelimits the
rate of their generation.

There's an underlying problem in usbnet's kevent deferral
mechanism which needs fixing, specifically that events *can*
get dropped and not handled.  This patch doesn't address this,
but just mitigates fallout caused by the current implemention.

Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/net/usb/usbnet.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
David Miller - Nov. 9, 2012, 10 p.m.
From: Steve Glendinning <steve.glendinning@shawell.net>
Date: Thu,  8 Nov 2012 16:26:21 +0000

> when something goes wrong, a flood of these messages can be
> generated by usbnet (thousands per second).  This doesn't
> generally *help* the condition so this patch ratelimits the
> rate of their generation.
> 
> There's an underlying problem in usbnet's kevent deferral
> mechanism which needs fixing, specifically that events *can*
> get dropped and not handled.  This patch doesn't address this,
> but just mitigates fallout caused by the current implemention.
> 
> Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Oliver Neukum - Nov. 12, 2012, 7:11 a.m.
On Thursday 08 November 2012 16:26:21 Steve Glendinning wrote:
> when something goes wrong, a flood of these messages can be
> generated by usbnet (thousands per second).  This doesn't
> generally *help* the condition so this patch ratelimits the
> rate of their generation.
> 
> There's an underlying problem in usbnet's kevent deferral
> mechanism which needs fixing, specifically that events *can*
> get dropped and not handled.  This patch doesn't address this,
> but just mitigates fallout caused by the current implemention.
> 
> Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
Acked-by: Oliver Neukum <oneukum@suse.de>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Oliver Neukum - Nov. 12, 2012, 7:16 a.m.
On Thursday 08 November 2012 16:26:21 Steve Glendinning wrote:

> There's an underlying problem in usbnet's kevent deferral

This is imported from schedule_work().

> mechanism which needs fixing, specifically that events *can*
> get dropped and not handled.  This patch doesn't address this,
> but just mitigates fallout caused by the current implemention.

All is not lost, as the flag is still set. How about starting a timer
in the failure case? It feels kind of dirty, but a solution with locks would
leave open a window to a race in any case.

	Regards
		Oliver

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 5bf7717..3565e6d 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -359,10 +359,12 @@  static enum skb_state defer_bh(struct usbnet *dev, struct sk_buff *skb,
 void usbnet_defer_kevent (struct usbnet *dev, int work)
 {
 	set_bit (work, &dev->flags);
-	if (!schedule_work (&dev->kevent))
-		netdev_err(dev->net, "kevent %d may have been dropped\n", work);
-	else
+	if (!schedule_work (&dev->kevent)) {
+		if (net_ratelimit())
+			netdev_err(dev->net, "kevent %d may have been dropped\n", work);
+	} else {
 		netdev_dbg(dev->net, "kevent %d scheduled\n", work);
+	}
 }
 EXPORT_SYMBOL_GPL(usbnet_defer_kevent);