ipvs: Fix estimator kthreads preferred affinity
authorFrederic Weisbecker <frederic@kernel.org>
Tue, 29 Jul 2025 12:26:11 +0000 (14:26 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 13 Aug 2025 06:34:33 +0000 (08:34 +0200)
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.

Fixes: d1a89197589c ("kthread: Default affine kthread to its preferred NUMA node")
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Florian Westphal <fw@strlen.de>
include/net/ip_vs.h
kernel/kthread.c
net/netfilter/ipvs/ip_vs_est.c

index ff406ef4fd4aabb1f190d1175302a63e2e542658..29a36709e7f35c00040a82a4c9c8c5508159611e 100644 (file)
@@ -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;
index 0e98b228a8efdd6ea45102075dc21bbb8c52b970..31b072e8d4279f290002e0a83c5cfc3e6584cfdd 100644 (file)
@@ -893,6 +893,7 @@ out:
 
        return ret;
 }
+EXPORT_SYMBOL_GPL(kthread_affine_preferred);
 
 /*
  * Re-affine kthreads according to their preferences
index f821ad2e19b35ebc11b529589592dc0f5f2af2f7..15049b826732726172fbcd20994cf550702b6623 100644 (file)
@@ -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);