Skip to contentSkip to conversation

ipvs: Fix incorrect use of HK_TYPE_KTHREAD housekeeping cpumask

PATCH In review Waiman Long 4 participants 12 messages Mar 31 – Apr 20

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover ipvs: Fix incorrect use of HK_TYPE_KTHREAD housekeeping cpumask

v2:
- Rebased on top of linux-next

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), the HK_TYPE_KTHREAD housekeeping cpumask may no longer be correct in showing the actual CPU affinity of kthreads that have no predefined CPU affinity. As the ipvs networking code is still using HK_TYPE_KTHREAD, we need to make HK_TYPE_KTHREAD reflect the reality.

This patch series makes HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN and uses RCU to protect access to the HK_TYPE_KTHREAD housekeeping cpumask.

Waiman Long (2):
sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN
ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

 include/linux/sched/isolation.h |  6 +++++-
 include/net/ip_vs.h             | 20 ++++++++++++++++----
 net/netfilter/ipvs/ip_vs_ctl.c  | 13 ++++++++-----
 3 files changed, 29 insertions(+), 10 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/2 sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), kthreads default to use the HK_TYPE_DOMAIN cpumask. IOW, it is no longer affected by the setting of the nohz_full boot kernel parameter.

That means HK_TYPE_KTHREAD should now be an alias of HK_TYPE_DOMAIN instead of HK_TYPE_KERNEL_NOISE to correctly reflect the current kthread behavior. Make the change as HK_TYPE_KTHREAD is still being used in some networking code.

Fixes 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management")
---
 include/linux/sched/isolation.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/sched/isolation.h +5 -1
index dc3975ff1b2e..cf0fd03dd7a2 100644
@@ -20,6 +20,11 @@ enum hk_type {
 	HK_TYPE_KERNEL_NOISE,
 	HK_TYPE_MAX,
 
+	/*
+	 * HK_TYPE_KTHREAD is now an alias of HK_TYPE_DOMAIN
+	 */
+	HK_TYPE_KTHREAD = HK_TYPE_DOMAIN,
+
 	/*
 	 * The following housekeeping types are only set by the nohz_full
 	 * boot commandline option. So they can share the same value.
@@ -29,7 +34,6 @@ enum hk_type {
 	HK_TYPE_RCU     = HK_TYPE_KERNEL_NOISE,
 	HK_TYPE_MISC    = HK_TYPE_KERNEL_NOISE,
 	HK_TYPE_WQ      = HK_TYPE_KERNEL_NOISE,
-	HK_TYPE_KTHREAD = HK_TYPE_KERNEL_NOISE
 };
 
 #ifdef CONFIG_CPU_ISOLATION
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH-next v2 1/2] sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN

Quoted 5 lines · Waiman Long

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), kthreads default to use the HK_TYPE_DOMAIN cpumask. IOW, it is no longer affected by the setting of the nohz_full boot kernel parameter.

Quoted 7 lines

That means HK_TYPE_KTHREAD should now be an alias of HK_TYPE_DOMAIN instead of HK_TYPE_KERNEL_NOISE to correctly reflect the current kthread behavior. Make the change as HK_TYPE_KTHREAD is still being used in some networking code.

Fixes 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management")

This makes ipvs_proc_est_cpumask_get() racy because now without RCU locked the mask pointer can be released at any point.

Other users:

sysctl_est_cpulist() -> ip_vs_est_stopped_recalc() -> ip_vs_est_reload_start()

Here sysctl_est_cpulist() is only invoked if ->est_cpulist_valid (->est_mutex makes it stable). So housekeeping_cpumask() should not be called.

But ip_vs_est_max_threads() is more complicated. And it's a sign we should probably call something like ipvs_proc_est_cpumask_set() when the HK_TYPE_DOMAIN is modified (and ipvs->est_cpulist_valid is 0) in order to update the ipvs kthreads accordingly.

Thanks.

Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#3 lore raw

PATCH v2 2/2 ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

In reply to Waiman Long

The ip_vs_ctl.c file and the associated ip_vs.h file are the only places in the kernel where HK_TYPE_KTHREAD cpumask is being retrieved and used. Now that HK_TYPE_KTHREAD/HK_TYPE_DOMAIN cpumask can be changed at run time. We need to use RCU to guard access to this cpumask to avoid a potential UAF problem as the returned cpumask may be freed before it is being used.

We can replace HK_TYPE_KTHREAD by HK_TYPE_DOMAIN as they are aliases of each other, but keeping the HK_TYPE_KTHREAD name can highlight the fact that it is the kthread initiated by ipvs that is being controlled.

---
 include/net/ip_vs.h            | 20 ++++++++++++++++----
 net/netfilter/ipvs/ip_vs_ctl.c | 13 ++++++++-----
 2 files changed, 24 insertions(+), 9 deletions(-)
include/net/ip_vs.h +16 -4
index 72d325c81313..7bda92fd3fe6 100644
@@ -1411,7 +1411,7 @@ static inline int sysctl_run_estimation(struct netns_ipvs *ipvs)
 	return ipvs->sysctl_run_estimation;
 }
 
-static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
+static inline const struct cpumask *__sysctl_est_cpulist(struct netns_ipvs *ipvs)
 {
 	if (ipvs->est_cpulist_valid)
 		return ipvs->sysctl_est_cpulist;
@@ -1529,7 +1529,7 @@ static inline int sysctl_run_estimation(struct netns_ipvs *ipvs)
 	return 1;
 }
 
-static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
+static inline const struct cpumask *__sysctl_est_cpulist(struct netns_ipvs *ipvs)
 {
 	return housekeeping_cpumask(HK_TYPE_KTHREAD);
 }
@@ -1564,6 +1564,18 @@ static inline int sysctl_svc_lfactor(struct netns_ipvs *ipvs)
 	return READ_ONCE(ipvs->sysctl_svc_lfactor);
 }
 
+static inline bool sysctl_est_cpulist_empty(struct netns_ipvs *ipvs)
+{
+	guard(rcu)();
+	return cpumask_empty(__sysctl_est_cpulist(ipvs));
+}
+
+static inline unsigned int sysctl_est_cpulist_weight(struct netns_ipvs *ipvs)
+{
+	guard(rcu)();
+	return cpumask_weight(__sysctl_est_cpulist(ipvs));
+}
+
 /* IPVS core functions
  * (from ip_vs_core.c)
  */
@@ -1895,7 +1907,7 @@ static inline void ip_vs_est_stopped_recalc(struct netns_ipvs *ipvs)
 	/* Stop tasks while cpulist is empty or if disabled with flag */
 	ipvs->est_stopped = !sysctl_run_estimation(ipvs) ||
 			    (ipvs->est_cpulist_valid &&
-			     cpumask_empty(sysctl_est_cpulist(ipvs)));
+			     sysctl_est_cpulist_empty(ipvs));
 #endif
 }
 
