Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1284016lqj; Mon, 3 Jun 2024 16:56:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcXfUclmc7Y4IqrNXI6Nz4YbgH8xllQkm37mPUQSql/XTfuGzB2UGIScEoUWhd5LxfBcbIbRGfn8XtqRddmAYuTr3bLiNu4Xh7jZwmNQ== X-Google-Smtp-Source: AGHT+IHq8MBQknJdxMt80gyoFM7deEnAWp1+UJGasLP8RGkYkdHmNOOkJGETya5MPD5PVzjP6YgD X-Received: by 2002:a05:6512:143:b0:52b:4ae8:46d9 with SMTP id 2adb3069b0e04-52b89521e23mr7839597e87.5.1717458969840; Mon, 03 Jun 2024 16:56:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717458969; cv=pass; d=google.com; s=arc-20160816; b=HAjrVUN9cDl7Iikx7Q1QwMB5wycKitO1a3tzNtYddRFSa7iTjd+gQjupLlPB92FrLF 8fQYUDAURgcXHpfNg0EOCkGsyb9GYJhLHXIWPRrufzcJFn30llnZo3UsFiQoAeXy2lWH Vgru3JVbPKhtsoPs5wlYMXpLq5fJl1HHi/4C4ZPshMivq9/qJl6rSskLdYubuUOSP1+s rRrlzy+wDAAttYnb4PkQgpfNAv0qkOcf5OSYMPG/ddqPPyw83GAwG7yFV9ibIUaWjzv0 bECdBECOAjroc/vvvVRJi3Ph06ubLEPjy6b/Z2TRUGNltk3Ct1A8cLRU6fVFyBrIUqAF VG0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=oJO1+zZTBsulX6SqWV6VvRfn6Se4lu+X0/aZO4oxm7U=; fh=laJ16KISl3E4IMYg1V+QS1rfNYaN4x2KmEsTE7D5/L4=; b=Q1SGoFGY2vaODcsQIKj17d9ZQ7HVBzFhhNczlz0WDXPceb6Wh6DZEkxN+qSY0qmfjl VXSXxbrMZzPv05KCYUihtEOEtlDwDvGGyxtVeH4ccqP530Fe/TvpR116VQ6AYQk5YLba TyDduYvj4RFelpCLTHzf9N+d7BnoOMUyBg5sOgCTR4+vqu8XIUKal0i9KFbfbaQoX5JV MIgVSaCtQBlkOHNZsChYfckU6GbHyuGs+fPNLjRLzwA55wCVzfhfQM5ItmW1j5mgQ99s 9cyv/QG+zXX6jfr2wtNZzyGfpOKIv5ZrhLvOBlg0nUT5A5V1RDrFUVOa7iPorLljx10L wDGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WlRi+oWm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199851-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199851-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a68a1162f29si338110166b.295.2024.06.03.16.56.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 16:56:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199851-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WlRi+oWm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199851-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199851-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 62F801F23D96 for ; Mon, 3 Jun 2024 23:56:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BB6213D2A6; Mon, 3 Jun 2024 23:55:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WlRi+oWm" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A91513D27C; Mon, 3 Jun 2024 23:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717458945; cv=none; b=ZK+we3iWSOlswZQeBWEzHyg3SWi0B7d3gXkUygEAkoUdMeZ3AecqXWLON+z9iLHqmPgpWMPIJq6Yv/H9kxpXII8O/uPcRgEJPm7ByWNccg7s3CGEWQEsk5DpmPUWeKQvaZ0WL0a568C4ay7IhObprFZjcm+OOiyhoQDeRyKRzrc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717458945; c=relaxed/simple; bh=49k/N76rSkVbMyCGLrPhdc2JjNR5PlQ62XZdNfocVbs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L9mr/AZVYiIh9uDc1tc+LvRFKTuouiEIASQGq/N+7HLEor/CJ0HGv21AgD+L11b2F+KVSCPdUVUxiGfgCfVVvi6MHX47kl++v1yNhnROM6BLhRi3CqnvHqa90lx3DNTGo8wnSGi3dWld5OCj6WpkjIobGiaOF/NssH3PFNujN7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WlRi+oWm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81023C4AF08; Mon, 3 Jun 2024 23:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717458944; bh=49k/N76rSkVbMyCGLrPhdc2JjNR5PlQ62XZdNfocVbs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WlRi+oWmLYzBZTR6yAynA1gYroOpWQjYROAm3XdTW6F7sdZE+3zLn0NXGq+dP3tqg jhADpCe+kTJgFJVxKpk8qQqlVLcxqYFhrNYn0PjaefenZtiggA9AFqW3Lp3Q3UYM/y dQ8ao6cnwSympOJ2LS5FctYKLXPGlUNLcFeunQgB3ysZ2w5j4PhjPny3jHo/0x4NLW ZphXB3cIEfn/6vYUc9BM1c6NR093v4Xuq0dvs2oqhku2u9RMhpojrqO9tSqAu8KXzy KxmjHx1nhpFglnFenNc3jSQCp2MtBOUWG6dFd902ktdrnhCLg6v/m2tFjiu6yUXDgp WSPxjnBLZVPew== Date: Mon, 3 Jun 2024 16:55:43 -0700 From: Jakub Kicinski To: Stefan Schmidt Cc: Yunshui Jiang , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wpan@vger.kernel.org, alex.aring@gmail.com, miquel.raynal@bootlin.com, davem@davemloft.net Subject: Re: [PATCH] net: mac802154: Fix racy device stats updates by DEV_STATS_INC() and DEV_STATS_ADD() Message-ID: <20240603165543.46c7d3b4@kernel.org> In-Reply-To: <41e4b0e3-ecc0-43ca-a6cd-4a6beb0ceb8f@datenfreihafen.org> References: <20240531080739.2608969-1-jiangyunshui@kylinos.cn> <41e4b0e3-ecc0-43ca-a6cd-4a6beb0ceb8f@datenfreihafen.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 3 Jun 2024 11:33:28 +0200 Stefan Schmidt wrote: > Hello. > > On 31.05.24 10:07, Yunshui Jiang wrote: > > mac802154 devices update their dev->stats fields locklessly. Therefore > > these counters should be updated atomically. Adopt SMP safe DEV_STATS_INC() > > and DEV_STATS_ADD() to achieve this. > > > > Signed-off-by: Yunshui Jiang > > --- > > net/mac802154/tx.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c > > index 2a6f1ed763c9..6fbed5bb5c3e 100644 > > --- a/net/mac802154/tx.c > > +++ b/net/mac802154/tx.c > > @@ -34,8 +34,8 @@ void ieee802154_xmit_sync_worker(struct work_struct *work) > > if (res) > > goto err_tx; > > > > - dev->stats.tx_packets++; > > - dev->stats.tx_bytes += skb->len; > > + DEV_STATS_INC(dev, tx_packets); > > + DEV_STATS_ADD(dev, tx_bytes, skb->len); > > > > ieee802154_xmit_complete(&local->hw, skb, false); > > > > @@ -90,8 +90,8 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) > > if (ret) > > goto err_wake_netif_queue; > > > > - dev->stats.tx_packets++; > > - dev->stats.tx_bytes += len; > > + DEV_STATS_INC(dev, tx_packets); > > + DEV_STATS_ADD(dev, tx_bytes, len); > > } else { > > local->tx_skb = skb; > > queue_work(local->workqueue, &local->sync_tx_work); > > This patch has been applied to the wpan tree and will be > part of the next pull request to net. Thanks! Hi! I haven't looked in detail, but FWIW $ git grep LLTX net/mac802154/ $ and similar patch from this author has been rejected: https://lore.kernel.org/all/CANn89iLPYoOjMxNjBVHY7GwPFBGuxwRoM9gZZ-fWUUYFYjM1Uw@mail.gmail.com/