From patchwork Tue Apr 16 07:42:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13631494 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F1CF386 for ; Tue, 16 Apr 2024 07:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713253380; cv=none; b=advcsAHjH0LAbMfqz6z5kOr+r1V+p92O4D5PsKz0GhCbSm51FYP3760beQBc8xveUOqbbBRBNHQlEPPtHRSlNPfrVIlwg6BPSnao85s5RVUmLTvciboE4gw+Hjc1R2SAbPCq2FKylUdU6BsRaapmGdBnUWrmy3gPPPFzpYA/ix0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713253380; c=relaxed/simple; bh=+KiaQPhhNId/j17RJ5WzPNy3XIrPK+vq2e8iry+j9Sw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eWDhnJIUL2IiED4siMO8VW4TOU0BPTcHdfocu1UJQIPSpt9fEaMydxXKYJzSmFvZHXtqALcpYmToPIjvLHjQy1jZQXfCHQT7shVJaFqxAYVOMb3DFAIrGCtlFYO1akYCIlqPQop+aEPcoJJYmEmjTz+LYtzECur5TOba1iXMnC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iocl2XLA; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iocl2XLA" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1e220e40998so26204785ad.1 for ; Tue, 16 Apr 2024 00:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713253379; x=1713858179; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9ZosKZuOLgAT2ovMTpFweL1hNrHDeyLIvW/nqMPw+0A=; b=iocl2XLAvWOrbTe9bzWOSYOL+w3OBsZQnObO0f096U/MlHPXcXzSKuFQU54W1NULTX yGQCVvPe0yqBWwBqu3pAu/qjA4gSvyuvhIsnid5VfO/bTmWcHQ5HMmLjHRIGTWB99goK ye35dyVO6aW70s0JP1hin6WDXXJrKUBiLSV1s1aSGUt46zCh0UNTW0feA4PmILFYFvP8 6YIFJXwIRyAnbLO4pQPo9t8WzmHl4/lnNG4a36QHJlwAEeRnZjOAtIl3SYqWiyFt2Ghl NP/oXdyLgR2Xaj9xiwfpv7xdsG8ivojIeiC0YsY5z7UAZjFxsb5fpIDB8LcNFuYOrb+G OAzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713253379; x=1713858179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9ZosKZuOLgAT2ovMTpFweL1hNrHDeyLIvW/nqMPw+0A=; b=Nqd9+UNCM0gGdpedTYB107nM7IUAWjRU0s9lW9Leo70UeGp02loZqfUXVAnwekoWUe RT+Z0mgZ0x4Gq6INW5p7yQrXvtBMdaBBqX8/kHm0OgqJ1Dqh6w9wQ4zYk6fGjoG4ySLI 46ONAvDVpZQT8cYZoZGcI+/l4m3QdKi/w5LTP8Uh+iKp/hqmsg6h7hscEy7xSpOmPUsd chCI2t1L+VEtt8Xgj975lQnRGRHyYY6wnt3gCsFxGjjL7kbIlVIBjfpebqfwd4AwVIEd LiGRX+pF7Nnz1OnAGIghYQnCNAAV7MskaoX1//0S63bJEo8CrCL08Xvjj21dNsHN7vWk G7aQ== X-Gm-Message-State: AOJu0YyNg+69OEgPq8Ubfs4DiDRU4Ty9f07taPJ3F0F3rif4s1jIGoIw vyI/UvKf7ZVA954UlUyXLcaIjRaqtS94efVMRtJVUFc6rq+ZZvMj X-Google-Smtp-Source: AGHT+IHCPHTboGti0enEZwboHZyMvx5bMbgE9zxAsAYRxRME5fkXZFMzUhhf9kLL6QkbJqUdVly98w== X-Received: by 2002:a17:902:f68f:b0:1e2:a449:da15 with SMTP id l15-20020a170902f68f00b001e2a449da15mr13847892plg.15.1713253378585; Tue, 16 Apr 2024 00:42:58 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d16-20020a170903231000b001e4881fbec8sm9126947plh.36.2024.04.16.00.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 00:42:57 -0700 (PDT) From: Jason Xing To: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, horms@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next 1/3] net: rps: protect last_qtail with rps_input_queue_tail_save() helper Date: Tue, 16 Apr 2024 15:42:30 +0800 Message-Id: <20240416074232.23525-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416074232.23525-1-kerneljasonxing@gmail.com> References: <20240416074232.23525-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Only one left place should be proctected locklessly. This patch made it. Signed-off-by: Jason Xing --- net/core/dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 854a3a28a8d8..cd97eeae8218 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4501,7 +4501,7 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb, struct netdev_rx_queue *rxqueue; struct rps_dev_flow_table *flow_table; struct rps_dev_flow *old_rflow; - u32 flow_id; + u32 flow_id, head; u16 rxq_index; int rc; @@ -4529,8 +4529,8 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb, old_rflow->filter = RPS_NO_FILTER; out: #endif - rflow->last_qtail = - READ_ONCE(per_cpu(softnet_data, next_cpu).input_queue_head); + head = READ_ONCE(per_cpu(softnet_data, next_cpu).input_queue_head); + rps_input_queue_tail_save(rflow->last_qtail, head); } rflow->cpu = next_cpu; From patchwork Tue Apr 16 07:42:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13631495 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00E52386 for ; Tue, 16 Apr 2024 07:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713253383; cv=none; b=oSfmRJpRWjORg4+7xsoCpOGPcnlBmsGFYtz6MK+arc7MnWQJ9l36hmRGoAZxkjn/Ac4gmrzKnDRmdoyrnN1DOoEg9wwosts7qZb0r8cEvYv9hEQVVQbuCzBB2zVKgi0VJG16thWONzwNZW1kgWfe//JGOA5MP4O24SVQXWKV6/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713253383; c=relaxed/simple; bh=0e5hJ9hCqm6AtEKne5xfb+mesbFdHF+EcWpdCqeyrCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sVR5DFRaZimR1ViHEyFepqmZPnmQGRVTeqLxFBytbTGXHsDTMv0Mc6c/9M1Q536bj4xC8C2j3ha9aMNma7rQP0kv2KLOXqSmBHqYXRPCp7D2lt3HfoGNKBdDGnTQGfd8iaHGLXouVZiNOzXhUyOTFX9QFBw8Kue2F4Wy5PMrAio= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GUkM43Ql; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GUkM43Ql" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6ed2170d89fso3103115b3a.1 for ; Tue, 16 Apr 2024 00:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713253381; x=1713858181; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H898G6JJEBxHp64rfVnRZZcHj9mNb3/HV1umOFcpYBI=; b=GUkM43QlcqhXVoCcv4VYD5oGLWiKy3tBFVv6xDM+6mvSuCCy6P2cXmHU5jSxpwk3eQ 1p+0HDDw6COAE+RdcDPLJ4YCKIQtL5QMRrAMyw0NxjCu+N01clsco8w1K+R1DMdw8R15 paNpdb1RD7CfXTEtnA1Zx8taCL3Osk40YWgVK6ijbD90oZrsl9bz8tg79d/apRxyr3Pq 0RKZKYS3VKTOgt9mNh6BL79f9lMnmNi0rGR+VPxTZkP4p7M+cbi8FOlx0pXRpAYzCzZv 1hQJE0GOcn9LxzPb4E/IxQtIjEER5YCn/Ff8iVlsYeyrlnlTeHtr6Crj8kGXWyDH5YV1 OUZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713253381; x=1713858181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H898G6JJEBxHp64rfVnRZZcHj9mNb3/HV1umOFcpYBI=; b=nyN995o4Wh1YdCJtbGZAKQcIKc0GSE6NakzateS8ZK5z7ZKxzIyqWaKIlcebefk6ST kkH6TA5DMDHWH+8T+7ts4nMnTuV5nM0cBL6qpdbPzdx+9qoxesKDkoU3EmiNf7muNQPh a+e33+evrzSY7bLvLxAGUssPSXcDkrOLTyCvj7F7yaMxPDatiP1oa42Ssnb7/uOwVEfO 0OQXSgzpbcyjnOt/99sS+DgjvplWkp/O10odECEme/uag6Q3DTzbJ8/CVcWxsNEqAozp AFCBUoFnLR+ANxVw4FZIKGV9KfodFjwoK9wfmO0DxmS/4YCpRocdRFpcgtsl64m478aT dMnQ== X-Gm-Message-State: AOJu0Yz/Pqa4ZEOJd7OCIam0DpVTjyW+XwNW/9zKexZY/N6KZoAy8nqv /H6p+aduHLUKDPEfMk/W/d9uacjHwKLe20HRl3MzYib4xIZAzoym X-Google-Smtp-Source: AGHT+IFvgE78j//QP7QgSz1Lv608YTitPdrKKVc45b+udBFIqKqaRlOU6t1+e9V7QnEOGtClJA8ADQ== X-Received: by 2002:a17:902:d485:b0:1e3:c327:35e4 with SMTP id c5-20020a170902d48500b001e3c32735e4mr3288173plg.5.1713253381307; Tue, 16 Apr 2024 00:43:01 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d16-20020a170903231000b001e4881fbec8sm9126947plh.36.2024.04.16.00.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 00:43:00 -0700 (PDT) From: Jason Xing To: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, horms@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next 2/3] net: rps: protect filter locklessly Date: Tue, 16 Apr 2024 15:42:31 +0800 Message-Id: <20240416074232.23525-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416074232.23525-1-kerneljasonxing@gmail.com> References: <20240416074232.23525-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing As we can see, rflow->filter can be written/read concurrently, so lockless access is needed. Signed-off-by: Jason Xing --- I'm not very sure if the READ_ONCE in set_rps_cpu() is useful. I scaned/checked the codes and found no lock can prevent multiple threads from calling set_rps_cpu() and handling the same flow simultaneously. The same question still exists in patch [3/3]. --- net/core/dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index cd97eeae8218..6892682f9cbf 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4524,8 +4524,8 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb, goto out; old_rflow = rflow; rflow = &flow_table->flows[flow_id]; - rflow->filter = rc; - if (old_rflow->filter == rflow->filter) + WRITE_ONCE(rflow->filter, rc); + if (old_rflow->filter == READ_ONCE(rflow->filter)) old_rflow->filter = RPS_NO_FILTER; out: #endif @@ -4666,7 +4666,7 @@ bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, if (flow_table && flow_id <= flow_table->mask) { rflow = &flow_table->flows[flow_id]; cpu = READ_ONCE(rflow->cpu); - if (rflow->filter == filter_id && cpu < nr_cpu_ids && + if (READ_ONCE(rflow->filter) == filter_id && cpu < nr_cpu_ids && ((int)(READ_ONCE(per_cpu(softnet_data, cpu).input_queue_head) - READ_ONCE(rflow->last_qtail)) < (int)(10 * flow_table->mask))) From patchwork Tue Apr 16 07:42:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13631496 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E7F5386 for ; Tue, 16 Apr 2024 07:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713253386; cv=none; b=s5aW07OH7z4TAoQ+LBT6WIAzoOCNAhM1Ps6tQTabD0Zc2dPrt14eti3+0E9BWFtEpkFhPM+elEQesuwp4S46ftFQ6qXhS1z6P67nCKyHylQVoKXKGdpj5EEofhzdUFYaP98kFQy98q3rowBAxFJtXgv65CLpvWal9BBpyW4QFwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713253386; c=relaxed/simple; bh=QjJzx72Ii7Sp3a22OsYNQmmWTCaSJb+lVkJBTg/YtRc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P0/e/eu6MMvUc9ezf9MEU4+zHoydVBa+FzvBIKOqoK/kcdSMLOJWReSaIM8CLjqQ91TKzczp35ZNpbQuge9nfxg6zA0Kq067YBwqtjQ7YJ9aASV5yE3gyEkd++zlCsSWRyKmSlfK6WlebQIRtSFU3i6ghi5+e/vAsfE8wc1vKlE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ct08AY2j; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ct08AY2j" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1e2bbc2048eso33168705ad.3 for ; Tue, 16 Apr 2024 00:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713253384; x=1713858184; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7NF+8s2YSkm0xT9TpPeR9HkXVuzALFR5UG13Vs9IVEE=; b=ct08AY2jsvx869SZvvTKn+p2jfW0rW0i1/Yr/7qiq9PkuynyY7U92oUZMARTaosNf3 pPPh0N4NT8TewVbJXWhs0x4ur9dXTG+a67Rthvptrvm7nFqsY6iG78N5n8LiWQKK8mGG cOwFrh+YGl/TEf/Dku4snO0tWAyXxeGPwZv0xOmnt+svMwEFXFXBWE+rRGe2dVu2pnuy ejVGXFJf2My+NkbtAynPsY7Z82IISXDAqu3arb9D/V+Z+18fmb83RAmsRfK3bR7O1wG4 DCMfRLx/N/YZJAEoXtbP7blzAflDn/xMzpvjeQMNYeDxmmwQ+Rsroyl2SA4NsMtLjqaz mxBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713253384; x=1713858184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7NF+8s2YSkm0xT9TpPeR9HkXVuzALFR5UG13Vs9IVEE=; b=HLCY9CLyCJYUx63QjhEp6oNcHhObxp7YzvaLQfFMiOZpSIUaZQT9waa6X51kYgoNx8 +mGezfKaJdmMwSFfH7k15lS25oWkMNoUj7ARExP+WpbNgoh9EXvov4LJ8zpqDzIXvX1Q bZ2l+IQZyDX+eFhRNRK0HcJXWoRB5a4TO0+V23e2zerIy5/J+JszTy3zkDfuzP7mBVV5 BwoNPKQRDur/gy0AFeVgy4Z0+4AStRGE1VEeV7zGY3YaKk4K4LqB0ELGTh0hxEyIBBIk 5bDKmyQqi+xVSbcDA4pwXWsDMbX3FJoH7ExW7F37YtLdZ1IE1Vzn/Gw+HPrATMGRpuOa 2+9A== X-Gm-Message-State: AOJu0YxW1mzV3ZhsclYJmsbhxFBJpD5u8FaJMTPrLJrVlYLjGQoclNGV 0DOQU9L982mWhbpbnq25AQRt86389RUGgiFalkmTxfU8Y+l1vrHN X-Google-Smtp-Source: AGHT+IHLTl1dVWVnqEYQjV+inIDInmggx511Gyfhlk2SBRDI71FpzJ9mq1vszVaOa15II0ht3nr5eA== X-Received: by 2002:a17:902:d2d0:b0:1dd:76f0:3dde with SMTP id n16-20020a170902d2d000b001dd76f03ddemr13284595plc.31.1713253384393; Tue, 16 Apr 2024 00:43:04 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d16-20020a170903231000b001e4881fbec8sm9126947plh.36.2024.04.16.00.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 00:43:03 -0700 (PDT) From: Jason Xing To: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, horms@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next 3/3] net: rps: locklessly access rflow->cpu Date: Tue, 16 Apr 2024 15:42:32 +0800 Message-Id: <20240416074232.23525-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240416074232.23525-1-kerneljasonxing@gmail.com> References: <20240416074232.23525-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing This is the last member in struct rps_dev_flow which should be protected locklessly. So finish it. Signed-off-by: Jason Xing --- net/core/dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 6892682f9cbf..6003553c05fc 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4533,7 +4533,7 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb, rps_input_queue_tail_save(rflow->last_qtail, head); } - rflow->cpu = next_cpu; + WRITE_ONCE(rflow->cpu, next_cpu); return rflow; } @@ -4597,7 +4597,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, * we can look at the local (per receive queue) flow table */ rflow = &flow_table->flows[hash & flow_table->mask]; - tcpu = rflow->cpu; + tcpu = READ_ONCE(rflow->cpu); /* * If the desired CPU (where last recvmsg was done) is