@@ -1911,7 +1923,7 @@ static inline bool ip_vs_est_stopped(struct netns_ipvs *ipvs)
 static inline int ip_vs_est_max_threads(struct netns_ipvs *ipvs)
 {
 	unsigned int limit = IPVS_EST_CPU_KTHREADS *
-			     cpumask_weight(sysctl_est_cpulist(ipvs));
+			     sysctl_est_cpulist_weight(ipvs);
 
 	return max(1U, limit);
 }
net/netfilter/ipvs/ip_vs_ctl.c +8 -5
index 032425025d88..e253a1ceef48 100644
@@ -2338,11 +2338,14 @@ static int ipvs_proc_est_cpumask_get(const struct ctl_table *table,
 
 	mutex_lock(&ipvs->est_mutex);
 
-	if (ipvs->est_cpulist_valid)
-		mask = *valp;
-	else
-		mask = (struct cpumask *)housekeeping_cpumask(HK_TYPE_KTHREAD);
-	ret = scnprintf(buffer, size, "%*pbl\n", cpumask_pr_args(mask));
+	/* HK_TYPE_KTHREAD cpumask needs RCU protection */
+	scoped_guard(rcu) {
+		if (ipvs->est_cpulist_valid)
+			mask = *valp;
+		else
+			mask = (struct cpumask *)housekeeping_cpumask(HK_TYPE_KTHREAD);
+		ret = scnprintf(buffer, size, "%*pbl\n", cpumask_pr_args(mask));
+	}
 
 	mutex_unlock(&ipvs->est_mutex);
 
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH-next v2 2/2] ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

Quoted 7 lines · Waiman Long

