From patchwork Tue Sep 19 16:15:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 815639 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HSHV4uwf"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xxSgW00mqz9sPk for ; Wed, 20 Sep 2017 02:16:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751431AbdISQPx (ORCPT ); Tue, 19 Sep 2017 12:15:53 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:49610 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbdISQPv (ORCPT ); Tue, 19 Sep 2017 12:15:51 -0400 Received: by mail-pg0-f42.google.com with SMTP id m30so62080pgn.6 for ; Tue, 19 Sep 2017 09:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=05zluyi7UJ3Pv5qoAZ06Joo1iI74m7BRryK5fT4okH8=; b=HSHV4uwfL3mQtpAM1PZXUvmKkR+R7hXH1mxJcTwd+zJo3MGNHlvqRYhaq8fPKmrhsC ZF/YY0O4aQtGK++wZOOAlfr+Xl2kMnVjxioGmqiWlN832M2J8FYwYlrRfh9+bu5SAa3F uqDO4kK0g9oDRyprAaIyGOa9tyh9na1w0w7Rg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=05zluyi7UJ3Pv5qoAZ06Joo1iI74m7BRryK5fT4okH8=; b=pWIZPDg6oGMO1ycl+UgfdL5msD0gG6oKpCzei2gDeSTkoG6Vqe0jfZMMCpJerZyEeX 403/rSOYEz0eVRPnn0oSqWEI24vosqTTKV/hMcBhJPuoKOsEyzbRsXkUk2w/fwG/dnhb FmSjC7upgrwX0TxWX2xDxhl9cULWwd8dGZojndUo2ZYLsbSwqMoN2A3uws2Y48Or54pN mVoJKAorEZDh6WmVILd/aCrfCSy5g2gQEZeiyWdxQ7RsJ3aBRW9E7isaOrd+VnRvxXiN 8KS5/y3bTaJcBcnNlvIa1kVOKYKPiGtS/E3neaT8j3yGRhwP4DasLtpDeP8YMgTtNJ2G UAXQ== X-Gm-Message-State: AHPjjUirliu862A9byzzjlFPfKeArBGap3yoVbS9cbh3Eq7PuBpYiL2v bn5plCUTTeSdv0F9TQFdr/dHrw== X-Google-Smtp-Source: AOwi7QADaWUT9pcJ7tYzs+sQ5DLGG+P0jR7Im75YYSRvxU4stgsK2O2px8VcKI3L+psB913V+FNSmQ== X-Received: by 10.99.4.8 with SMTP id 8mr1869855pge.123.1505837751222; Tue, 19 Sep 2017 09:15:51 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.112.154]) by smtp.gmail.com with ESMTPSA id o128sm5030751pga.5.2017.09.19.09.15.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Sep 2017 09:15:49 -0700 (PDT) From: Douglas Anderson To: Oliver Neukum Cc: groeck@chromium.org, grundler@chromium.org, Douglas Anderson , netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/3] usbnet: Get rid of spammy usbnet "kevent X may have been dropped" Date: Tue, 19 Sep 2017 09:15:20 -0700 Message-Id: <20170919161522.995-1-dianders@chromium.org> X-Mailer: git-send-email 2.14.1.690.gbb1197296e-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Every once in a while when my system is under a bit of stress I see some spammy messages show up in my logs that say: kevent X may have been dropped As far as I can tell these messages aren't terribly useful. The comments around the messages make me think that either workqueues used to work differently or that the original author of the code missed a sublety related to them. The error message appears to predate the git conversion of the kernel so it's somewhat hard to tell. Specifically, workqueues should work like this: A) If a workqueue hasn't been scheduled then schedule_work() schedules it and returns true. B) If a workqueue has been scheduled (but hasn't started) then schedule_work() will do nothing and return false. C) If a workqueue has been scheduled (and has started) then schedule_work() will put it on the queue to run again and return true. Said another way: if you call schedule_work() you can guarantee that at least one full runthrough of the work will happen again. That should mean that the work will get processed and I don't see any reason to think something should be dropped. Reading the comments in in usbnet_defer_kevent() made me think that B) and C) would be treated the same. That is: even if we've started the work and are 99% of the way through then schedule_work() would return false and the work wouldn't be queued again. If schedule_work() really did behave that way then, truly, some amount of work would be lost. ...but it doesn't. NOTE: if somehow these warnings are useful to mean something then perhaps we should change them to make it more obvious. If it's interesting to know when the work is backlogged then we should change the spam to say "warning: usbnet is backlogged". ALSO NOTE: If somehow some of the types of work need to be repeated if usbnet_defer_kevent() is called multiple times then that should be quite easy to accomplish without dropping any work on the floor. We can just keep an atomic count for that type of work and add a loop into usbnet_deferred_kevent(). Signed-off-by: Douglas Anderson Reviewed-by: Guenter Roeck Acked-by: Oliver Neukum --- drivers/net/usb/usbnet.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 6510e5cc1817..a3e8dbaadcf9 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -450,19 +450,17 @@ static enum skb_state defer_bh(struct usbnet *dev, struct sk_buff *skb, } /* some work can't be done in tasklets, so we use keventd - * - * NOTE: annoying asymmetry: if it's active, schedule_work() fails, - * but tasklet_schedule() doesn't. hope the failure is rare. */ void usbnet_defer_kevent (struct usbnet *dev, int work) { set_bit (work, &dev->flags); - 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); - } + + /* If work is already started this will mark it to run again when it + * finishes; if we already had work pending and it hadn't started + * yet then that's fine too. + */ + schedule_work (&dev->kevent); + netdev_dbg(dev->net, "kevent %d scheduled\n", work); } EXPORT_SYMBOL_GPL(usbnet_defer_kevent);