* [PATCH net] ipvs: Fix estimator kthreads preferred affinity
@ 2025-07-29 12:06 Frederic Weisbecker
2025-08-27 10:48 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Frederic Weisbecker @ 2025-07-29 12:06 UTC (permalink / raw)
To: LKML
Cc: Frederic Weisbecker, David S. Miller, David Ahern, Simon Horman,
Julian Anastasov, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Pablo Neira Ayuso, Jozsef Kadlecsik, netdev, lvs-devel,
netfilter-devel, coreteam
The estimator kthreads' affinity are defined by sysctl overwritten
preferences and applied through a plain call to the scheduler's affinity
API.
However since the introduction of managed kthreads preferred affinity,
such a practice shortcuts the kthreads core code which eventually
overwrites the target to the default unbound affinity.
Fix this with using the appropriate kthread's API which will carry the
desired affinity and maintain it across CPU hotplug events and CPU
isolation constraints.
Fixes: d1a89197589c ("kthread: Default affine kthread to its preferred NUMA node")
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
include/net/ip_vs.h | 13 +++++++++++++
net/netfilter/ipvs/ip_vs_est.c | 3 ++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index ff406ef4fd4a..29a36709e7f3 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -1163,6 +1163,14 @@ static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
return housekeeping_cpumask(HK_TYPE_KTHREAD);
}
+static inline const struct cpumask *sysctl_est_preferred_cpulist(struct netns_ipvs *ipvs)
+{
+ if (ipvs->est_cpulist_valid)
+ return ipvs->sysctl_est_cpulist;
+ else
+ return NULL;
+}
+
static inline int sysctl_est_nice(struct netns_ipvs *ipvs)
{
return ipvs->sysctl_est_nice;
@@ -1270,6 +1278,11 @@ static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
return housekeeping_cpumask(HK_TYPE_KTHREAD);
}
+static inline const struct cpumask *sysctl_est_preferred_cpulist(struct netns_ipvs *ipvs)
+{
+ return NULL;
+}
+
static inline int sysctl_est_nice(struct netns_ipvs *ipvs)
{
return IPVS_EST_NICE;
diff --git a/net/netfilter/ipvs/ip_vs_est.c b/net/netfilter/ipvs/ip_vs_est.c
index f821ad2e19b3..15049b826732 100644
--- a/net/netfilter/ipvs/ip_vs_est.c
+++ b/net/netfilter/ipvs/ip_vs_est.c
@@ -265,7 +265,8 @@ int ip_vs_est_kthread_start(struct netns_ipvs *ipvs,
}
set_user_nice(kd->task, sysctl_est_nice(ipvs));
- set_cpus_allowed_ptr(kd->task, sysctl_est_cpulist(ipvs));
+ if (sysctl_est_preferred_cpulist(ipvs))
+ kthread_affine_preferred(kd->task, sysctl_est_preferred_cpulist(ipvs));
pr_info("starting estimator thread %d...\n", kd->id);
wake_up_process(kd->task);
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] ipvs: Fix estimator kthreads preferred affinity
2025-07-29 12:06 [PATCH net] ipvs: Fix estimator kthreads preferred affinity Frederic Weisbecker
@ 2025-08-27 10:48 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2025-08-27 10:48 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: LKML, David S. Miller, David Ahern, Julian Anastasov,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Pablo Neira Ayuso,
Jozsef Kadlecsik, netdev, lvs-devel, netfilter-devel, coreteam
On Tue, Jul 29, 2025 at 02:06:59PM +0200, Frederic Weisbecker wrote:
> The estimator kthreads' affinity are defined by sysctl overwritten
> preferences and applied through a plain call to the scheduler's affinity
> API.
>
> However since the introduction of managed kthreads preferred affinity,
> such a practice shortcuts the kthreads core code which eventually
> overwrites the target to the default unbound affinity.
>
> Fix this with using the appropriate kthread's API which will carry the
> desired affinity and maintain it across CPU hotplug events and CPU
> isolation constraints.
>
> Fixes: d1a89197589c ("kthread: Default affine kthread to its preferred NUMA node")
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-27 10:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29 12:06 [PATCH net] ipvs: Fix estimator kthreads preferred affinity Frederic Weisbecker
2025-08-27 10:48 ` Simon Horman
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).