Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp853863lqj; Mon, 3 Jun 2024 02:54:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3JqkXcusIO70Hbz3kQL6OqvsaY0GlIGSJ3GYCRjfgKnIDJxxubl/dHsbfRjDD09/6ZTOJ2umvNf2b/KUJVS9A9CYtxJt35srh5IVZ7A== X-Google-Smtp-Source: AGHT+IEhfxF3JySJXIkSwB43IobgEijtt2ed7/S2AXoGJQiAN6mrSIlql3OA9ry930am//kX7qry X-Received: by 2002:a05:6a00:1383:b0:6f8:b57f:5791 with SMTP id d2e1a72fcca58-70247891066mr10141848b3a.26.1717408445973; Mon, 03 Jun 2024 02:54:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717408445; cv=pass; d=google.com; s=arc-20160816; b=zqpjzlUY3u7aXaWmtiT+ezZBDdIN0EFm2Ojymh8pFWVkvuHb/x9sJDZ47YYp9jwxii D4XoUL7q88j9RnzDAwxy0QP/0B70Lbf0ruDSCmHYRewLqLbAJJW31AK93VGrwz8Fj/xk Jr4N5nU4HM536svPsL8XPjZR4xiPhvnGbTd2/6yjNhVbjI6NaRfCYjorzC2BX8rFCNk9 hiu2NV/NrMmVihe6xKP5N7WYa2vSSiJmA3Rw1fL42Th775n1377VyTKhBF2+eETaa/O7 ekAxop0HwfqIT4HuD3/iLtk5TVo/2ZVi+2/Xnjt39OQ6tWGW2fXrHS6gufht+h+3dUa4 t45g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=3nWKy6AKKd5kBCqS4Y/8g3wOqFQkOvvYM77V/sj1yk4=; fh=PSnr8OEb0cyQ40ZxVpSVxRv9ogMqHCPT67dKszSgyqs=; b=JElawMOgOvFcdBLZ+OptAhLyHO1PSJjad7UnsT7uf+D+M44Fg2Ip7RovN/uRzxf4gi QDAOxNnpt7KoSUG3ZDUrArYDdWBnbNQZkceHi3XuZe5Sl++WsB2QfSIDdOpYCuQiqhrM z2Dr73bF8d3QgLp8THLINVmvvXOXRnoC+TsyvqdafBlNoMKGpYt5XLW8aRFnFd+CZqCB TepMx08g936aTSB6vQvgHN1MhTJ2L2LGllpKzMLN8zSu9DoIVf8f4alO0To69EPkm3TR tbdtVKQ7M4C2p0p9nlYMlOvlpk9NfJujraLJzhULe/sho9NduRIjZJFkltyUJTWM/TIK n6ZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@datenfreihafen.org header.s=2021 header.b=EJ61GY7M; arc=pass (i=1 spf=pass spfdomain=datenfreihafen.org dkim=pass dkdomain=datenfreihafen.org); spf=pass (google.com: domain of linux-kernel+bounces-198924-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198924-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-70242c295aasi6235155b3a.295.2024.06.03.02.54.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 02:54:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198924-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@datenfreihafen.org header.s=2021 header.b=EJ61GY7M; arc=pass (i=1 spf=pass spfdomain=datenfreihafen.org dkim=pass dkdomain=datenfreihafen.org); spf=pass (google.com: domain of linux-kernel+bounces-198924-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198924-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8600B283432 for ; Mon, 3 Jun 2024 09:46:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F191A129A67; Mon, 3 Jun 2024 09:40:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=datenfreihafen.org header.i=@datenfreihafen.org header.b="EJ61GY7M" Received: from proxima.lasnet.de (proxima.lasnet.de [78.47.171.185]) (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 ACE8B84FD8; Mon, 3 Jun 2024 09:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.47.171.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407632; cv=none; b=M3iW45BqTi6pwt2iRVxz1ZLBs4CarQZp72eJa+s5r84/I0p4fe40fDCnel3eYR3i0fyuNvGLHa3P1e9MAXIn7bb46XySjtXustfCKT9XxduPkHJr606XyFHijYr+rSjCuYk+Y4NPGQVOrIUwvGDAhV9h+YwA523SSRIWg7fBmiQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407632; c=relaxed/simple; bh=oVDr4kqufAv/dxzz5Lxq0u/Ascj3+Nvd6O3eZYaIXi4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DKzkhEnMlebmBVJQ9G5Oj5rCk+kNf8VvUW9bQJxCfHa/HG6vr5tm/3Gmdx9BuqmBGaTixV6+bU9K51mikxXI+wnx8B7FxtFe3fodVilJdm8Qj92ddL1Uz2BzJ3+WL/sIFcPkQTxBfrsPWia8ALxBX/Gr96R/YgZ9c/nHq/4/vEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=datenfreihafen.org; spf=pass smtp.mailfrom=datenfreihafen.org; dkim=pass (2048-bit key) header.d=datenfreihafen.org header.i=@datenfreihafen.org header.b=EJ61GY7M; arc=none smtp.client-ip=78.47.171.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=datenfreihafen.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=datenfreihafen.org Received: from [192.168.2.51] (unknown [45.118.184.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: stefan@datenfreihafen.org) by proxima.lasnet.de (Postfix) with ESMTPSA id D8BCDC063F; Mon, 3 Jun 2024 11:33:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datenfreihafen.org; s=2021; t=1717407209; 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=3nWKy6AKKd5kBCqS4Y/8g3wOqFQkOvvYM77V/sj1yk4=; b=EJ61GY7Mjdnz4zlqQCfRKO0kKsMMgfxuNIV77s8WH2+buDVSdhFI9jBEksT4vaHhzgSTU8 M+CCD72vV+LLeHk90K2xcf9/Uo8oLScKiaU5d9QPJBDMPymDXjhbQcEYUpVgKM2ejD8wnK +cS2KGFGquZtu1UrFPmviX332DzaRqpyRU5d77CgkL+H5T/h498dQ34qQrmVBm2YP9Ce1s 5LGnkbhY3ElztedPf86I09ypKV1JoGl3C6U93c3YGz7GxHV9dn6fsj4hns8retU3z3gc07 FYpZOvZohcH1Y3+vGTu5X6oS586w68ltei+5vdJLK3oGQvAhEJLFGlFighqv1g== Message-ID: <41e4b0e3-ecc0-43ca-a6cd-4a6beb0ceb8f@datenfreihafen.org> Date: Mon, 3 Jun 2024 11:33:28 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net: mac802154: Fix racy device stats updates by DEV_STATS_INC() and DEV_STATS_ADD() To: Yunshui Jiang , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wpan@vger.kernel.org Cc: alex.aring@gmail.com, miquel.raynal@bootlin.com, davem@davemloft.net References: <20240531080739.2608969-1-jiangyunshui@kylinos.cn> Content-Language: en-US From: Stefan Schmidt In-Reply-To: <20240531080739.2608969-1-jiangyunshui@kylinos.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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! regards Stefan Schmidt