Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp304805lqh; Fri, 31 May 2024 01:39:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUwpVxpV8ZiGmpTIVMLOsymN93hqlUzQanajK4KQ4aRh1DoFjqgfOBIXVdC54Rxv65gD7l8zVsn6xHJwIqT2/eUTFUcgWG8G/gsvz5vwQ== X-Google-Smtp-Source: AGHT+IH7F/m396SPZgdVuXp0gTW/xLsTnqsbWHhIaiwMMjbcgavamVflMh321SELjlKSWPrzZ//X X-Received: by 2002:a05:6102:2a66:b0:47c:2123:4539 with SMTP id ada2fe7eead31-48bc2124585mr1232903137.20.1717144747895; Fri, 31 May 2024 01:39:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717144747; cv=pass; d=google.com; s=arc-20160816; b=aYdUYPKoyjwsioDgPVXU530mEB/vxKbDS4VyGiWiERUUjZQXkO7RIYaVrt9TJgxjtd WaTwfjLRRn1hbbpwy+PeSpMqCfUmbblLXTY6BscXKM8/RacFjWvYoUiHDs7Z9DSQGA4E IfaYx73MGYY89ycQL00PSKact9noHCTQ7OLIS2STFlAY/0YtI6zdALEnFxhZfxeViRcj 7XJ9HusgueT9pOB9AkLcN0gObqRCtffVy8P90+EUZ1jrsK3lETfOvINXoKTRr9VXra11 29xQXq87ENouGYvFE8cXS+tpJnCB9LlfGuCJPR12gHB9OfHWdw6rhs/ie5g7eQKFRENH 4IXg== 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:message-id:date:subject:cc:to :from; bh=LWIlOjPfd/vYHmdNyYoLElZXzz/IC3qCgzBCvp6L2hg=; fh=adv+8zc8HhLW+rW8/bApv98qbisj/IQWfLAr1f6EMSw=; b=x92pHDSS0GoqkTBiFEmkezoH1gm6YFSgEGyfKE+mU/7nh6J4Qm+Xqgq5akz0Y3AIMF KkHhWXeP+ZncrDJmAcUmkdCX7BrJ5aSSG3sisb2m3P5BdJrstVzdwJM/9SxlJfaHZ4cX GxcF8XVKwgCQp9axC3dWey0kVXzIB9iEW2cPQg4dB82ctKqequYWaAzI04TdLFZ9LlAa u7IbSC4CbGu11Q/wFVD4ScqAAyk/45abPHp23u2BkULm7N/sK/G5ExJy19OPVY1NbDSt yGfy8SyLwqbF4Z5cO6VM/KDrNIXnTizRr9htAPLLXTAu6nrFLZ5lyJP9GPc//TEEsXpc kHZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-196489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196489-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794f2f176fasi164435785a.178.2024.05.31.01.39.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 01:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-196489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196489-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 912EE1C240C3 for ; Fri, 31 May 2024 08:39:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C17081509B0; Fri, 31 May 2024 08:38:52 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 E1B871509A0; Fri, 31 May 2024 08:38:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717144732; cv=none; b=ZlnX8HIhpcTulA4GKqORC3nsP1vYMngaBkK/r0dHQpuOxrl1EA437e28d5FRB2VRkyTOSS0oDtQiUGEGYIRtrozsVBwAjoKS0F7YtxX1oCZY0LmDz127uqoTVf4C6zjKuk5ir72JqnKmbhFPyUdt8p6+nqTZ5SCEIOpKDOyANGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717144732; c=relaxed/simple; bh=EllydnyfeYldFu/EBpUAeZrS0zgaVpolpK1I6EowbuA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=FmDhGOEPd6cJzN/hU3lPJNUp1hCerQkQzWpSpZYJs887D9/gNAeGns+eoYRLK3+9hBdnRy3iZQDK4Ui+7KwoTJKJxFtHeuapuSF/p7dYf+4bxzU3tsU+9GJHGJ6fah0aiBCxe3PZH2+H1RVr6ppXNCnLjRtAWhLW9WM1szM6vmc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 3061b1421f2911ef9305a59a3cc225df-20240531 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:c99a51ee-a07a-4200-805f-7e8eaae0afd6,IP:20, URL:0,TC:0,Content:0,EDM:-25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,AC TION:release,TS:-20 X-CID-INFO: VERSION:1.1.38,REQID:c99a51ee-a07a-4200-805f-7e8eaae0afd6,IP:20,UR L:0,TC:0,Content:0,EDM:-25,RT:0,SF:-15,FILE:0,BULK:0,RULE:EDM_GE969F26,ACT ION:release,TS:-20 X-CID-META: VersionHash:82c5f88,CLOUDID:18d63e66079d3071e08c677f7dc8762d,BulkI D:240531163844I27RDKAM,BulkQuantity:0,Recheck:0,SF:19|44|66|24|17|102,TC:n il,Content:0,EDM:1,IP:-2,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_FSI,TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD X-UUID: 3061b1421f2911ef9305a59a3cc225df-20240531 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1258249045; Fri, 31 May 2024 16:38:43 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 8160FE000EB9; Fri, 31 May 2024 16:38:43 +0800 (CST) X-ns-mid: postfix-66598C93-390090898 Received: from kylin-pc.. (unknown [172.25.130.133]) by mail.kylinos.cn (NSMail) with ESMTPA id 2C35DE000EB9; Fri, 31 May 2024 16:38:42 +0800 (CST) From: Yunshui Jiang To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Yunshui Jiang Subject: [PATCH] net: caif: use DEV_STATS_INC() and DEV_STATS_ADD() Date: Fri, 31 May 2024 16:38:40 +0800 Message-Id: <20240531083840.2644162-1-jiangyunshui@kylinos.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CAIF 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/caif/chnl_net.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c index 47901bd4def1..376f5abba88d 100644 --- a/net/caif/chnl_net.c +++ b/net/caif/chnl_net.c @@ -90,7 +90,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cf= pkt *pkt) break; default: kfree_skb(skb); - priv->netdev->stats.rx_errors++; + DEV_STATS_INC(priv->netdev, rx_errors); return -EINVAL; } =20 @@ -103,8 +103,8 @@ static int chnl_recv_cb(struct cflayer *layr, struct = cfpkt *pkt) netif_rx(skb); =20 /* Update statistics. */ - priv->netdev->stats.rx_packets++; - priv->netdev->stats.rx_bytes +=3D pktlen; + DEV_STATS_INC(priv->netdev, rx_packets); + DEV_STATS_ADD(priv->netdev, rx_bytes, pktlen); =20 return 0; } @@ -206,14 +206,14 @@ static netdev_tx_t chnl_net_start_xmit(struct sk_bu= ff *skb, if (skb->len > priv->netdev->mtu) { pr_warn("Size of skb exceeded MTU\n"); kfree_skb(skb); - dev->stats.tx_errors++; + DEV_STATS_INC(dev, tx_errors); return NETDEV_TX_OK; } =20 if (!priv->flowenabled) { pr_debug("dropping packets flow off\n"); kfree_skb(skb); - dev->stats.tx_dropped++; + DEV_STATS_INC(dev, tx_dropped); return NETDEV_TX_OK; } =20 @@ -228,13 +228,13 @@ static netdev_tx_t chnl_net_start_xmit(struct sk_bu= ff *skb, /* Send the packet down the stack. */ result =3D priv->chnl.dn->transmit(priv->chnl.dn, pkt); if (result) { - dev->stats.tx_dropped++; + DEV_STATS_INC(dev, tx_dropped); return NETDEV_TX_OK; } =20 /* Update statistics. */ - dev->stats.tx_packets++; - dev->stats.tx_bytes +=3D len; + DEV_STATS_INC(dev, tx_packets); + DEV_STATS_ADD(dev, tx_bytes, len); =20 return NETDEV_TX_OK; } --=20 2.34.1