From patchwork Wed Apr 17 06:27:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13632904 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 A15BA1851 for ; Wed, 17 Apr 2024 06:27:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713335256; cv=none; b=E/1zmHUkgO66G6aQevzTINldG2L/rO1qGOcol1hpb7W4QcuXI3HXYCCi8C95P29PT2Y+DwH0DaQ+qemAtr3YsZQIDW6J6Sv0Llqmb7A2+qmJIucAjf1YQg7o1U9+84K5CgWMCXRxZjbgVXg6mhxsATaBk7G3Q34vlaDNlW/XGvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713335256; c=relaxed/simple; bh=Gs5gJJVIQpozdEczY9HzZUbRSJ4pmuUyr8VWAYt7Krc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IeN+VW0HvD5kfh4s/m1AEeCqVf+ZzHJOSQZfqR81JDsUe1++TmkIpe647ih8Ud2S/TbUser2axpypvWD4vx/k0SLXCix0eys1lPAZfggE2xiAYhKRGkdjaQJEtsdkybnXb45lhtE196h+ulDMGrmj/FVoVIETwsgIkalbYmY5Vc= 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=f9Lmwzu/; arc=none smtp.client-ip=209.85.210.52 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="f9Lmwzu/" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6e9e1a52b74so877936a34.0 for ; Tue, 16 Apr 2024 23:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713335254; x=1713940054; 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=+3Izpu42pBrVzasccWQKJO3uxRg0LVnG55BW/QOwOnE=; b=f9Lmwzu/p5H33fpERWjBiwramsmASMx+e2CQH7bD97D9UeMBravBwVVHCI/RZlMjVT LQrpMKZ3VETOl7Ax6VZ3f+IHupRIGeoKLlcC+kgrwPU8ybSh10hWzBgSngzXI9zBG6W7 tBBUsOqZlARLZsLLYJorp0zoKkQRWVhB90stmAlzCFH2z5vH7cVytm3TZ4Q6vmE92oGx EJtb60pRsMkgYcanSVXvjBVrQu/nmWmHQKyrttu7UjJwTzVwuk+URC2+Hd49X/yRDWJd KgPM40MVD/CdonDn0C24Sex88wgqO6oSy5jAGFveShClGmwKn0Nvn4eIxK1z8anFL9Yb iIyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713335254; x=1713940054; 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=+3Izpu42pBrVzasccWQKJO3uxRg0LVnG55BW/QOwOnE=; b=IEY+25r0QLabGd/2R/+cDjFHyMzg8qeGiXR6iwRdGSGButeo7Jhh/upCDSgWvbFjmW qdJSGi92fEzKwgGog/AJS/5hkxArixSmniSJ1hjeSW6DbH3xnV3iMO5Vqw3+YPte9iDE YIzWzRhJRA18c44MTrCmm7DZQrbs/AKgwFX2eR6d+VVK2YvRMICSCW5yskXBiXJW9te3 4/8hmh84m5/tzvM+mmktLcLrTUXJL1hNO4yRIPmLiNIF3H9hAhwfqqNX3mF86ff0XweN +0sNSLRTbRbKqh0e+nuT6Q0mF5BvQNV2Lnx1d4tql1Lkt1+O8dzmztT0xsrTOwlmzSbH 7HyQ== X-Gm-Message-State: AOJu0YwFgSb01iz+AT/TDf6f5SXThLHs5pAHVHYX3mWtyic8UYiRcvSg PJCvrExmvcM3vNyvyWJAFdZv5zetjiVY7IklggYMYa2X2OxJFqjg X-Google-Smtp-Source: AGHT+IHBcmUh2cdIERP7iuXpWYeY6yJE7hNqNPqY4dr12QHvXmYc4VZc55CD6x9YdSp1Eb6etAlD2g== X-Received: by 2002:a05:6808:1708:b0:3c4:f1a1:b7b2 with SMTP id bc8-20020a056808170800b003c4f1a1b7b2mr19818475oib.55.1713335253743; Tue, 16 Apr 2024 23:27:33 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id a193-20020a6390ca000000b005dc120fa3b2sm9821006pge.18.2024.04.16.23.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 23:27:33 -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 v2 1/3] net: rps: protect last_qtail with rps_input_queue_tail_save() helper Date: Wed, 17 Apr 2024 14:27:19 +0800 Message-Id: <20240417062721.45652-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240417062721.45652-1-kerneljasonxing@gmail.com> References: <20240417062721.45652-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..2003b9a61e40 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 Wed Apr 17 06:27:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13632905 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 6F9E31851 for ; Wed, 17 Apr 2024 06:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713335258; cv=none; b=O5J+vrZesO3FE69+TK/B6ZPi8/YI+/eZ9F2TZk3StZLpdWFWYTuB7JVzZAKd1V7xn+MqWK2NcAtyJox4RxXRXi/XGc7Et47C/B3+KJv2VBhSg8NY09frIpYxDwfc3HDGSRrfKF53qiY+ST5qbmcWXeNIKohlJig/xPEeYc03A6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713335258; c=relaxed/simple; bh=LjTSwOzUYwO9FexdpM432GBKfMVRd9Bn95OsvZKpLoU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CZqIugyzxUYhBt4nfY22oVzKKbb4IwK4FFNiFVl5xVtbro8maw/a13nGYQA06UqAFkIrKzmSJLdqCIZlXu+AeorbiyeomlWPCprwSgleyrpFn+cU86Blq63We4zawzIeJHYp6lpQa547bZBjx97low/1mAjQeEMNsoQaBG0c6KE= 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=Js5fwlK3; arc=none smtp.client-ip=209.85.210.41 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="Js5fwlK3" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6eb7500abe3so2095981a34.2 for ; Tue, 16 Apr 2024 23:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713335256; x=1713940056; 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=+42Zh365pp6FZP2BKOJ2fToigQcA8JSYTE5I/4rSW0s=; b=Js5fwlK30P8v99UD67P5BOtPSL/pOUU5SPYP5Q9FTjtAHy2MXfXLek5Mwk2q+gi1I+ 7lydxlahxfLorADyrionWVpuWjNChTbbRpxCmuGMYbWWetmz8cVPrcPHUB7s248FwMbt kSw/49ntKao+s3R2UckgeEnz4tZB9GFJGAhQhAds7CyeVz7RIjE98TMukp5hm+PpfzG3 0P/pJWRTgb8W2DR2/lfp0CNM40cUP0mPaaIreghAiOYZcRRCrfDsv23mzxisEvXbovgs 5/NoGM6cedIY+PFLbEq41zEcpBFH+ujIgo0xa0jQKPIBpHx02pE2wJit1xxNcgCAaPTS 5vKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713335256; x=1713940056; 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=+42Zh365pp6FZP2BKOJ2fToigQcA8JSYTE5I/4rSW0s=; b=tkQx3niI/JIW7PcpFY3KUySyJ15zBC14bdXMX2N4VmohqJW75fLguNCjPbMPHVFvFp 7ZptfOhONhdzImzLI85pvYbaPJTPR8PV+y8prSNK/nLwd06axAyuOET1p0IUYwJhy6Ym ahFJb944jePzyu0elbT/KzTekdojKSMXxbf7vR/4SeWYJpILGP9KwGputHuFyb2E745l xou9Sxvpa0erB42TbsDpDfHqAoa0cdNo7W7Bs0L7uObEkygqPXeMEI6SgiRWqqQwJjsT 4rc0QSBeTERqVTM1AREHxD+CfVQ0rAKq9oCZCezijTde1bK8nVxzECakss4UvogE+lTS 4xdQ== X-Gm-Message-State: AOJu0YyEQUYVQL0tBGd5PRNODyFqVnDJkPKgfKNo8QQpQ2p3Ppl6MKfR h8sWGgRVRyK5zKOMBoEBdT6EaTc1RNKKezZl/lHpl55bZB30/v1O X-Google-Smtp-Source: AGHT+IH4jooJQ/7n2N66IbCzrQULZATFieco1u2Vg2/GL+al1XBlx5oMKWPkUxL5N//uKsKbl6/X2g== X-Received: by 2002:a9d:7616:0:b0:6ea:1d59:be71 with SMTP id k22-20020a9d7616000000b006ea1d59be71mr15787486otl.32.1713335256421; Tue, 16 Apr 2024 23:27:36 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id a193-20020a6390ca000000b005dc120fa3b2sm9821006pge.18.2024.04.16.23.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 23:27:35 -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 v2 2/3] net: rps: protect filter locklessly Date: Wed, 17 Apr 2024 14:27:20 +0800 Message-Id: <20240417062721.45652-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240417062721.45652-1-kerneljasonxing@gmail.com> References: <20240417062721.45652-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 2003b9a61e40..40a535158e45 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 Wed Apr 17 06:27:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13632906 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 06F0D5A784 for ; Wed, 17 Apr 2024 06:27:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713335261; cv=none; b=D2PjM6mLpSdtjKcbZQsOpSfcEA+/ByX74bZKAiKbsdeeVHwG2e1649hcgQQe93KWT3PkyqmARuyqiHs14/PsvZLVegfafZ1uhBsAiqtovKdworsnGmvoUPdl7lyDqjOVquQl7W/jZzmAvXq368OUjo9GVJ0VTpbfnLHj1HXn9RA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713335261; c=relaxed/simple; bh=lG1VqfYPVS5aljnryZS192B21YJzSt3bL0wKDML71Dk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CGWRlvr2SezQRGupT3eWtz/sSQmcuRYRqlcFlAFYlyKIAAs77DxlZUuQ+JJNfy6weBLM+Oj33VO7j+x++jGtReSQM6CD+8B7krAqnatedqizMilPYxgsbFoC3KRejiEIDaZVU8bwf8xZBPPgHHCp7qkbIBoyA3SJLX0QGKpCCv4= 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=QwQmjS61; arc=none smtp.client-ip=209.85.210.47 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="QwQmjS61" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6eb812370a5so1601831a34.0 for ; Tue, 16 Apr 2024 23:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713335259; x=1713940059; 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=2MWNLBsgAvWpxcDaMrRSKJ3+W1whAYT8zWw7ExmTZfk=; b=QwQmjS61xJNGqTqXKmsodHIZ7hSbNlv8kmN81n0ZIwY3q8xgLFioddfVAhyJixhpiY r7AggenJItr4NYYrOjNIb7T3u76EOdTg0ZMoYl7bXm/3hTLUlR2VW+39DA4qul5ZA9kU OzqXgNqxobIoY31LdX2voCcHtuaz9zPsumMcTt8/HZaMU4S0VozRfe9XtVXZnSpOChIG 1qbBFCEuQVFcVAvM9aZH+Zo6CsD6SGUGwZBV4HfeUdWDliS9ox8GXG0o1U6t9Tw1Aijo 0MpnSV1+oGVuojyc6UNZoshXUFnpn9dvoPKdXhz/ANFet4uGC6RqlzlX5/vyJzlM6V6m +fjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713335259; x=1713940059; 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=2MWNLBsgAvWpxcDaMrRSKJ3+W1whAYT8zWw7ExmTZfk=; b=LK5p1l5UI8Mo69euk5TN1bdwB0+ZWO3L/t4eoFj+edUlydDFsGCCTMJaEgsAWj7qE7 4OU8WYlqmSJWSRefSidRefNwooZ3EvfALz2Orvnv9Iv2CYMsfbOsakGGnDeFMO9HuBsg g/85RkVIUYViS8imI+VsYvSEpG90CxTLy9ItqFViwyVqctEsIONvqxGe9grzYql8vFMd qnFDbAORcXU4ZaDlQoXG1dmzJdHmd98Tw1e7ZLwMPdoz4XBbUeNV2kSZU6rPZJ0Kbz48 s28R7cgECnNTVxMRj13+tNU0d/UCGUV0E9E1pAgzkWvuUsAY0AK1BwyPnLDkCpzdldr4 ZJMw== X-Gm-Message-State: AOJu0Yw4DAungqdnSzIOh6eJGysKrDzzOZp6w7qsBo9tpMyqYPmf1Niq CaW4LwJK1Xzf85TfPZT+mdcIEdd/M5tAkE0fFopS8+dXfEvs0exJ X-Google-Smtp-Source: AGHT+IEI6Peo3RP0ZxOU6CcegaA6NGdJ7zZU3BCVAQi8tTemSGFF4BUMEww+E3NyhIJBvnUPlqnv0g== X-Received: by 2002:a05:6830:2051:b0:6eb:7d1c:bfdf with SMTP id f17-20020a056830205100b006eb7d1cbfdfmr10544868otp.25.1713335259090; Tue, 16 Apr 2024 23:27:39 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id a193-20020a6390ca000000b005dc120fa3b2sm9821006pge.18.2024.04.16.23.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 23:27:38 -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 v2 3/3] net: rps: locklessly access rflow->cpu Date: Wed, 17 Apr 2024 14:27:21 +0800 Message-Id: <20240417062721.45652-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240417062721.45652-1-kerneljasonxing@gmail.com> References: <20240417062721.45652-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 40a535158e45..aeb45025e2bc 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