From 24e094ef5e58809da37434add46920faaebfa14b Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sat, 18 Oct 2025 06:53:28 -0400 Subject: [PATCH] lib: move cpu_load into lib/os Move cpu_load to lib/os, as this functionality on its own does not justify being a subsystem on its own. Fixes #95498 Signed-off-by: Anas Nashif --- MAINTAINERS.yml | 2 -- doc/services/cpu_freq/policies/on_demand.rst | 2 +- doc/services/cpu_load/index.rst | 2 +- include/zephyr/{cpu_load => sys}/cpu_load.h | 0 lib/os/CMakeLists.txt | 1 + lib/os/Kconfig | 1 + {subsys => lib/os}/cpu_load/CMakeLists.txt | 0 {subsys => lib/os}/cpu_load/Kconfig | 4 ++-- {subsys => lib/os}/cpu_load/cpu_load.c | 0 subsys/CMakeLists.txt | 1 - subsys/Kconfig | 1 - subsys/cpu_freq/policies/on_demand/on_demand.c | 2 +- 12 files changed, 7 insertions(+), 9 deletions(-) rename include/zephyr/{cpu_load => sys}/cpu_load.h (100%) rename {subsys => lib/os}/cpu_load/CMakeLists.txt (100%) rename {subsys => lib/os}/cpu_load/Kconfig (87%) rename {subsys => lib/os}/cpu_load/cpu_load.c (100%) diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index 2176e228089..0a996a1d725 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -855,8 +855,6 @@ CPU Frequency Scaling: - seankyer files: - include/zephyr/cpu_freq/ - - include/zephyr/cpu_load/ - - subsys/cpu_load/ - subsys/cpu_freq/ - dts/bindings/p_state/ labels: diff --git a/doc/services/cpu_freq/policies/on_demand.rst b/doc/services/cpu_freq/policies/on_demand.rst index ea1d3e15b09..63026bc4547 100644 --- a/doc/services/cpu_freq/policies/on_demand.rst +++ b/doc/services/cpu_freq/policies/on_demand.rst @@ -4,7 +4,7 @@ On-Demand CPU Frequency Scaling Policy ###################################### The On-Demand policy evaluates the current CPU load using the -:ref:`CPU Load subsystem `, and compares it to the trigger threshold defined by the +:ref:`CPU Load metric `, and compares it to the trigger threshold defined by the SoC P-state definition. The On-Demand policy will iterate through the defined P-states and select the first P-state of which diff --git a/doc/services/cpu_load/index.rst b/doc/services/cpu_load/index.rst index 68fb257ebba..5ed96621a05 100644 --- a/doc/services/cpu_load/index.rst +++ b/doc/services/cpu_load/index.rst @@ -1,4 +1,4 @@ -.. _cpu_load_subsys: +.. _cpu_load_metric: CPU Load ######## diff --git a/include/zephyr/cpu_load/cpu_load.h b/include/zephyr/sys/cpu_load.h similarity index 100% rename from include/zephyr/cpu_load/cpu_load.h rename to include/zephyr/sys/cpu_load.h diff --git a/lib/os/CMakeLists.txt b/lib/os/CMakeLists.txt index 7fc5f23ff47..c1be6613ab0 100644 --- a/lib/os/CMakeLists.txt +++ b/lib/os/CMakeLists.txt @@ -50,6 +50,7 @@ zephyr_syscall_header_ifdef(CONFIG_FDTABLE zephyr_sources_ifdef(CONFIG_CBPRINTF_COMPLETE cbprintf_complete.c) zephyr_sources_ifdef(CONFIG_CBPRINTF_NANO cbprintf_nano.c) +add_subdirectory_ifdef(CONFIG_CPU_LOAD_METRIC cpu_load) if(NOT CONFIG_PICOLIBC) zephyr_sources(cbprintf.c) diff --git a/lib/os/Kconfig b/lib/os/Kconfig index eb1433e09d1..ece806dcdea 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -151,5 +151,6 @@ config POWEROFF rsource "Kconfig.cbprintf" rsource "zvfs/Kconfig" +rsource "cpu_load/Kconfig" endmenu diff --git a/subsys/cpu_load/CMakeLists.txt b/lib/os/cpu_load/CMakeLists.txt similarity index 100% rename from subsys/cpu_load/CMakeLists.txt rename to lib/os/cpu_load/CMakeLists.txt diff --git a/subsys/cpu_load/Kconfig b/lib/os/cpu_load/Kconfig similarity index 87% rename from subsys/cpu_load/Kconfig rename to lib/os/cpu_load/Kconfig index 7772a6695e7..4941cf8b1a4 100644 --- a/subsys/cpu_load/Kconfig +++ b/lib/os/cpu_load/Kconfig @@ -3,14 +3,14 @@ # SPDX-License-Identifier: Apache-2.0 menuconfig CPU_LOAD_METRIC - bool "CPU Load Subsystem" + bool "CPU Load Metric" select EXPERIMENTAL select THREAD_RUNTIME_STATS select SCHED_THREAD_USAGE select SCHED_THREAD_USAGE_ALL select SCHED_THREAD_USAGE_AUTO_ENABLE help - CPU Load subsystem + Tracking of CPU load statistics. if CPU_LOAD_METRIC diff --git a/subsys/cpu_load/cpu_load.c b/lib/os/cpu_load/cpu_load.c similarity index 100% rename from subsys/cpu_load/cpu_load.c rename to lib/os/cpu_load/cpu_load.c diff --git a/subsys/CMakeLists.txt b/subsys/CMakeLists.txt index 756214ad752..979fb92f5f4 100644 --- a/subsys/CMakeLists.txt +++ b/subsys/CMakeLists.txt @@ -41,7 +41,6 @@ add_subdirectory_ifdef(CONFIG_BINDESC bindesc) add_subdirectory_ifdef(CONFIG_BT bluetooth) add_subdirectory_ifdef(CONFIG_CONSOLE_SUBSYS console) add_subdirectory_ifdef(CONFIG_CPU_FREQ cpu_freq) -add_subdirectory_ifdef(CONFIG_CPU_LOAD_METRIC cpu_load) add_subdirectory_ifdef(CONFIG_CRC crc) add_subdirectory_ifdef(CONFIG_DAP dap) add_subdirectory_ifdef(CONFIG_DEMAND_PAGING demand_paging) diff --git a/subsys/Kconfig b/subsys/Kconfig index f35a0d1c906..380c0e5d944 100644 --- a/subsys/Kconfig +++ b/subsys/Kconfig @@ -12,7 +12,6 @@ source "subsys/bluetooth/Kconfig" source "subsys/canbus/Kconfig" source "subsys/console/Kconfig" source "subsys/cpu_freq/Kconfig" -source "subsys/cpu_load/Kconfig" source "subsys/crc/Kconfig" source "subsys/dap/Kconfig" source "subsys/debug/Kconfig" diff --git a/subsys/cpu_freq/policies/on_demand/on_demand.c b/subsys/cpu_freq/policies/on_demand/on_demand.c index 41b9b733eab..1cc1cdec78d 100644 --- a/subsys/cpu_freq/policies/on_demand/on_demand.c +++ b/subsys/cpu_freq/policies/on_demand/on_demand.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include LOG_MODULE_REGISTER(cpu_freq_policy_on_demand, CONFIG_CPU_FREQ_LOG_LEVEL);