OSDN Git Service

kernel: Add API to mark IRQs and kthreads as performance critical
authorSultan Alsawaf <sultan@kerneltoast.com>
Sat, 20 Jul 2019 07:10:53 +0000 (00:10 -0700)
committer0ranko0P <ranko0p@outlook.com>
Sat, 7 Dec 2019 10:01:09 +0000 (18:01 +0800)
commit4f521eb62d2364433d09261e26122f16f314b702
treebf51d8c0482f58853e916bbbba775ca1a4278030
parent8df652f368a190ef9d7457309c52614bf5e93a13
kernel: Add API to mark IRQs and kthreads as performance critical

On devices with a CPU that contains heterogeneous cores (e.g.,
big.LITTLE), it can be beneficial to place some performance-critical
IRQs and kthreads onto the performance CPU cluster in order to improve
performance.

This commit adds the following APIs:
-kthread_run_perf_critical() to create and start a perf-critical kthread
-irq_set_perf_affinity() to mark an active IRQ as perf-critical
-IRQF_PERF_CRITICAL to schedule an IRQ and any threads it may have onto
 performance CPUs
-PF_PERF_CRITICAL to mark a process (mainly a kthread) as performance
 critical (this is used by kthread_run_perf_critical())

In order to accommodate this new API, the following changes are made:
-Performance-critical IRQs are distributed evenly among online CPUs
 available in cpu_perf_mask
-Performance-critical IRQs have their affinities reaffined upon exit
 from suspend (since the affinities are broken when non-boot CPUs are
 disabled)
-Performance-critical IRQs and their threads have their affinities reset
 upon entering suspend, so that upon immediate suspend exit (when only
 the boot CPU is online), interrupts can be processed and interrupt
 threads can be scheduled onto an online CPU (otherwise we'd hit a
 kernel BUG)
-__set_cpus_allowed_ptr() is modified to enforce a performance-critical
 kthread's affinity
-Perf-critical IRQs are marked with IRQD_AFFINITY_MANAGED so userspace
 can't mess with their affinity

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
include/linux/interrupt.h
include/linux/kthread.h
include/linux/sched.h
kernel/cpu.c
kernel/irq/manage.c
kernel/sched/core.c