netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	netdev@vger.kernel.org,  eric.dumazet@gmail.com,
	Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 4/4] net: rps: remove kfree_rcu_mightsleep() use
Date: Mon,  7 Apr 2025 16:36:02 +0000	[thread overview]
Message-ID: <20250407163602.170356-5-edumazet@google.com> (raw)
In-Reply-To: <20250407163602.170356-1-edumazet@google.com>

Add an rcu_head to sd_flow_limit and rps_sock_flow_table structs
to use the more conventional and predictable k[v]free_rcu().

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/rps.h          | 5 +++--
 net/core/dev.h             | 1 +
 net/core/sysctl_net_core.c | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/net/rps.h b/include/net/rps.h
index e358e9711f27..507f4aa5d39b 100644
--- a/include/net/rps.h
+++ b/include/net/rps.h
@@ -57,9 +57,10 @@ struct rps_dev_flow_table {
  * meaning we use 32-6=26 bits for the hash.
  */
 struct rps_sock_flow_table {
-	u32	mask;
+	struct rcu_head	rcu;
+	u32		mask;
 
-	u32	ents[] ____cacheline_aligned_in_smp;
+	u32		ents[] ____cacheline_aligned_in_smp;
 };
 #define	RPS_SOCK_FLOW_TABLE_SIZE(_num) (offsetof(struct rps_sock_flow_table, ents[_num]))
 
diff --git a/net/core/dev.h b/net/core/dev.h
index e855e1cb43fd..710abc05ebdb 100644
--- a/net/core/dev.h
+++ b/net/core/dev.h
@@ -15,6 +15,7 @@ struct cpumask;
 /* Random bits of netdevice that don't need to be exposed */
 #define FLOW_LIMIT_HISTORY	(1 << 7)  /* must be ^2 and !overflow buckets */
 struct sd_flow_limit {
+	struct rcu_head		rcu;
 	unsigned int		count;
 	u8			log_buckets;
 	unsigned int		history_head;
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 5cfe76ede523..5dbb2c6f371d 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -201,7 +201,7 @@ static int rps_sock_flow_sysctl(const struct ctl_table *table, int write,
 			if (orig_sock_table) {
 				static_branch_dec(&rps_needed);
 				static_branch_dec(&rfs_needed);
-				kvfree_rcu_mightsleep(orig_sock_table);
+				kvfree_rcu(orig_sock_table, rcu);
 			}
 		}
 	}
@@ -239,7 +239,7 @@ static int flow_limit_cpu_sysctl(const struct ctl_table *table, int write,
 				     lockdep_is_held(&flow_limit_update_mutex));
 			if (cur && !cpumask_test_cpu(i, mask)) {
 				RCU_INIT_POINTER(sd->flow_limit, NULL);
-				kfree_rcu_mightsleep(cur);
+				kfree_rcu(cur, rcu);
 			} else if (!cur && cpumask_test_cpu(i, mask)) {
 				cur = kzalloc_node(len, GFP_KERNEL,
 						   cpu_to_node(i));
-- 
2.49.0.504.g3bcea36a83-goog


  parent reply	other threads:[~2025-04-07 16:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 16:35 [PATCH net-next 0/4] rps: misc changes Eric Dumazet
2025-04-07 16:35 ` [PATCH net-next 1/4] net: rps: change skb_flow_limit() hash function Eric Dumazet
2025-04-07 18:53   ` Willem de Bruijn
2025-04-07 16:36 ` [PATCH net-next 2/4] net: rps: annotate data-races around (struct sd_flow_limit)->count Eric Dumazet
2025-04-07 18:55   ` Willem de Bruijn
2025-04-07 16:36 ` [PATCH net-next 3/4] net: add data-race annotations in softnet_seq_show() Eric Dumazet
2025-04-07 19:04   ` Willem de Bruijn
2025-04-07 16:36 ` Eric Dumazet [this message]
2025-04-07 19:36   ` [PATCH net-next 4/4] net: rps: remove kfree_rcu_mightsleep() use Willem de Bruijn
2025-04-08 20:08 ` [PATCH net-next 0/4] rps: misc changes patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250407163602.170356-5-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).