[PATCH 09/17] sched/core: Add support for nohz_full CPUs

Shrikanth Hegde posted 17 patches 1 week, 5 days ago
There is a newer version of this series
[PATCH 09/17] sched/core: Add support for nohz_full CPUs
Posted by Shrikanth Hegde 1 week, 5 days ago
Enable tick on nohz full CPU when it is marked as paravirt.
If there in no CFS/RT running there, disable the tick to save the power.

In addition to this, arch specific code which enables the paravirt CPU
should call, tick_nohz_dep_set_cpu with TICK_DEP_BIT_SCHED for moving
the task out of nohz_full CPU fast.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 kernel/sched/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 90fc04d84b74..73d1d49a3c72 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1336,6 +1336,10 @@ bool sched_can_stop_tick(struct rq *rq)
 {
 	int fifo_nr_running;
 
+	/* Keep the tick running until both RT and CFS are pushed out*/
+	if (cpu_paravirt(rq->cpu) && (rq->rt.rt_nr_running || rq->cfs.h_nr_queued))
+		return false;
+
 	/* Deadline tasks, even if single, need the tick */
 	if (rq->dl.dl_nr_running)
 		return false;
-- 
2.47.3
Re: [PATCH 09/17] sched/core: Add support for nohz_full CPUs
Posted by K Prateek Nayak 1 week, 3 days ago
Hello Shrikanth,

On 11/19/2025 6:14 PM, Shrikanth Hegde wrote:
> Enable tick on nohz full CPU when it is marked as paravirt.
> If there in no CFS/RT running there, disable the tick to save the power.

Wouldn't the task be pinned if it is running on a nohz CPU?
We don't push out pinned tasks so this seems unnecessary.
Am I missing something?

-- 
Thanks and Regards,
Prateek
Re: [PATCH 09/17] sched/core: Add support for nohz_full CPUs
Posted by Shrikanth Hegde 1 week, 3 days ago
Hi Prateek.

On 11/21/25 8:46 AM, K Prateek Nayak wrote:
> Hello Shrikanth,
> 
> On 11/19/2025 6:14 PM, Shrikanth Hegde wrote:
>> Enable tick on nohz full CPU when it is marked as paravirt.
>> If there in no CFS/RT running there, disable the tick to save the power.
> 
> Wouldn't the task be pinned if it is running on a nohz CPU?
> We don't push out pinned tasks so this seems unnecessary.
> Am I missing something?
> 

No. Task will not be pinned if it running on nohz_full unless
user has done a taskset. They are still part of sched domains.

Pinning is usually true for isolcpus. You need to explicity set taskset
for isolcpus since by default you won't go to those CPUs.

on nohz_full it is just that tick will be disabled when it has
only one task running. If there are more task on it, tick will be
enabled and load balancing can run.

Example:  ( i have 300-479 as nohz_full)
taskset -c 300-315 stress-ng --cpu=2

(it was initially on 301,302)
10:27:37 PM  301  100.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
10:27:37 PM  302  100.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00

Ran hackbench for a brief time. After hackbench completes,
(it runs now on 301,314)
10:27:43 PM  301  100.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
10:27:43 PM  314  100.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
Re: [PATCH 09/17] sched/core: Add support for nohz_full CPUs
Posted by K Prateek Nayak 1 week ago
Hello Shrikanth,

On 11/21/2025 10:10 AM, Shrikanth Hegde wrote:
>> Wouldn't the task be pinned if it is running on a nohz CPU?
>> We don't push out pinned tasks so this seems unnecessary.
>> Am I missing something?
>>
> 
> No. Task will not be pinned if it running on nohz_full unless
> user has done a taskset. They are still part of sched domains.
> 
> Pinning is usually true for isolcpus. You need to explicity set taskset
> for isolcpus since by default you won't go to those CPUs.

TIL! I was under the impression that nohz_full is a superset of isolcpus
but I was clearly mistaken. Thank you for clarifying.

-- 
Thanks and Regards,
Prateek