Message ID | 20240208095358.251381-1-david@davidv.dev |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-57779-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp56379dyd; Thu, 8 Feb 2024 01:55:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpLPEK1lh512s/Au+Ptvha4dNODzbkTjQeK+Ak6XY+ZnqXvr+K7TGSIdMefI+wSX8Olehy X-Received: by 2002:a67:f8c5:0:b0:46d:239a:1eef with SMTP id c5-20020a67f8c5000000b0046d239a1eefmr5623563vsp.32.1707386150459; Thu, 08 Feb 2024 01:55:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707386150; cv=pass; d=google.com; s=arc-20160816; b=bp00rFglKHNPIdDiCyCBSilVvKoXUOes1SmTpi2z7Hm1rxivRhPNsX638pM7c8OCJO If50lg6lzgAvadhu14afZPgYsIiaXLXNbSHmSCUw2fiyL4VBps2cb1I1+q18LxhOgB13 F46eR6C46ZzowOYvto1vCLTZpzRCmKFJusTlnkYmWiEI97qv4Cxf+m81e/W9gzidnIQh GGChrowB1SNhQRVP9S/CTIzFh4NRI6+AaYGHrDaZM7QdVBTuZMdXBJnCWbrOQCR2Zx0+ wIunt0f032j/Rb8asBkRhrwVgJGFL9PcKg3ZB1pyeik+5d5nSMU6I6Jc2oNJY5rDylAY dVyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=m7buU54YASzC4cRoxXyJbvQsKrfgiWwIk/Xc2h1dSmE=; fh=1RCV4yiZguyDb9w4N9AHVKSXxUnklfEaWQDz16lcCxQ=; b=PxRv0qJEDJSjgDTTJhog0RDFVNuBFW8PY/0e81ZBsLeAeOevE6sRtAXhumgqYxaeIP knkQdGJIse1MaQN52tmGUZO+yiZvQLYpeKfSrcXTfUfzlucJuKylh7tWLAN3fUcd2m0t uHo+2tIODwNPGV/+VTtGg8mWK+8LxdDuPB+voUcwJQWt4Qqh8OG7mvC92nVY0OauNDfP nFjSCFOCRfVfFnLYfCA7taffw2ye/QylFbzQzEOscZjE7Wc6flY7ifBc15j0EVjIst0C VBR8zTkrfM4UEDJyuN7n+Aeg95NVJjncLbWyMZFKyGU4eInp798oJfVMiPBEADNtrQmF BXbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=davidv.dev); spf=pass (google.com: domain of linux-kernel+bounces-57779-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57779-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVRoDxClHUPIxkMNrEedwX3M5m74Ic9+xpKpOxNDDks6ObjKe5tNJK7Fdf+uCoFGmie0Riy7JEWhloMrHliCk57cCHzZw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h20-20020ac85854000000b0042a26b35c05si3076916qth.434.2024.02.08.01.55.50 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 01:55:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57779-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=davidv.dev); spf=pass (google.com: domain of linux-kernel+bounces-57779-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57779-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9CAC71C26E0D for <ouuuleilei@gmail.com>; Thu, 8 Feb 2024 09:55:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BFBB86EB6D; Thu, 8 Feb 2024 09:54:12 +0000 (UTC) Received: from davidv.dev (mail.davidv.dev [78.46.233.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AB4E6BFD7 for <linux-kernel@vger.kernel.org>; Thu, 8 Feb 2024 09:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.46.233.60 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707386051; cv=none; b=i768Mq3mZhJXO14F2kgNT8ElG6zRO8+moJ+X9p9kiaAZL0swQE9QSF0Kz369y+I+5IGTuHCn7a9qFIt63o3QDiV+84h8HF9p8GDm5zYMPZxhWFh09RhmQ4jdCcReAk7uUG3eIFOBKI7VcZYrpySIv0xAll+/6fBa4CLfiGfCO+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707386051; c=relaxed/simple; bh=zquoTPDiDMopq79YAJN8pFBJInmPfdGsBn+pPQU1BdE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f7LdLmtyj97PvMJGMQHqnnYM1w1wClRH0H3t0V/TcpRmPSPir6ZNzql6LPZAaxmdIriTjFRdmr+Y7wg+VcrTxCsjbJeshgioN9Y8ANeg1CpRfGy8kFi9wpDYbF5SN8zc9yN6n2hkdtiICCzpoo1KzfKKwUxQV5PtsJnLiHMO1Es= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidv.dev; spf=pass smtp.mailfrom=davidv.dev; arc=none smtp.client-ip=78.46.233.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidv.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=davidv.dev Received: from framework.labs by mail.davidv.dev (chasquid) with ESMTPSA tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (over submission+TLS, TLS-1.2, envelope from "david@davidv.dev") ; Thu, 08 Feb 2024 10:54:06 +0100 From: David Ventura <david@davidv.dev> To: david@davidv.dev Cc: Jonathan Corbet <corbet@lwn.net>, "David S. Miller" <davem@davemloft.net>, David Ahern <dsahern@kernel.org>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Paul E. McKenney" <paulmck@kernel.org>, Randy Dunlap <rdunlap@infradead.org>, Xiongwei Song <xiongwei.song@windriver.com>, linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list), netdev@vger.kernel.org (open list:NETWORKING [IPv4/IPv6]) Subject: [PATCH v2 1/2] net: make driver settling time configurable Date: Thu, 8 Feb 2024 10:52:29 +0100 Message-Id: <20240208095358.251381-1-david@davidv.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240208093722.246930-1-david@davidv.dev> References: <20240208093722.246930-1-david@davidv.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790324140072132682 X-GMAIL-MSGID: 1790324140072132682 |
Series |
net: ipconfig: remove wait for drivers
|
|
Commit Message
David
Feb. 8, 2024, 9:52 a.m. UTC
During IP auto configuration, some drivers apparently need to wait a
certain length of time to settle; as this is not true for all drivers,
make this length of time configurable.
Signed-off-by: David Ventura <david@davidv.dev>
---
.../admin-guide/kernel-parameters.txt | 4 ++++
Documentation/admin-guide/nfs/nfsroot.rst | 3 +++
net/ipv4/ipconfig.c | 23 ++++++++++++++++---
3 files changed, 27 insertions(+), 3 deletions(-)
Comments
On 2/8/24 12:52, David Ventura wrote: > During IP auto configuration, some drivers apparently need to wait a > certain length of time to settle; as this is not true for all drivers, > make this length of time configurable. > > Signed-off-by: David Ventura <david@davidv.dev> > --- > .../admin-guide/kernel-parameters.txt | 4 ++++ > Documentation/admin-guide/nfs/nfsroot.rst | 3 +++ > net/ipv4/ipconfig.c | 23 ++++++++++++++++--- > 3 files changed, 27 insertions(+), 3 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index b47940577c10..b07a035642fa 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -2291,6 +2291,10 @@ > > ip= [IP_PNP] > See Documentation/admin-guide/nfs/nfsroot.rst. > + ip.dev_wait_ms= > + [IP_PNP] > + See Documentation/admin-guide/nfs/nfsroot.rst. > + > > ipcmni_extend [KNL,EARLY] Extend the maximum number of unique System V > IPC identifiers from 32,768 to 16,777,216. > diff --git a/Documentation/admin-guide/nfs/nfsroot.rst b/Documentation/admin-guide/nfs/nfsroot.rst > index 135218f33394..f26f7a342af6 100644 > --- a/Documentation/admin-guide/nfs/nfsroot.rst > +++ b/Documentation/admin-guide/nfs/nfsroot.rst > @@ -223,6 +223,9 @@ ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns > /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real > root filesystem if it is on NFS). > > +ip.dev_wait_ms=<value> > + Set the number of milliseconds to delay after opening the network device > + which will be autoconfigured. Defaults to 10 milliseconds. > > nfsrootdebug > This parameter enables debugging messages to appear in the kernel > diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c > index c56b6fe6f0d7..cbf35163b973 100644 > --- a/net/ipv4/ipconfig.c > +++ b/net/ipv4/ipconfig.c > @@ -82,8 +82,6 @@ > #define IPCONFIG_DYNAMIC > #endif > > -/* Define the friendly delay before and after opening net devices */ > -#define CONF_POST_OPEN 10 /* After opening: 10 msecs */ > > /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */ > #define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */ > @@ -101,6 +99,7 @@ > > /* Wait for carrier timeout default in seconds */ > static unsigned int carrier_timeout = 120; > +static unsigned int dev_wait_ms = 10; > > /* > * Public IP configuration > @@ -1516,7 +1515,8 @@ static int __init ip_auto_config(void) > return err; > > /* Give drivers a chance to settle */ > - msleep(CONF_POST_OPEN); > + if(dev_wait_ms > 0) > + msleep(dev_wait_ms); What's the point to wait more than CONF_POST_OPEN with the change? > > /* > * If the config information is insufficient (e.g., our IP address or > @@ -1849,3 +1849,20 @@ static int __init set_carrier_timeout(char *str) > return 1; > } > __setup("carrier_timeout=", set_carrier_timeout); > + > + > +static int __init set_dev_wait_ms(char *str) > +{ > + ssize_t ret; > + > + if (!str) > + return 0; > + > + ret = kstrtouint(str, 0, &dev_wait_ms); > + if (ret) > + return 0; > + > + return 1; > +} > + > +__setup("ip.dev_wait_ms=", set_dev_wait_ms);
On 2/8/24 11:26, Denis Kirjanov wrote: > > On 2/8/24 12:52, David Ventura wrote: >> During IP auto configuration, some drivers apparently need to wait a >> certain length of time to settle; as this is not true for all drivers, >> make this length of time configurable. >> >> Signed-off-by: David Ventura <david@davidv.dev> >> --- >> .../admin-guide/kernel-parameters.txt | 4 ++++ >> Documentation/admin-guide/nfs/nfsroot.rst | 3 +++ >> net/ipv4/ipconfig.c | 23 ++++++++++++++++--- >> 3 files changed, 27 insertions(+), 3 deletions(-) >> >> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt >> index b47940577c10..b07a035642fa 100644 >> --- a/Documentation/admin-guide/kernel-parameters.txt >> +++ b/Documentation/admin-guide/kernel-parameters.txt >> @@ -2291,6 +2291,10 @@ >> >> ip= [IP_PNP] >> See Documentation/admin-guide/nfs/nfsroot.rst. >> + ip.dev_wait_ms= >> + [IP_PNP] >> + See Documentation/admin-guide/nfs/nfsroot.rst. >> + >> >> ipcmni_extend [KNL,EARLY] Extend the maximum number of unique System V >> IPC identifiers from 32,768 to 16,777,216. >> diff --git a/Documentation/admin-guide/nfs/nfsroot.rst b/Documentation/admin-guide/nfs/nfsroot.rst >> index 135218f33394..f26f7a342af6 100644 >> --- a/Documentation/admin-guide/nfs/nfsroot.rst >> +++ b/Documentation/admin-guide/nfs/nfsroot.rst >> @@ -223,6 +223,9 @@ ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns >> /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real >> root filesystem if it is on NFS). >> >> +ip.dev_wait_ms=<value> >> + Set the number of milliseconds to delay after opening the network device >> + which will be autoconfigured. Defaults to 10 milliseconds. >> >> nfsrootdebug >> This parameter enables debugging messages to appear in the kernel >> diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c >> index c56b6fe6f0d7..cbf35163b973 100644 >> --- a/net/ipv4/ipconfig.c >> +++ b/net/ipv4/ipconfig.c >> @@ -82,8 +82,6 @@ >> #define IPCONFIG_DYNAMIC >> #endif >> >> -/* Define the friendly delay before and after opening net devices */ >> -#define CONF_POST_OPEN 10 /* After opening: 10 msecs */ >> >> /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */ >> #define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */ >> @@ -101,6 +99,7 @@ >> >> /* Wait for carrier timeout default in seconds */ >> static unsigned int carrier_timeout = 120; >> +static unsigned int dev_wait_ms = 10; >> >> /* >> * Public IP configuration >> @@ -1516,7 +1515,8 @@ static int __init ip_auto_config(void) >> return err; >> >> /* Give drivers a chance to settle */ >> - msleep(CONF_POST_OPEN); >> + if(dev_wait_ms > 0) >> + msleep(dev_wait_ms); > What's the point to wait more than CONF_POST_OPEN with the change? I didn't have anything specificin mind - shall I change this to only enable/disable the 10ms wait instead of allowing a configurable value? >> >> /* >> * If the config information is insufficient (e.g., our IP address or >> @@ -1849,3 +1849,20 @@ static int __init set_carrier_timeout(char *str) >> return 1; >> } >> __setup("carrier_timeout=", set_carrier_timeout); >> + >> + >> +static int __init set_dev_wait_ms(char *str) >> +{ >> + ssize_t ret; >> + >> + if (!str) >> + return 0; >> + >> + ret = kstrtouint(str, 0, &dev_wait_ms); >> + if (ret) >> + return 0; >> + >> + return 1; >> +} >> + >> +__setup("ip.dev_wait_ms=", set_dev_wait_ms);
On Thu, 8 Feb 2024 10:52:29 +0100 David Ventura wrote: > During IP auto configuration, some drivers apparently need to wait a > certain length of time to settle; as this is not true for all drivers, > make this length of time configurable. Please CC folks who gave you feedback, Andrew's is missing. Andrew, what do you think about just removing the wait? Or decreasing it to 1ms? It feels a little wasteful to be adding uAPI for something which as you said is likely papering over ancient bugs. We'll fix the bugs which are still around and the uAPI will stay forever :(
On Fri, Feb 09, 2024 at 01:59:44PM -0800, Jakub Kicinski wrote: > On Thu, 8 Feb 2024 10:52:29 +0100 David Ventura wrote: > > During IP auto configuration, some drivers apparently need to wait a > > certain length of time to settle; as this is not true for all drivers, > > make this length of time configurable. > > Please CC folks who gave you feedback, Andrew's is missing. > > Andrew, what do you think about just removing the wait? > Or decreasing it to 1ms? > It feels a little wasteful to be adding uAPI for something > which as you said is likely papering over ancient bugs. We'll > fix the bugs which are still around and the uAPI will stay > forever :( My guess is, the broken drivers are doing setup stuff after they call netdev_register(). Reducing it to 1ms will probably continue to hide such bugs. So we could just go with that, and probably not see any regressions. Or we can decide we really do want to know about broken drivers, and just remove the delay. Either way, we don't need a new uAPI. David, is 1ms too long for you? If we do take the delay out, you are going to receive some of the flack from regression reports. Andrew
On 2/9/24 23:11, Andrew Lunn wrote: > On Fri, Feb 09, 2024 at 01:59:44PM -0800, Jakub Kicinski wrote: >> On Thu, 8 Feb 2024 10:52:29 +0100 David Ventura wrote: >>> During IP auto configuration, some drivers apparently need to wait a >>> certain length of time to settle; as this is not true for all drivers, >>> make this length of time configurable. >> Please CC folks who gave you feedback, Andrew's is missing. Thanks for the feedback, still learning this workflow >> >> Andrew, what do you think about just removing the wait? >> Or decreasing it to 1ms? >> It feels a little wasteful to be adding uAPI for something >> which as you said is likely papering over ancient bugs. We'll >> fix the bugs which are still around and the uAPI will stay >> forever :( > My guess is, the broken drivers are doing setup stuff after they call > netdev_register(). > > Reducing it to 1ms will probably continue to hide such bugs. So we > could just go with that, and probably not see any regressions. Or we > can decide we really do want to know about broken drivers, and just > remove the delay. > > Either way, we don't need a new uAPI. Would it make sense to move this to a build-time configuration flag? I do not have a gut-feeling for which behaviors should be configurable at build vs run time. > David, is 1ms too long for you? If we do take the delay out, you are > going to receive some of the flack from regression reports. I've used this patch to experiment with different values, and the sleep time behaves as described in Documentation/timers/timers-howto.rst, that is, a call of `msleep(1)` usually delays boot time by 12~13 ms in my tests. On top of this, I'm running this specific example on a no-smp systemm, where I do not believe the `msleep` achieves anything (but I'm a kernel newbie so please correct me if I'm wrong). > > Andrew >
> Would it make sense to move this to a build-time configuration flag? > > I do not have a gut-feeling for which behaviors should be configurable > > at build vs run time. If it is build time, it becomes the distribution problem to pick a value. Might be best to just bite the bullet, set it to 0, and fixup whatever breaks. Andrew
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b47940577c10..b07a035642fa 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2291,6 +2291,10 @@ ip= [IP_PNP] See Documentation/admin-guide/nfs/nfsroot.rst. + ip.dev_wait_ms= + [IP_PNP] + See Documentation/admin-guide/nfs/nfsroot.rst. + ipcmni_extend [KNL,EARLY] Extend the maximum number of unique System V IPC identifiers from 32,768 to 16,777,216. diff --git a/Documentation/admin-guide/nfs/nfsroot.rst b/Documentation/admin-guide/nfs/nfsroot.rst index 135218f33394..f26f7a342af6 100644 --- a/Documentation/admin-guide/nfs/nfsroot.rst +++ b/Documentation/admin-guide/nfs/nfsroot.rst @@ -223,6 +223,9 @@ ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real root filesystem if it is on NFS). +ip.dev_wait_ms=<value> + Set the number of milliseconds to delay after opening the network device + which will be autoconfigured. Defaults to 10 milliseconds. nfsrootdebug This parameter enables debugging messages to appear in the kernel diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index c56b6fe6f0d7..cbf35163b973 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -82,8 +82,6 @@ #define IPCONFIG_DYNAMIC #endif -/* Define the friendly delay before and after opening net devices */ -#define CONF_POST_OPEN 10 /* After opening: 10 msecs */ /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */ #define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */ @@ -101,6 +99,7 @@ /* Wait for carrier timeout default in seconds */ static unsigned int carrier_timeout = 120; +static unsigned int dev_wait_ms = 10; /* * Public IP configuration @@ -1516,7 +1515,8 @@ static int __init ip_auto_config(void) return err; /* Give drivers a chance to settle */ - msleep(CONF_POST_OPEN); + if(dev_wait_ms > 0) + msleep(dev_wait_ms); /* * If the config information is insufficient (e.g., our IP address or @@ -1849,3 +1849,20 @@ static int __init set_carrier_timeout(char *str) return 1; } __setup("carrier_timeout=", set_carrier_timeout); + + +static int __init set_dev_wait_ms(char *str) +{ + ssize_t ret; + + if (!str) + return 0; + + ret = kstrtouint(str, 0, &dev_wait_ms); + if (ret) + return 0; + + return 1; +} + +__setup("ip.dev_wait_ms=", set_dev_wait_ms);