Skip to contentSkip to conversation

sched/deadline: Do not start hrtick if its disabled for DL

PATCH In review Joel Fernandes (Google) 2 participants 3 messages Nov 12, 2024 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/deadline: Do not start hrtick if its disabled for DL

Fix an issue where high-resolution timers causes aggressive preemptions, leading to increased idle times in CFS tasks (which are inside the DL server). The problem was traced to improper usage of hrtick_enabled(), which could start high-resolution ticks unexpectedly causing repeated preemptions.

The fix replaces this call with hrtick_enabled_dl(), aligning it with scheduler feature checks.

---
 kernel/sched/deadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +1 -1
index b216e6deeac4..d46502b9ce58 100644
@@ -2121,7 +2121,7 @@ static struct task_struct *pick_next_task_dl(struct rq *rq)
 	if (!p->dl_server)
 		set_next_task_dl(rq, p, true);
 
-	if (hrtick_enabled(rq))
+	if (hrtick_enabled_dl(rq))
 		start_hrtick_dl(rq, &p->dl);
 
 	return p;
Signature · 1 line
2.47.0.277.g8800431eea-goog
maintainer
#1 lore raw

Hi Joel,

Quoted 22 lines · Joel Fernandes (Google)

Fix an issue where high-resolution timers causes aggressive preemptions, leading to increased idle times in CFS tasks (which are inside the DL server). The problem was traced to improper usage of hrtick_enabled(), which could start high-resolution ticks unexpectedly causing repeated preemptions.

The fix replaces this call with hrtick_enabled_dl(), aligning it with scheduler feature checks.

---
 kernel/sched/deadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +0 -0
index b216e6deeac4..d46502b9ce58 100644

kernel/sched/deadline.c static struct task_struct *pick_next_task_dl(struct rq *rq) · line 2127

Quoted 8 lines
kernel/sched/deadline.c +1 -1
@@ -2121,7 +2121,7 @@ static struct task_struct *pick_next_task_dl(struct rq *rq)
 	if (!p->dl_server)
 		set_next_task_dl(rq, p, true);
 
-	if (hrtick_enabled(rq))
+	if (hrtick_enabled_dl(rq))
 		start_hrtick_dl(rq, &p->dl);
 
 	return p;

I'm not sure I'm seeing this in current code. We have two users in deadline.c and they both use hrtick_enabled_dl (after a recent fix by Phil).

Best,
Juri

#2 lore raw
Quoted 31 lines · Juri Lelli

Hi Joel,

Quoted 28 lines · Joel Fernandes (Google)

Fix an issue where high-resolution timers causes aggressive preemptions, leading to increased idle times in CFS tasks (which are inside the DL server). The problem was traced to improper usage of hrtick_enabled(), which could start high-resolution ticks unexpectedly causing repeated preemptions.

The fix replaces this call with hrtick_enabled_dl(), aligning it with scheduler feature checks.

---
 kernel/sched/deadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +1 -1
index b216e6deeac4..d46502b9ce58 100644
@@ -2121,7 +2121,7 @@ static struct task_struct *pick_next_task_dl(struct rq *rq)
 	if (!p->dl_server)
 		set_next_task_dl(rq, p, true);
 
-	if (hrtick_enabled(rq))
+	if (hrtick_enabled_dl(rq))
 		start_hrtick_dl(rq, &p->dl);
 
Quoted 6 lines

kernel/sched/deadline.c static struct task_struct *pick_next_task_dl(struct rq *rq) · line 2127

Quoted 2 lines
kernel/sched/deadline.c +0 -0
 	return p;

I'm not sure I'm seeing this in current code. We have two users in deadline.c and they both use hrtick_enabled_dl (after a recent fix by Phil).

Ah you're right. The latest kernel we are on is on 6.6 so this got missed.

Thanks Juri for your quick reply and pointing out the missing patches!

- Joel