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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42AD9C433EF for ; Fri, 15 Apr 2022 13:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354131AbiDONsW (ORCPT ); Fri, 15 Apr 2022 09:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235290AbiDONsV (ORCPT ); Fri, 15 Apr 2022 09:48:21 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B05F18385; Fri, 15 Apr 2022 06:45:51 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id A45F9C0011; Fri, 15 Apr 2022 13:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1650030349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r5e/ituSe4Bvmn7/ipiIp9xLyWhKGgopzYJiAYxoSB0=; b=dP1/xN0GlD+5NO3uXdngygB6HWCd34pEyuj2uJZuOjEhCjNV8KDx/W6DPiiCDOqogfDQqV DmuZrWkzeibO1RY6xPNIXlHafkYusP16Mw5fhuJEM2RKlPCTUd7Ysw24zp4lbQvZiqKj5Y APIDQs52Lr/5dCbwI2iwQ7wcVPBv3cKPgbz51JA368MmF/XLK6pDNMq1Xj++bDH82Vy/ys 16bqIrZe+CurQqZG/ji7Gx9s7sS4DFvQXUqMpLLXSJt1yxAJZNgzuUtKIw/tCVzzFfaZBw UNjrh1QHY1OwWY6iCBmpi5uds62SenhMsbzgdOv784fwRMQ3P5qd48Iyl75K7Q== Date: Fri, 15 Apr 2022 15:44:20 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Andrew Lunn Cc: Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Geert Uytterhoeven , Magnus Damm , Heiner Kallweit , Russell King , Thomas Petazzoni , Herve Codina , =?UTF-8?B?TWlxdcOobA==?= Raynal , Milan Stevanovic , Jimmy Lalande , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH net-next 07/12] net: dsa: rzn1-a5psw: add statistics support Message-ID: <20220415154420.128a0fca@fixe.home> In-Reply-To: References: <20220414122250.158113-1-clement.leger@bootlin.com> <20220414122250.158113-8-clement.leger@bootlin.com> <20220415140402.76822543@fixe.home> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Le Fri, 15 Apr 2022 15:37:38 +0200, Andrew Lunn a =C3=A9crit : > > > > +static void a5psw_get_ethtool_stats(struct dsa_switch *ds, int por= t, > > > > + uint64_t *data) > > > > +{ > > > > + struct a5psw *a5psw =3D ds->priv; > > > > + u32 reg_lo, reg_hi; > > > > + unsigned int u; > > > > + > > > > + for (u =3D 0; u < ARRAY_SIZE(a5psw_stats); u++) { > > > > + /* A5PSW_STATS_HIWORD is global and thus, access must be > > > > + * exclusive > > > > + */ =20 > > >=20 > > > Could you explain that a bit more. The RTNL lock will prevent two > > > parallel calls to this function. =20 > >=20 > > Ok, I wasn't sure of the locking applicable here. =20 >=20 > In general, RTNL protects you for any user space management like > operation on the driver. In this case, if you look in net/ethtool, you > will find the IOCTL handler code takes RTNL before calling into the > main IOCTL dispatcher. If you want to be paranoid/document the > assumption, you can add an ASSERT_RTNL(). Ok, I'll look at the call stack in details to see what locking is applied. >=20 > The semantics for some of the other statistics Vladimir requested can > be slightly different. One of them is in atomic context, because a > spinlock is held. But i don't remember if RTNL is also held. This is > less of an issue for your switch, since it uses MMIO, however many > switches need to perform blocking IO over MDIO, SPI, IC2 etc to get > stats, which you cannot do in atomic context. So they end up returning > cached values. >=20 > Look in the mailing list for past discussion for details. Ok, thanks, >=20 > Andrew --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com