Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3288768rdb; Wed, 13 Sep 2023 07:49:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGL+hq76vhj1P45P8Bdea3MoxHW2DfS9IXNlRM63TwOPWUi+ohXUlmk68ZMfJAnzDliqbaT X-Received: by 2002:a17:902:8c8e:b0:1bb:d59d:8c57 with SMTP id t14-20020a1709028c8e00b001bbd59d8c57mr2694166plo.18.1694616549018; Wed, 13 Sep 2023 07:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694616549; cv=none; d=google.com; s=arc-20160816; b=iEB3qdtqjqetH7aCiah9rmXM80fsG/66txkegvvI9Ue2/mo/LXlzmP72h8Iy1oFFs4 zPcXpRl0mAJ79NLsH+8+4BsJdfcep6U8i5UZvVb5c8nmoip3ZWNRIhjMyLH3A6+y/IFD 1c4e64i8LdjxlnT3RcYZINqkpniiS6PnquJxXARpL9Almg3gIGkJMFK1+TjTmPrOTl49 VIpTz65pgDO6TXNWlNg+rUeVLFegF0UEqzOKT8JsK4HelSkhJRY8HBWS/+Oj/oyX9dPJ Xqz0vJYGKKsa+QQ3igT6vmA7C9bYo0WvxF49HJjcQVrPHzYEgti3hKibN4ADBvebFRc1 oXnw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eCPNB3f8GNgVxJUpWRW/W6HKVJRrmQ84OGAFX7TCqo0=; fh=ibVdLqUnRIo9OK7Tr6NAMnQ5lBZm92fw4JYz3cyXBt0=; b=tyTA4o6GPZq4m+HlQzpyRXn5OcpfGToPsxVnwwEcBXy4x9tDjO6UwugwS2p29SR0/F 1zChD8oVQTGwpxGlwdE9dv6TIJQTluDOlrQ63ytG7NiWN7rBGUYauOGoaJG3zJ0xpmG4 QEKFmClgMJctRdhj9d6Do5YjUB53TYNu4mgbZHEADOoMfprGw7lPiVwfpK0vjSzv60Oh R8fhlhx8YUfTd767vPw/8oSQRXQtGOjSQ0NumCSsUjbwGj+bIE+XmVgNYtx2ZWH3PxFP 8Gur32mvawFBHoRRfjr8KBLLEg+duFpUm5QAF/zE1HlYmW10jltMqKDxTNwWLEvjzK4t ZXiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oGLkwU9F; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z9-20020a170903018900b001bde698074csi10498684plg.584.2023.09.13.07.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 07:49:08 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oGLkwU9F; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4FF0C801CB56; Wed, 13 Sep 2023 07:47:08 -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 S241412AbjIMOqv (ORCPT + 99 others); Wed, 13 Sep 2023 10:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241431AbjIMOqu (ORCPT ); Wed, 13 Sep 2023 10:46:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6AC398 for ; Wed, 13 Sep 2023 07:46:46 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FE9FC433C8; Wed, 13 Sep 2023 14:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694616406; bh=MEPRVLhq94lkOpBYdxRoPzKxMTXOzT6mLYuQo0C5GYg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oGLkwU9FWN+uir2AxMWDTeonZoJko3bsyCrAoEwRogRsrKE3tdrx4B9pi8+bKr/rN YNmj1snrt3z/3uMq8t3XLwRcIdtFeEX4usIBazutl44jkrrsnbzmUi+o/KlszxGhTW kQ/3EbY9WMqXrWE+yQ0jghLPZaWW+prreEFa455H+PLcHo/nLRU9nYtgaZo3JnKrPj vFqlFKnCj6MRw+R8ApLZnFn10v9011Amq+LnEVzCYWDd8jZUbGtwzr5m5NpxvdL84/ 3VKpgZuZL8GyrJ1R2wgmk36jUw1EttiwIhx9Ix80TmVPWYzmiShvDIdhGPcyxDKqwd tx3968REAuSrA== Date: Wed, 13 Sep 2023 22:34:42 +0800 From: Jisheng Zhang To: Johannes Berg Cc: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Lucas Stach , Maxime Coquelin , Eric Dumazet , Samuel Holland , netdev@vger.kernel.org, "David S . Miller" , Alexandre Torgue , Jernej Skrabec , linux-kernel@vger.kernel.org, Chen-Yu Tsai , Jose Abreu , kernel@pengutronix.de, Giuseppe Cavallaro , Jakub Kicinski , Paolo Abeni , linux-sunxi@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: Re: [REGRESSION] [PATCH net-next v5 2/2] net: stmmac: use per-queue 64 bit statistics where necessary Message-ID: 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: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2fcc9fb0e40ceff8ea4ae55cca3ce0aff75a20ca.camel@sipsolutions.net> 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 07:47:08 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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önig wrote: > > > > > > 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. > > > > This is done. The problematic thing is that in stmmac_open() -> > > __stmmac_open() the syncp initialized before is overwritten by > > > > memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf)); Thank Johannes and Uwe for pointing out the issue. > > > > Do I need to point out that this is ugly? > > 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. > > Also, I couldn't convince myself that it's even race-free? Even if it > is, it's not really obvious, IMHO. > > 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? 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(): dma_conf->dma_tx_size = priv->dma_conf.dma_tx_size Is it acceptable? Thanks > > But anyway, I have no skin in this game - just reviewing this because I > was trying to help out Uwe. > > johannes