From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 9BC6B23CC for ; Mon, 15 Jan 2024 06:08:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="of+JNQdv" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40e7a9c527dso3788125e9.1 for ; Sun, 14 Jan 2024 22:08:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1705298905; x=1705903705; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=psrO8ysP5KQkyXx2iDli7R9JaH/czE23JBWLZP2hF6Y=; b=of+JNQdvV+y0T6efuQKInZXfrYeq7oRuwGXp+gPHSW94NGQvx71MxTNdP9F7mIccv/ Z8Awxe0BwJaRs7Tk2+ys4/dxesxHVOUgZBatiEA6iKM46AcUZasIBO9l4/0ME9+rXhZ+ KdAkCQnMCM77yTK6w34Au3bde3r7ap/Gmim8faC3ebSGuaknht2yWNS8gSfyT4kXg+5j QilO9r8eL/5RgMpLreKpIiMdN2eWdWnkcQ9s9gxfM9PYbupmAxT1n0+ACS3Gn0Lle26A CkcQ/h+YlrsTVZccFuVFsRSFCmq9LOdY5pyOxsWOG60zjIRNtWmMjy3ywDIu/+VBi8ri oJ6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705298905; x=1705903705; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=psrO8ysP5KQkyXx2iDli7R9JaH/czE23JBWLZP2hF6Y=; b=Vitg+g3keXPMiO60W1J8clC9u0WCKUy57nUwJQ0Ckt5nScOlOABG9vWtHlPu2kFYua mUREFRHtgaq0Yr64A7mPibpgImgLEd5xK5IF1W8B/MHrsOYYfMWpB2Hrn5KoebY9pQBL EN+Tu+uyHEPuephcxyymVW9mOkfBXpgIqQNkp6B/XoDPYbmTl2h2QAgqlDLNDB4iUTH0 S2+hHJ2NkUOE9DHWKJj2MDdKseLihH0l+dtKVJh4RJPhSCArJlFA4BXkU/RNrGfgUlL5 1IE17uAyV46EbWwvCgCLmI90t/HU1yJAWpdZKq7B9C6sSidwlqX8dO7KcaOWHTUBvmOP nzQg== X-Gm-Message-State: AOJu0Yxgd4asmiG9uXdo78FoQULuDIWEr8Pyps/WUuk/fjvTDYAfjpsZ fhVQAZ9nzBaS2Gnb28+wdUd6EIx2MCBJvQ== X-Google-Smtp-Source: AGHT+IH5OShb4hhtSROS3CploGhi1S8b/OCgr07G0OUJA+ZIGTCrkqbF2Da08w9/6IjxEf6TjbE5nA== X-Received: by 2002:a05:600c:3c84:b0:40d:8587:a781 with SMTP id bg4-20020a05600c3c8400b0040d8587a781mr1496032wmb.188.1705298904551; Sun, 14 Jan 2024 22:08:24 -0800 (PST) Received: from [192.168.50.4] ([82.78.167.46]) by smtp.gmail.com with ESMTPSA id f6-20020a05600c4e8600b0040d6ffae526sm18649129wmq.39.2024.01.14.22.08.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 14 Jan 2024 22:08:24 -0800 (PST) Message-ID: <720e045a-1d5e-432e-9da8-5508eaa96720@tuxon.dev> Date: Mon, 15 Jan 2024 08:08:22 +0200 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v3 17/19] net: ravb: Return cached statistics if the interface is down To: Sergey Shtylyov , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, geert+renesas@glider.be, Claudiu Beznea References: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> <20240105082339.1468817-18-claudiu.beznea.uj@bp.renesas.com> <28754087-8685-015e-7e8a-d8c3ed26930c@omp.ru> From: claudiu beznea Content-Language: en-US In-Reply-To: <28754087-8685-015e-7e8a-d8c3ed26930c@omp.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 14.01.2024 14:22, Sergey Shtylyov wrote: > On 1/10/24 4:17 PM, claudiu beznea wrote: > > [...] > >>>> From: Claudiu Beznea >>>> >>>> Return the cached statistics in case the interface is down. There should be >>>> no drawback to this, as cached statistics are updated in ravb_close(). >>>> >>>> The commit prepares the code for the addition of runtime PM support. >>>> >>>> Suggested-by: Sergey Shtylyov >>>> Signed-off-by: Claudiu Beznea >>> [...] >>> >>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c >>>> index 76035afd4054..168b6208db37 100644 >>>> --- a/drivers/net/ethernet/renesas/ravb_main.c >>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c >>>> @@ -2117,6 +2117,9 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev) >>>> const struct ravb_hw_info *info = priv->info; >>>> struct net_device_stats *nstats, *stats0, *stats1; >>>> >>>> + if (!(ndev->flags & IFF_UP)) >>> >>> Well, I guess it's OK to read the counters in the reset mode... BUT >>> won't this race with pm_runtime_put_autosuspend() when its call gets added >>> to ravb_close()? >> >> I re-checked it and, yes, this is true. A sync runtime suspend would be >> better here. But, as of my current investigation, even with this > > No, the sync form of the RPM call won't fix the race... > >> ravb_get_stats() can still race with ravb_open()/ravb_close() as they are >> called though different locking scheme (ravb_open()/ravb_close() is called >> with rtnl locked while ravb_get_stats() can be called only with >> dev_base_lock rwlock locked for reading). >> >> A mutex in the driver should to help with this. > > Why don't you want to mimic what the sh_eth driver does? I thought it can be replaced by the already existing IFF_UP flag from ndev->flags. Investigating it further while trying to address this concurrency issue made me realize that it fits to address the issue you mentioned here. Thank you, Claudiu Beznea > >> Thank you, >> Claudiu Beznea > > [...] > > MBR, Sergey