Skip to content

Commit 93940fb

Browse files
cloehlerafaeljw
authored andcommitted
cpufreq/schedutil: Only bind threads if needed
Remove the unconditional binding of sugov kthreads to the affected CPUs if the cpufreq driver indicates that updates can happen from any CPU. This allows userspace to set affinities to either save power (waking up bigger CPUs on HMP can be expensive) or increasing performance (by letting the utilized CPUs run without preemption of the sugov kthread). Signed-off-by: Christian Loehle <[email protected]> Acked-by: Viresh Kumar <[email protected]> Acked-by: Vincent Guittot <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Acked-by: Juri Lelli <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 2b16c63 commit 93940fb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

kernel/sched/cpufreq_schedutil.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,11 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
666666
}
667667

668668
sg_policy->thread = thread;
669-
kthread_bind_mask(thread, policy->related_cpus);
669+
if (policy->dvfs_possible_from_any_cpu)
670+
set_cpus_allowed_ptr(thread, policy->related_cpus);
671+
else
672+
kthread_bind_mask(thread, policy->related_cpus);
673+
670674
init_irq_work(&sg_policy->irq_work, sugov_irq_work);
671675
mutex_init(&sg_policy->work_lock);
672676

kernel/sched/syscalls.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,13 @@ int dl_task_check_affinity(struct task_struct *p, const struct cpumask *mask)
11291129
if (!task_has_dl_policy(p) || !dl_bandwidth_enabled())
11301130
return 0;
11311131

1132+
/*
1133+
* The special/sugov task isn't part of regular bandwidth/admission
1134+
* control so let userspace change affinities.
1135+
*/
1136+
if (dl_entity_is_special(&p->dl))
1137+
return 0;
1138+
11321139
/*
11331140
* Since bandwidth control happens on root_domain basis,
11341141
* if admission test is enabled, we only admit -deadline

0 commit comments

Comments
 (0)