Skip to content

Commit c0a23bb

Browse files
Frederic WeisbeckerFlorian Westphal
authored andcommitted
ipvs: Fix estimator kthreads preferred affinity
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: d1a8919 ("kthread: Default affine kthread to its preferred NUMA node") Signed-off-by: Frederic Weisbecker <[email protected]> Acked-by: Julian Anastasov <[email protected]> Signed-off-by: Florian Westphal <[email protected]>
1 parent 30c1d25 commit c0a23bb

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

include/net/ip_vs.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,14 @@ static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
11631163
return housekeeping_cpumask(HK_TYPE_KTHREAD);
11641164
}
11651165

1166+
static inline const struct cpumask *sysctl_est_preferred_cpulist(struct netns_ipvs *ipvs)
1167+
{
1168+
if (ipvs->est_cpulist_valid)
1169+
return ipvs->sysctl_est_cpulist;
1170+
else
1171+
return NULL;
1172+
}
1173+
11661174
static inline int sysctl_est_nice(struct netns_ipvs *ipvs)
11671175
{
11681176
return ipvs->sysctl_est_nice;
@@ -1270,6 +1278,11 @@ static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
12701278
return housekeeping_cpumask(HK_TYPE_KTHREAD);
12711279
}
12721280

1281+
static inline const struct cpumask *sysctl_est_preferred_cpulist(struct netns_ipvs *ipvs)
1282+
{
1283+
return NULL;
1284+
}
1285+
12731286
static inline int sysctl_est_nice(struct netns_ipvs *ipvs)
12741287
{
12751288
return IPVS_EST_NICE;

kernel/kthread.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
893893

894894
return ret;
895895
}
896+
EXPORT_SYMBOL_GPL(kthread_affine_preferred);
896897

897898
/*
898899
* Re-affine kthreads according to their preferences

net/netfilter/ipvs/ip_vs_est.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ int ip_vs_est_kthread_start(struct netns_ipvs *ipvs,
265265
}
266266

267267
set_user_nice(kd->task, sysctl_est_nice(ipvs));
268-
set_cpus_allowed_ptr(kd->task, sysctl_est_cpulist(ipvs));
268+
if (sysctl_est_preferred_cpulist(ipvs))
269+
kthread_affine_preferred(kd->task, sysctl_est_preferred_cpulist(ipvs));
269270

270271
pr_info("starting estimator thread %d...\n", kd->id);
271272
wake_up_process(kd->task);

0 commit comments

Comments
 (0)