The ip_vs_ctl.c file and the associated ip_vs.h file are the only places in the kernel where HK_TYPE_KTHREAD cpumask is being retrieved and used. Now that HK_TYPE_KTHREAD/HK_TYPE_DOMAIN cpumask can be changed at run time. We need to use RCU to guard access to this cpumask to avoid a potential UAF problem as the returned cpumask may be freed before it is being used.

Quoted 5 lines

We can replace HK_TYPE_KTHREAD by HK_TYPE_DOMAIN as they are aliases of each other, but keeping the HK_TYPE_KTHREAD name can highlight the fact that it is the kthread initiated by ipvs that is being controlled.

Oh I see you're handling a few concerns here. But it's too late, the previous patch broke bisection.

Quoted 47 lines
---
 include/net/ip_vs.h            | 20 ++++++++++++++++----
 net/netfilter/ipvs/ip_vs_ctl.c | 13 ++++++++-----
 2 files changed, 24 insertions(+), 9 deletions(-)
include/net/ip_vs.h +14 -2
index 72d325c81313..7bda92fd3fe6 100644
@@ -1411,7 +1411,7 @@ static inline int sysctl_run_estimation(struct netns_ipvs *ipvs)
 	return ipvs->sysctl_run_estimation;
 }
 
-static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
+static inline const struct cpumask *__sysctl_est_cpulist(struct netns_ipvs *ipvs)
 {
 	if (ipvs->est_cpulist_valid)
 		return ipvs->sysctl_est_cpulist;
@@ -1529,7 +1529,7 @@ static inline int sysctl_run_estimation(struct netns_ipvs *ipvs)
 	return 1;
 }
 
-static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
+static inline const struct cpumask *__sysctl_est_cpulist(struct netns_ipvs *ipvs)
 {
 	return housekeeping_cpumask(HK_TYPE_KTHREAD);
 }
@@ -1564,6 +1564,18 @@ static inline int sysctl_svc_lfactor(struct netns_ipvs *ipvs)
 	return READ_ONCE(ipvs->sysctl_svc_lfactor);
 }
 
+static inline bool sysctl_est_cpulist_empty(struct netns_ipvs *ipvs)
+{
+	guard(rcu)();
+	return cpumask_empty(__sysctl_est_cpulist(ipvs));
+}
+
+static inline unsigned int sysctl_est_cpulist_weight(struct netns_ipvs *ipvs)
+{
+	guard(rcu)();
+	return cpumask_weight(__sysctl_est_cpulist(ipvs));
+}
+
 /* IPVS core functions
  * (from ip_vs_core.c)
  */

include/net/ip_vs.h static inline void ip_vs_est_stopped_recalc(struct netns_ipvs *ipvs) · line 1910

Quoted 5 lines
include/net/ip_vs.h +1 -1
@@ -1895,7 +1907,7 @@ static inline void ip_vs_est_stopped_recalc(struct netns_ipvs *ipvs)
 	/* Stop tasks while cpulist is empty or if disabled with flag */
 	ipvs->est_stopped = !sysctl_run_estimation(ipvs) ||
 			    (ipvs->est_cpulist_valid &&
-			     cpumask_empty(sysctl_est_cpulist(ipvs)));
+			     sysctl_est_cpulist_empty(ipvs));

It's not needed, if ipvs->est_cpulist_valid, sysctl_est_cpulist() doesn't refer to housekeeping.

include/net/ip_vs.h static inline bool ip_vs_est_stopped(struct netns_ipvs *ipvs) · line 1926

Quoted 9 lines
include/net/ip_vs.h +1 -1
 #endif
 }
 
@@ -1911,7 +1923,7 @@ static inline bool ip_vs_est_stopped(struct netns_ipvs *ipvs)
 static inline int ip_vs_est_max_threads(struct netns_ipvs *ipvs)
 {
 	unsigned int limit = IPVS_EST_CPU_KTHREADS *
-			     cpumask_weight(sysctl_est_cpulist(ipvs));
+			     sysctl_est_cpulist_weight(ipvs);

That probably works for callers ip_vs_start_estimator().

But this is not handling the core issue that related kthreads should be updated, as is done in ipvs_proc_est_cpumask_set(), when HK_TYPE_DOMAIN mask changes.

Quoted 14 lines
include/net/ip_vs.h +0 -0
 	return max(1U, limit);
 }
