Fundamentals 7 min read

Utilization Clamping (uclamp) in Linux Kernel Scheduling

Utilization clamping (uclamp) lets user space specify a task’s minimum and maximum CPU utilization, allowing the Linux scheduler to more accurately scale frequency and select cores, improving performance and power efficiency through per‑task, cgroup, and global APIs that replace the older schedtune mechanism.

OPPO Kernel Craftsman
OPPO Kernel Craftsman
OPPO Kernel Craftsman
Utilization Clamping (uclamp) in Linux Kernel Scheduling

With the continuous evolution of Linux kernel scheduling technologies, multiple scheduling classes (stop, deadline, rt, cfs, idle) exist to satisfy diverse task requirements. While most user‑space tasks rely on the Completely Fair Scheduler (CFS) or the Real‑Time scheduler (RT), POSIX priority mechanisms are insufficient for conveying task‑specific information such as core selection and frequency scaling. Passing this information from user space to the kernel scheduler enables more informed scheduling decisions, and Utilization Clamping (uclamp) provides exactly this mechanism.

Utilization refers to two dimensions: CPU Utilization, which indicates how busy a CPU is and drives frequency scaling (e.g., when the schedutil governor is active); and Task Utilization, which reflects how much CPU a particular task consumes, effectively classifying a task as “big” or “small.” The PELT load‑tracking algorithm sometimes mis‑estimates task utilization—for UI or control threads it may report a low value, causing the scheduler to treat them as small tasks, even though the user space expects them to run on high‑performance cores. Conversely, long‑running background tasks may be reported as large, though they do not require high performance.

uclamp allows user space to clamp a task’s utilization within a configurable range [util_min, util_max] . By raising util_min , a task appears larger, prompting the scheduler to keep the CPU at a higher performance state and accelerate the task. By lowering util_max , a task appears smaller, allowing the CPU to enter a low‑power state and reduce energy consumption.

Historically, Android Kernel 5.4 introduced a schedtune feature that offered similar functionality. Developed by Patrick Bellasi at ARM, uclamp was created as a replacement for schedtune, addressing its shortcomings and eventually being merged into the mainline kernel.

Software Architecture : A user‑space process‑management service obtains the desired util_min and util_max for each task and passes them to the kernel via appropriate interfaces. The scheduler then uses these values both for frequency scaling (through schedutil ) and for core selection, ensuring tasks run on suitable CPUs.

User‑Space Interfaces :

System‑wide API: proc/sys/kernel/sched_util_clamp_min and proc/sys/kernel/sched_util_clamp_max set global limits for per‑task‑group and per‑task values (range 0‑ SCHED_CAPACITY_SCALE ).

cgroup‑based API: cpu.uclamp.min and cpu.uclamp.max control per‑task‑group values as percentages (0.00‑100.00).

Per‑task API: The sched_setattr system call lets each task set its own uclamp_min and uclamp_max , subject to cgroup and global limits.

Bucket Algorithm : uclamp divides the range [0, SCHED_CAPACITY_SCALE] into UCLAMP_BUCKETS intervals (buckets). Each bucket stores a value and a list of tasks . Tasks’ uclamp_min values are placed into the UCLAMP_MIN bucket set, and uclamp_max values into the UCLAMP_MAX set. Within a bucket, the maximum value among its tasks determines the bucket’s contribution; the CPU’s final util_min or util_max is the maximum bucket value across all buckets, guaranteeing that high‑performance tasks always receive sufficient resources.

Conclusion : By exposing task‑level utilization information to the kernel scheduler, uclamp enables more accurate frequency scaling and core selection, delivering measurable improvements in both performance and power efficiency.

PerformanceKernelschedulerLinuxpower managementUtilization Clamping
OPPO Kernel Craftsman
Written by

OPPO Kernel Craftsman

Sharing Linux kernel-related cutting-edge technology, technical articles, technical news, and curated tutorials

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.