Skip to content

Commit 4d3b29a

Browse files
Lin YikaiKernel Patches Daemon
authored andcommitted
cpuidle: Implement BPF extensible cpuidle class
The BPF cpuidle ext governor registers at postcore_initcall() but remains disabled by default due to its low priority "rating" (1). Activation requires adjust higer "rating" than other governors within BPF. Core Components: 1.**struct cpuidle_gov_ext_ops** – BPF-overridable operations: - ops.enable()/ops.disable(): enable or disable callback - ops.select(): cpu Idle-state selection logic - ops.set_stop_tick(): Scheduler tick management after state selection - ops.reflect(): feedback info about previous idle state. - ops.init()/ops.deinit(): Initialization or cleanup. 2.**Critical kfuncs for kernel state access**: - bpf_cpuidle_ext_gov_update_rating(): Activate ext governor by raising rating must be called from "ops.init()" - bpf_cpuidle_ext_gov_latency_req(): get idle-state latency constraints - bpf_tick_nohz_get_sleep_length(): get CPU sleep duration in tickless mode Signed-off-by: Lin Yikai <[email protected]>
1 parent 27199db commit 4d3b29a

File tree

3 files changed

+550
-0
lines changed

3 files changed

+550
-0
lines changed

drivers/cpuidle/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ config CPU_IDLE_GOV_HALTPOLL
4444

4545
Some virtualized workloads benefit from using it.
4646

47+
config CPU_IDLE_GOV_EXT
48+
bool "bpf cpuidle ext governor"
49+
depends on BPF_SYSCALL && BPF_JIT && DEBUG_INFO_BTF
50+
default y
51+
help
52+
This governor implements a simple cpuidle ext governor,
53+
which can be customized by a BPF program without modifying
54+
kernel code.
55+
56+
Some scenarios benefit where CPUidle policy needs
57+
to be customized based on user-space requirements.
58+
4759
config DT_IDLE_STATES
4860
bool
4961

drivers/cpuidle/governors/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o
77
obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o
88
obj-$(CONFIG_CPU_IDLE_GOV_TEO) += teo.o
99
obj-$(CONFIG_CPU_IDLE_GOV_HALTPOLL) += haltpoll.o
10+
obj-$(CONFIG_CPU_IDLE_GOV_EXT) += ext.o

0 commit comments

Comments
 (0)