From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70BBCC433C1 for ; Tue, 23 Mar 2021 06:50:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BB42619BF for ; Tue, 23 Mar 2021 06:50:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbhCWGuA (ORCPT ); Tue, 23 Mar 2021 02:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbhCWGtd (ORCPT ); Tue, 23 Mar 2021 02:49:33 -0400 Received: from mail-wm1-x349.google.com (mail-wm1-x349.google.com [IPv6:2a00:1450:4864:20::349]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83978C061756 for ; Mon, 22 Mar 2021 23:49:28 -0700 (PDT) Received: by mail-wm1-x349.google.com with SMTP id w10so654129wmk.1 for ; Mon, 22 Mar 2021 23:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=pditvg/nc0NLp+p2M+bo/XsGI8wzVr1z5D5T5xN+BK0=; b=pD3GJ4+4okoHKwwo6ruL+u4wUBi7/p22gschG4mFHjG+1UHklTrafFGqEVUAEAV1VL HSBAfqGpmArEQJwg1bipPS3fR8+FxmB+QK++3coIYvZkZVSTkZ/ZKvnp0NhfFlynMaTx Lia8SWM8MPDsNxI7IG2J0WyrYJEUFn1eCV+pd5ALQq7A3hBVb/P//I9mv75CoavPoM2r Yrpc5b0vghqmZobcKVN+b7t7zIKD0YKt85YiGO3SVFyL5WMDojbT6YOwjyhnWz56fBZS fOqJ/W5XlWlrFullfwfmE3HZfMcgguY1+D4IChzQAot7rgQv/SYUpxkdwtNNG+YLaTY2 PB0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=pditvg/nc0NLp+p2M+bo/XsGI8wzVr1z5D5T5xN+BK0=; b=ePoBFsiLwXM7KIO7wyHuruf8qoATR/x8ciKnZXruvdviB/Fs5kv2z7Wy5q53/PtAbQ ea6yvE7+qnvT/+aiFCBUNqMZPzOFvKXRPWGbcZ7NjJX8FvM+9vjA47oJalPlzw6ThmkK jejeOvSXXVIvMvVzJj+uvlpKfIpJDuA/Ls4NYbAWtWkEu2zITuqjfOpIwF9cJi/2N7Dm vmgXV/q6OpJThanRaxxR/Ol2A4PtUVqsBM3nNvt46ry0G1cTxFtnMVgU2WPMd6cvaCuH 1qG6iazNJGju+2mbdfIdHj8nxG+0gAuu4kVuaz9Ap9S5/JEdfFPTUQh6AZZJ2AAuzTkM Ci2Q== X-Gm-Message-State: AOAM530/2yBYsHcmN5SaCIbL4bJX+cF2PArJaUAi/tCO0nS3xL0b3PZ/ PHWtqWXlQPOwG9xhAV9CTlFVwGU3/6Qb X-Google-Smtp-Source: ABdhPJwCEn8gixp+xlt4DyGdnlAg3sme9Kew9fjXQeafOZX+ZOjfUZ+ilzQTeEfnQMi47mt+wi/Q5YfHX7Rp X-Received: from dvyukov-desk.muc.corp.google.com ([2a00:79e0:15:13:d80d:9d4d:16e4:a16c]) (user=dvyukov job=sendgmr) by 2002:a05:600c:49aa:: with SMTP id h42mr1828173wmp.49.1616482166965; Mon, 22 Mar 2021 23:49:26 -0700 (PDT) Date: Tue, 23 Mar 2021 07:49:23 +0100 Message-Id: <20210323064923.2098711-1-dvyukov@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH v2] net: make unregister netdev warning timeout configurable From: Dmitry Vyukov To: davem@davemloft.net, edumazet@google.com, leon@kernel.org Cc: Dmitry Vyukov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org netdev_wait_allrefs() issues a warning if refcount does not drop to 0 after 10 seconds. While 10 second wait generally should not happen under normal workload in normal environment, it seems to fire falsely very often during fuzzing and/or in qemu emulation (~10x slower). At least it's not possible to understand if it's really a false positive or not. Automated testing generally bumps all timeouts to very high values to avoid flake failures. Add net.core.netdev_unregister_timeout_secs sysctl to make the timeout configurable for automated testing systems. Lowering the timeout may also be useful for e.g. manual bisection. The default value matches the current behavior. Signed-off-by: Dmitry Vyukov Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=211877 Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes since v1: - use sysctl instead of a config --- Documentation/admin-guide/sysctl/net.rst | 11 +++++++++++ include/linux/netdevice.h | 1 + net/core/dev.c | 6 +++++- net/core/sysctl_net_core.c | 10 ++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/sysctl/net.rst b/Documentation/admin-guide/sysctl/net.rst index f2ab8a5b6a4b8..2090bfc69aa50 100644 --- a/Documentation/admin-guide/sysctl/net.rst +++ b/Documentation/admin-guide/sysctl/net.rst @@ -311,6 +311,17 @@ permit to distribute the load on several cpus. If set to 1 (default), timestamps are sampled as soon as possible, before queueing. +netdev_unregister_timeout_secs +------------------------------ + +Unregister network device timeout in seconds. +This option controls the timeout (in seconds) used to issue a warning while +waiting for a network device refcount to drop to 0 during device +unregistration. A lower value may be useful during bisection to detect +a leaked reference faster. A larger value may be useful to prevent false +warnings on slow/loaded systems. +Default value is 10, minimum 0, maximum 3600. + optmem_max ---------- diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 87a5d186faff4..179c5693f5119 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4611,6 +4611,7 @@ void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s); extern int netdev_max_backlog; extern int netdev_tstamp_prequeue; +extern int netdev_unregister_timeout_secs; extern int weight_p; extern int dev_weight_rx_bias; extern int dev_weight_tx_bias; diff --git a/net/core/dev.c b/net/core/dev.c index 0f72ff5d34ba0..7accbd4a3bec1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10344,6 +10344,8 @@ int netdev_refcnt_read(const struct net_device *dev) } EXPORT_SYMBOL(netdev_refcnt_read); +int netdev_unregister_timeout_secs __read_mostly = 10; + #define WAIT_REFS_MIN_MSECS 1 #define WAIT_REFS_MAX_MSECS 250 /** @@ -10405,7 +10407,9 @@ static void netdev_wait_allrefs(struct net_device *dev) refcnt = netdev_refcnt_read(dev); - if (refcnt && time_after(jiffies, warning_time + 10 * HZ)) { + if (refcnt && + time_after(jiffies, warning_time + + netdev_unregister_timeout_secs * HZ)) { pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n", dev->name, refcnt); warning_time = jiffies; diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 4567de519603b..d84c8a1b280e2 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -24,6 +24,7 @@ static int two = 2; static int three = 3; +static int int_3600 = 3600; static int min_sndbuf = SOCK_MIN_SNDBUF; static int min_rcvbuf = SOCK_MIN_RCVBUF; static int max_skb_frags = MAX_SKB_FRAGS; @@ -570,6 +571,15 @@ static struct ctl_table net_core_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE, }, + { + .procname = "netdev_unregister_timeout_secs", + .data = &netdev_unregister_timeout_secs, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = &int_3600, + }, { } }; base-commit: e0c755a45f6fb6e81e3a62a94db0400ef0cdc046 -- 2.31.0.291.g576ba9dcdaf-goog