Skip to content

Commit

Permalink
kernel: Force trivial, unbound kthreads onto low-power CPUs
Browse files Browse the repository at this point in the history
In order to reduce power consumption, force all non-perf-critical, unbound
kthreads onto the low-power CPUs. Note that init (pid == 1) must be
explicitly excluded from this so that all processes forked from init have a
sane default CPU affinity mask.

Signed-off-by: Sultan Alsawaf <sultanxda@gmail.com>
  • Loading branch information
sidex15 committed Nov 16, 2024
1 parent 829b756 commit f3c6fc9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,10 @@ adjust_cpumask(const struct task_struct *p,
/* Force all performance-critical kthreads onto the big cluster */
if (p->flags & PF_PERF_CRITICAL)
return cpu_perf_mask;
/* Force all trivial, unbound kthreads onto the little cluster */
if (p->flags & PF_KTHREAD && p->pid != 1 &&
cpumask_equal(req_mask, cpu_all_mask))
return cpu_lp_mask;

return orig_mask;
}
Expand Down

0 comments on commit f3c6fc9

Please sign in to comment.