net/netfilter/ipvs/ip_vs_ctl.c +0 -3
index 032425025d88..e253a1ceef48 100644
@@ -2338,11 +2338,14 @@ static int ipvs_proc_est_cpumask_get(const struct ctl_table *table,
 
 	mutex_lock(&ipvs->est_mutex);
 
-	if (ipvs->est_cpulist_valid)
-		mask = *valp;
-	else

net/netfilter/ipvs/ip_vs_ctl.c static int ipvs_proc_est_cpumask_get(const struct ctl_table *table, · line 2348

Quoted 10 lines
net/netfilter/ipvs/ip_vs_ctl.c +8 -2
-		mask = (struct cpumask *)housekeeping_cpumask(HK_TYPE_KTHREAD);
-	ret = scnprintf(buffer, size, "%*pbl\n", cpumask_pr_args(mask));
+	/* HK_TYPE_KTHREAD cpumask needs RCU protection */
+	scoped_guard(rcu) {
+		if (ipvs->est_cpulist_valid)
+			mask = *valp;
+		else
+			mask = (struct cpumask *)housekeeping_cpumask(HK_TYPE_KTHREAD);
+		ret = scnprintf(buffer, size, "%*pbl\n", cpumask_pr_args(mask));
+	}

And that works.

Thanks.

Quoted 6 lines
net/netfilter/ipvs/ip_vs_ctl.c +0 -0
 	mutex_unlock(&ipvs->est_mutex);
 
Signature · 1 line
2.53.0
Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#5 lore raw

Re: [PATCH-next v2 2/2] ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

Quoted 8 lines · Frederic Weisbecker
Quoted 7 lines · Waiman Long

The ip_vs_ctl.c file and the associated ip_vs.h file are the only places in the kernel where HK_TYPE_KTHREAD cpumask is being retrieved and used. Now that HK_TYPE_KTHREAD/HK_TYPE_DOMAIN cpumask can be changed at run time. We need to use RCU to guard access to this cpumask to avoid a potential UAF problem as the returned cpumask may be freed before it is being used.

Quoted 7 lines
Quoted 5 lines

We can replace HK_TYPE_KTHREAD by HK_TYPE_DOMAIN as they are aliases of each other, but keeping the HK_TYPE_KTHREAD name can highlight the fact that it is the kthread initiated by ipvs that is being controlled.

Oh I see you're handling a few concerns here. But it's too late, the previous patch broke bisection.

Good point. So I have to either reverse the patch order, or just change HK_TYPE_KTHREAD to HK_TYPE_DOMAIN & drop the first one.

Quoted 47 lines
Quoted 47 lines
---
  include/net/ip_vs.h            | 20 ++++++++++++++++----
  net/netfilter/ipvs/ip_vs_ctl.c | 13 ++++++++-----
  2 files changed, 24 insertions(+), 9 deletions(-)
include/net/ip_vs.h +14 -2
index 72d325c81313..7bda92fd3fe6 100644
@@ -1411,7 +1411,7 @@ static inline int sysctl_run_estimation(struct netns_ipvs *ipvs)
  	return ipvs->sysctl_run_estimation;
  }
 
-static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
+static inline const struct cpumask *__sysctl_est_cpulist(struct netns_ipvs *ipvs)
  {
  	if (ipvs->est_cpulist_valid)
  		return ipvs->sysctl_est_cpulist;
@@ -1529,7 +1529,7 @@ static inline int sysctl_run_estimation(struct netns_ipvs *ipvs)
  	return 1;
  }
 
-static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
+static inline const struct cpumask *__sysctl_est_cpulist(struct netns_ipvs *ipvs)
  {
  	return housekeeping_cpumask(HK_TYPE_KTHREAD);
  }
@@ -1564,6 +1564,18 @@ static inline int sysctl_svc_lfactor(struct netns_ipvs *ipvs)
  	return READ_ONCE(ipvs->sysctl_svc_lfactor);
  }
 
+static inline bool sysctl_est_cpulist_empty(struct netns_ipvs *ipvs)
+{
+	guard(rcu)();
+	return cpumask_empty(__sysctl_est_cpulist(ipvs));
+}
+
+static inline unsigned int sysctl_est_cpulist_weight(struct netns_ipvs *ipvs)
+{
+	guard(rcu)();
+	return cpumask_weight(__sysctl_est_cpulist(ipvs));
+}
+
  /* IPVS core functions
   * (from ip_vs_core.c)
   */
