Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1259181pxb; Wed, 27 Oct 2021 23:46:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5Lfgvju8JgpLCtZJTwqaH9TRCdeMi4yq1tMF5MPfufja8Iz6Fzr0GikU2ke7pRdFzPXlV X-Received: by 2002:a63:d30e:: with SMTP id b14mr1865667pgg.454.1635403600302; Wed, 27 Oct 2021 23:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635403600; cv=none; d=google.com; s=arc-20160816; b=WmUyWLRtlaQ3A1VgzrZ/C1qND3i7zXO4dgsVUGGGxbas4TCZYDAzHxadQIsQLkEe61 b/RiymMMs53+RVybunSP6lVvUv0z3e7cO/awK88tmyhXbqqqNT0H64NSDiZ8PSAd9gd5 B6b6jUM6m56aE/YKROm1gOy8xVYZA5KFdW9mERuGzhB6tajNlN6X9pzfisqbCA+kLIM/ p56yKsAJ9Ful+CkREYRsvaHxkVJXikfuDza9KGklCCUNUVKFbW0gex5IkHjo6S3q126T dC/K+efYkuKEzxOX/Oh38YPWZul/63Zg17FqaTasjxNwx8UfRgbxLVruqKMyQTuVyCqB Mniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=5aXOGOX+UmhVc6rdAH1wVE3NAbWHBZ5GaIeEzgQ9sWo=; b=apidmiIWMhMf/3PGZnUZvh50lSIXIs5bv1g+xvyC9uPq7vSkC9RhMoSqvzzFCLlbal ujwVDLydr6dlXGs7MOflcza1WHJPLe7NhonMxabfpurB30oYOCniIjclg0Se9SC6MM/5 5kNt61YgOcafAzaq0gAq8LKihwr5g5fDIxN3+ydYDvlurfsJz3NvMeKawx1Dcy/Q/5QC R3cOGbRI2GDcP84aQGQotS5bo8V+6E4aDlUuSj9Iu8UTK3w+in/oJfiApERRHT7ebCCK 6Z7fPPht+MbimauLPxYAg2SuVyU0XEftY1mHlJ18w83cRAssuZwUY/umuhrXICSrlk8A IRvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si3220389pfe.153.2021.10.27.23.46.27; Wed, 27 Oct 2021 23:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbhJ1Grw convert rfc822-to-8bit (ORCPT + 99 others); Thu, 28 Oct 2021 02:47:52 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:53967 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbhJ1Grv (ORCPT ); Thu, 28 Oct 2021 02:47:51 -0400 Received: (Authenticated sender: maxime.chevallier@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 7FC9660014; Thu, 28 Oct 2021 06:45:21 +0000 (UTC) Date: Thu, 28 Oct 2021 08:45:20 +0200 From: Maxime Chevallier To: Antoine Tenart Cc: David Ahern , Hideaki YOSHIFUJI , Jakub Kicinski , Russell King , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: Re: [RFC PATCH net] net: ipconfig: Release the rtnl_lock while waiting for carrier Message-ID: <20211028084520.4b96f93a@bootlin.com> In-Reply-To: <163535070902.935735.6368176213562383450@kwain> References: <20211027131953.9270-1-maxime.chevallier@bootlin.com> <163535070902.935735.6368176213562383450@kwain> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Antoine, On Wed, 27 Oct 2021 18:05:09 +0200 Antoine Tenart wrote: >Hi Maxime, > >Quoting Maxime Chevallier (2021-10-27 15:19:53) >> While waiting for a carrier to come on one of the netdevices, some >> devices will require to take the rtnl lock at some point to fully >> initialize all parts of the link. >> >> That's the case for SFP, where the rtnl is taken when a module gets >> detected. This prevents mounting an NFS rootfs over an SFP link. >> >> This means that while ipconfig waits for carriers to be detected, no SFP >> modules can be detected in the meantime, it's only detected after >> ipconfig times out. >> >> This commit releases the rtnl_lock while waiting for the carrier to come >> up, and re-takes it to check the for the init device and carrier status. >> >> At that point, the rtnl_lock seems to be only protecting >> ic_is_init_dev(). >> >> Fixes: 73970055450e ("sfp: add SFP module support") > >Was this working with SFP modules before? From what I can tell, no. In that case, does it need a fixes tag ? It seems the problem has always been there, and booting an nfsroot never worked over SFP links. > >> diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c >> index 816d8aad5a68..069ae05bd0a5 100644 >> --- a/net/ipv4/ipconfig.c >> +++ b/net/ipv4/ipconfig.c >> @@ -278,7 +278,12 @@ static int __init ic_open_devs(void) >> if (ic_is_init_dev(dev) && netif_carrier_ok(dev)) >> goto have_carrier; >> >> + /* Give a chance to do complex initialization that >> + * would require to take the rtnl lock. >> + */ >> + rtnl_unlock(); >> msleep(1); >> + rtnl_lock(); >> >> if (time_before(jiffies, next_msg)) >> continue; > >The rtnl lock is protecting 'for_each_netdev' and 'dev_change_flags' in >this function. What could happen in theory is a device gets removed from >the list or has its flags changed. I don't think that's an issue here. > >Instead of releasing the lock while sleeping, you could drop the lock >before the carrier waiting loop (with a similar comment) and only >protect the above 'for_each_netdev' loop. Nice catch, the effect should be the same but with a much cleaner idea of what is being protected. I'll give it a try and respin, thanks for the review ! Maxime >Antoine -- Maxime Chevallier, Bootlin Embedded Linux and kernel engineering https://bootlin.com