Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3475338rdb; Wed, 13 Sep 2023 13:13:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3SwN/r63a7fHqUC7vJobChgBjYazgsugBZ0FgJji2noD9mw2ocWUKRemnFxxhV7YiFAUq X-Received: by 2002:a05:6a00:22c9:b0:68f:d6db:5d4b with SMTP id f9-20020a056a0022c900b0068fd6db5d4bmr5647561pfj.12.1694636001275; Wed, 13 Sep 2023 13:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694636001; cv=none; d=google.com; s=arc-20160816; b=qi54Sx3sFnpAlh+akgmbhWXFNOsiV0+E0Ma3UB2LJX0HyX8L1r83ca1QchWu6eNTec Q9sHEYnz6YF67Ym3hAiK50PLbnU8z488HrOLMZIdG6J4sfU8jsyFQw1g7Xpgnk95WGv5 jgoNK8oZYPPy0apw6sNmU/nZBht6yGcp5cE81C/5dRJyOPgq7ee6aZcdx6xZCYFouhh7 MPlyLfT7AlD80l81Z7aYzV4K3YehGzCx361BrvbCKDePQQ09qCOQleKbYpVhngMoWIwC YS9LhdG4fwEGrO3fTyNCQfVmDyZUJEl30UVyuOU6l2zFqrOMO26wG6mA5CGBexJ9+n7g IkiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=XoBaM2FvjCf5nwKNqi//Rd9OwpEhbK9iU7y/DYRoZYA=; fh=ou4kKxGdyGJKcBT4RCe7HG5FYm3MXBHF87XEkbTAqDg=; b=A8/PFheXiqW6G+9xDkGKsZWyQr+Yi+Jdx8ILMD+5X9Y1Zgd5FFhOMwICi5N5PFmrLC CooUU86Uxg3F2gcyV3cVqCuXbzEsWft3gnPAhtvohl6Y9DSbOOsIozXylkAl1D36JZ24 IfC2CWb6lqMVc0RSVCgAUgoFPC38j/o6inqDkflo6jFMcQ/Fp39hSLkUYyaafbDZ4z8P z5oojlfNfxSMrwxLNb79sI3OO03nxC394TU9Huwfu++u8HMmr+aqdjlMA+2k07T1XdAb L6kl2EHwqka7FRbfU3uNPx2Lo6KTLE6f3OiUhMC95+vtdjdwrukS1loAL65YK6+ayCH3 1bpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u1-20020a637901000000b0057763b28f63si7173279pgc.506.2023.09.13.13.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:13:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 65EE381DFD77; Wed, 13 Sep 2023 13:12:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231918AbjIMUMa (ORCPT + 99 others); Wed, 13 Sep 2023 16:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbjIMUM3 (ORCPT ); Wed, 13 Sep 2023 16:12:29 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5617C1BC6 for ; Wed, 13 Sep 2023 13:12:25 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qgWDi-0001jv-1g; Wed, 13 Sep 2023 22:12:18 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qgWDd-0069Er-3M; Wed, 13 Sep 2023 22:12:13 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1qgWDc-001Q1d-Pi; Wed, 13 Sep 2023 22:12:12 +0200 Date: Wed, 13 Sep 2023 22:12:12 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Jisheng Zhang Cc: Johannes Berg , Paolo Abeni , kernel@pengutronix.de, Samuel Holland , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Alexandre Torgue , Jernej Skrabec , linux-kernel@vger.kernel.org, Jakub Kicinski , Eric Dumazet , Jose Abreu , Maxime Coquelin , Giuseppe Cavallaro , Chen-Yu Tsai , linux-sunxi@lists.linux.dev, "David S . Miller" , linux-arm-kernel@lists.infradead.org, Lucas Stach Subject: Re: [REGRESSION] [PATCH net-next v5 2/2] net: stmmac: use per-queue 64 bit statistics where necessary Message-ID: <20230913201212.eiedub5rsztuwaa7@pengutronix.de> References: <20230717160630.1892-1-jszhang@kernel.org> <20230717160630.1892-3-jszhang@kernel.org> <20230911171102.cwieugrpthm7ywbm@pengutronix.de> <99695befef06b025de2c457ea5f861aa81a0883c.camel@pengutronix.de> <20230912092411.pprnpvrbxwz77x6a@pengutronix.de> <2fcc9fb0e40ceff8ea4ae55cca3ce0aff75a20ca.camel@sipsolutions.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dpbv4jds3tisu2kp" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 13:12:33 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email --dpbv4jds3tisu2kp Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, On Wed, Sep 13, 2023 at 10:34:42PM +0800, Jisheng Zhang wrote: > On Tue, Sep 12, 2023 at 11:30:14AM +0200, Johannes Berg wrote: > > On Tue, 2023-09-12 at 11:24 +0200, Uwe Kleine-K=F6nig wrote: > > > >=20 > > > > The newly added "struct u64_stats_sync syncp" uses a seqlock > > > > internally, which is broken into multiple words on 32bit machines, = and > > > > needs to be initialized properly. You need to call u64_stats_init on > > > > syncp before first usage. > > >=20 > > > This is done. The problematic thing is that in stmmac_open() -> > > > __stmmac_open() the syncp initialized before is overwritten by > > >=20 > > > memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf)); >=20 > Thank Johannes and Uwe for pointing out the issue. >=20 > > >=20 > > > Do I need to point out that this is ugly? > >=20 > > I think it also leaks the (lockdep) state since it reinits the syncp > > (and a lot of other state) doing this. This is also called when the MTU > > changes. > >=20 > > Also, I couldn't convince myself that it's even race-free? Even if it > > is, it's not really obvious, IMHO. > >=20 > > So it seems to me that really this needs to be split into data that > > actually should be reinitialized, and data that shouldn't, or just not > > use memcpy() here but copy only the relevant state? >=20 > Since we are in rc1, I need to fix the bug with as small changes as > possible. so another solution could be: replace rx/tx stats structure > with pointers, then setup pointers in the new allocated dma_conf with > the old one as current code did for dma_tx_size/dma_rx_size in > stmmac_setup_dma_desc(): >=20 > dma_conf->dma_tx_size =3D priv->dma_conf.dma_tx_size >=20 > Is it acceptable? I wondered if you can just initialize the data directly in *priv, instead of setting up a local copy, initialize that one + copy it over?! Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --dpbv4jds3tisu2kp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmUCF5sACgkQj4D7WH0S /k5YqAf/QoHjd1H4OMaQOFFZq5Z1GnCqzupN9tFvF4XnK2Y0RUzjcmrLVkjEZSvA GbuGtwdxWJr8ixqCzqbfibyZAY7i8nK6se1X4wOUikFWfsd4VVlMAvLwyvZDIeEM 6EmLYW1jMo6O+PvxapPzIKtKkNuO51/BmZ1pLy40UKINT8txpwMrCLSvCJgGTbhr abaJvfJZS2Pel0QVCkYpm7dqX7pNPmLiNlDXwJwatnQrT2FmSxH1ftchDS3KE4Rl QSFlKi7cYMQydd8QZp3i4NzQ+xeTWL0WROSxm7p376NFUYItnDXIBmMw0MvkyL82 XY/qJUJCraljLXTiRlSGhrHVHDMUqQ== =fL1E -----END PGP SIGNATURE----- --dpbv4jds3tisu2kp--