Quoted 8 lines

include/net/ip_vs.h static inline void ip_vs_est_stopped_recalc(struct netns_ipvs *ipvs) · line 1910

Quoted 6 lines
include/net/ip_vs.h +1 -1
@@ -1895,7 +1907,7 @@ static inline void ip_vs_est_stopped_recalc(struct netns_ipvs *ipvs)
  	/* Stop tasks while cpulist is empty or if disabled with flag */
  	ipvs->est_stopped = !sysctl_run_estimation(ipvs) ||
  			    (ipvs->est_cpulist_valid &&
-			     cpumask_empty(sysctl_est_cpulist(ipvs)));
+			     sysctl_est_cpulist_empty(ipvs));

It's not needed, if ipvs->est_cpulist_valid, sysctl_est_cpulist() doesn't refer to housekeeping.

Right.

Quoted 11 lines

include/net/ip_vs.h static inline bool ip_vs_est_stopped(struct netns_ipvs *ipvs) · line 1926

Quoted 9 lines
include/net/ip_vs.h +1 -1
  #endif
  }
 
@@ -1911,7 +1923,7 @@ static inline bool ip_vs_est_stopped(struct netns_ipvs *ipvs)
  static inline int ip_vs_est_max_threads(struct netns_ipvs *ipvs)
  {
  	unsigned int limit = IPVS_EST_CPU_KTHREADS *
-			     cpumask_weight(sysctl_est_cpulist(ipvs));
+			     sysctl_est_cpulist_weight(ipvs);

That probably works for callers ip_vs_start_estimator().

Quoted 2 lines

But this is not handling the core issue that related kthreads should be updated, as is done in ipvs_proc_est_cpumask_set(), when HK_TYPE_DOMAIN mask changes.

If ipvs_proc_est_cpumask_set() has been called, the real affinity should be the intersection of the given cpumask and HK_TYPE_DOMAIN cpumask. Is that what you are referring to?

Cheers,
Longman

Quoted 35 lines
Quoted 15 lines
include/net/ip_vs.h +0 -0
  	return max(1U, limit);
  }
net/netfilter/ipvs/ip_vs_ctl.c +0 -3
index 032425025d88..e253a1ceef48 100644
@@ -2338,11 +2338,14 @@ static int ipvs_proc_est_cpumask_get(const struct ctl_table *table,
 
  	mutex_lock(&ipvs->est_mutex);
 
-	if (ipvs->est_cpulist_valid)
-		mask = *valp;
-	else

net/netfilter/ipvs/ip_vs_ctl.c static int ipvs_proc_est_cpumask_get(const struct ctl_table *table, · line 2348

Quoted 10 lines
net/netfilter/ipvs/ip_vs_ctl.c +8 -2
-		mask = (struct cpumask *)housekeeping_cpumask(HK_TYPE_KTHREAD);
-	ret = scnprintf(buffer, size, "%*pbl\n", cpumask_pr_args(mask));
+	/* HK_TYPE_KTHREAD cpumask needs RCU protection */
+	scoped_guard(rcu) {
+		if (ipvs->est_cpulist_valid)
+			mask = *valp;
+		else
+			mask = (struct cpumask *)housekeeping_cpumask(HK_TYPE_KTHREAD);
+		ret = scnprintf(buffer, size, "%*pbl\n", cpumask_pr_args(mask));
+	}

And that works.

Thanks.

Quoted 6 lines
net/netfilter/ipvs/ip_vs_ctl.c +0 -0
  	mutex_unlock(&ipvs->est_mutex);
 
Signature · 1 line
2.53.0
maintainer Acked-by on the v2 series
#6 lore raw
In reply to Waiman Long

Hello,

Quoted 10 lines · Waiman Long

v2:
- Rebased on top of linux-next

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), the HK_TYPE_KTHREAD housekeeping cpumask may no longer be correct in showing the actual CPU affinity of kthreads that have no predefined CPU affinity. As the ipvs networking code is still using HK_TYPE_KTHREAD, we need to make HK_TYPE_KTHREAD reflect the reality.

Quoted 7 lines

This patch series makes HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN and uses RCU to protect access to the HK_TYPE_KTHREAD housekeeping cpumask.

Waiman Long (2):
sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN
ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

The patchset looks good to me for nf-next, thanks!

Pablo, Florian, as a bugfix this patchset missed
the chance to be applied before the changes that are in nf-next in ip_vs.h, there is little fuzz there. If there is no chance to resolve it somehow, we can apply it on top of nf-next where it now applies successfully.

Quoted 5 lines
 include/linux/sched/isolation.h |  6 +++++-
 include/net/ip_vs.h             | 20 ++++++++++++++++----
 net/netfilter/ipvs/ip_vs_ctl.c  | 13 ++++++++-----
 3 files changed, 29 insertions(+), 10 deletions(-)

Regards

--
Julian Anastasov <[email protected]>

#7 lore raw
Quoted 25 lines · Julian Anastasov

Hello,

Quoted 10 lines · Waiman Long

v2:
- Rebased on top of linux-next

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), the HK_TYPE_KTHREAD housekeeping cpumask may no longer be correct in showing the actual CPU affinity of kthreads that have no predefined CPU affinity. As the ipvs networking code is still using HK_TYPE_KTHREAD, we need to make HK_TYPE_KTHREAD reflect the reality.

Quoted 7 lines

This patch series makes HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN and uses RCU to protect access to the HK_TYPE_KTHREAD housekeeping cpumask.

Waiman Long (2):
sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN
ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

The patchset looks good to me for nf-next, thanks!

Quoted 7 lines

Pablo, Florian, as a bugfix this patchset missed
the chance to be applied before the changes that are in nf-next in ip_vs.h, there is little fuzz there. If there is no chance to resolve it somehow, we can apply it on top of nf-next where it now applies successfully.

One way to handle this is to follow up with nf-next as you suggest, then send a backport that applies cleanly for -stable once it is released.

Else, let me know if I am misunderstanding.

maintainer
#8 lore raw

Hello,

Quoted 34 lines · Pablo Neira Ayuso
Quoted 25 lines · Julian Anastasov

Hello,

Quoted 10 lines · Waiman Long

v2:
- Rebased on top of linux-next

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), the HK_TYPE_KTHREAD housekeeping cpumask may no longer be correct in showing the actual CPU affinity of kthreads that have no predefined CPU affinity. As the ipvs networking code is still using HK_TYPE_KTHREAD, we need to make HK_TYPE_KTHREAD reflect the reality.

Quoted 7 lines

This patch series makes HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN and uses RCU to protect access to the HK_TYPE_KTHREAD housekeeping cpumask.

Waiman Long (2):
sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN
ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

The patchset looks good to me for nf-next, thanks!

Quoted 7 lines

Pablo, Florian, as a bugfix this patchset missed
the chance to be applied before the changes that are in nf-next in ip_vs.h, there is little fuzz there. If there is no chance to resolve it somehow, we can apply it on top of nf-next where it now applies successfully.

Quoted 3 lines

One way to handle this is to follow up with nf-next as you suggest, then send a backport that applies cleanly for -stable once it is released.

Lets do it this way, thanks!

Quoted 1 line

Else, let me know if I am misunderstanding.

Regards

--
Julian Anastasov <[email protected]>

maintainer
#9 lore raw
In reply to Pablo Neira Ayuso

Hello,

Quoted 34 lines · Pablo Neira Ayuso
Quoted 25 lines · Julian Anastasov

Hello,

Quoted 10 lines · Waiman Long

v2:
- Rebased on top of linux-next

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), the HK_TYPE_KTHREAD housekeeping cpumask may no longer be correct in showing the actual CPU affinity of kthreads that have no predefined CPU affinity. As the ipvs networking code is still using HK_TYPE_KTHREAD, we need to make HK_TYPE_KTHREAD reflect the reality.

Quoted 7 lines

This patch series makes HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN and uses RCU to protect access to the HK_TYPE_KTHREAD housekeeping cpumask.

Waiman Long (2):
sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN
ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

The patchset looks good to me for nf-next, thanks!

Quoted 7 lines

Pablo, Florian, as a bugfix this patchset missed
the chance to be applied before the changes that are in nf-next in ip_vs.h, there is little fuzz there. If there is no chance to resolve it somehow, we can apply it on top of nf-next where it now applies successfully.

Quoted 5 lines

One way to handle this is to follow up with nf-next as you suggest, then send a backport that applies cleanly for -stable once it is released.

Else, let me know if I am misunderstanding.

This patchset is now material for the net tree. To help it,
I just posted patch "ipvs: fix races around est_mutex and est_cpulist" that can be applied before this patchset to the net tree. Can we get this patchset for the net tree?

Regards

--
Julian Anastasov <[email protected]>

#10 lore raw
Quoted 43 lines · Julian Anastasov

Hello,

Quoted 38 lines · Pablo Neira Ayuso
Quoted 25 lines · Julian Anastasov

Hello,

Quoted 10 lines · Waiman Long

v2:
- Rebased on top of linux-next

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), the HK_TYPE_KTHREAD housekeeping cpumask may no longer be correct in showing the actual CPU affinity of kthreads that have no predefined CPU affinity. As the ipvs networking code is still using HK_TYPE_KTHREAD, we need to make HK_TYPE_KTHREAD reflect the reality.

Quoted 7 lines

This patch series makes HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN and uses RCU to protect access to the HK_TYPE_KTHREAD housekeeping cpumask.

Waiman Long (2):
sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN
ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

The patchset looks good to me for nf-next, thanks!

Quoted 7 lines

Pablo, Florian, as a bugfix this patchset missed
the chance to be applied before the changes that are in nf-next in ip_vs.h, there is little fuzz there. If there is no chance to resolve it somehow, we can apply it on top of nf-next where it now applies successfully.

One way to handle this is to follow up with nf-next as you suggest, then send a backport that applies cleanly for -stable once it is released.

Quoted 6 lines
Quoted 1 line

Else, let me know if I am misunderstanding.

This patchset is now material for the net tree. To help it,
I just posted patch "ipvs: fix races around est_mutex and est_cpulist" that can be applied before this patchset to the net tree. Can we get this patchset for the net tree?

Yes, I am preparing a PR.

BTW, did you get look at the report provided by the AI assistant?

https://sashiko.dev/#/?list=org.kernel.vger.netfilter-devel

If not, please repost to get initial feedback from it.

Thanks.

maintainer
#11 lore raw

Hello,

Quoted 51 lines · Pablo Neira Ayuso
Quoted 43 lines · Julian Anastasov

Hello,

Quoted 38 lines · Pablo Neira Ayuso
Quoted 25 lines · Julian Anastasov

Hello,

Quoted 10 lines · Waiman Long

v2:
- Rebased on top of linux-next

Since commit 041ee6f3727a ("kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management"), the HK_TYPE_KTHREAD housekeeping cpumask may no longer be correct in showing the actual CPU affinity of kthreads that have no predefined CPU affinity. As the ipvs networking code is still using HK_TYPE_KTHREAD, we need to make HK_TYPE_KTHREAD reflect the reality.

Quoted 7 lines

This patch series makes HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN and uses RCU to protect access to the HK_TYPE_KTHREAD housekeeping cpumask.

Waiman Long (2):
sched/isolation: Make HK_TYPE_KTHREAD an alias of HK_TYPE_DOMAIN
ipvs: Guard access of HK_TYPE_KTHREAD cpumask with RCU

The patchset looks good to me for nf-next, thanks!

Quoted 7 lines

Pablo, Florian, as a bugfix this patchset missed
the chance to be applied before the changes that are in nf-next in ip_vs.h, there is little fuzz there. If there is no chance to resolve it somehow, we can apply it on top of nf-next where it now applies successfully.

One way to handle this is to follow up with nf-next as you suggest, then send a backport that applies cleanly for -stable once it is released.

Quoted 6 lines
Quoted 1 line

Else, let me know if I am misunderstanding.

This patchset is now material for the net tree. To help it,
I just posted patch "ipvs: fix races around est_mutex and est_cpulist" that can be applied before this patchset to the net tree. Can we get this patchset for the net tree?

Quoted 5 lines

Yes, I am preparing a PR.

BTW, did you get look at the report provided by the AI assistant?

https://sashiko.dev/#/?list=org.kernel.vger.netfilter-devel

Yes, I monitor it. I'm waiting the review for
my 3+1 patches from today. And I hope the review for this HK_TYPE_KTHREAD patchset is addressed too with "ipvs: fix races around est_mutex and est_cpulist".

Quoted 3 lines

If not, please repost to get initial feedback from it.

Thanks.

Regards

--
Julian Anastasov <[email protected]>