]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched/fair: Simplify hrtick_update()
authorPeter Zijlstra (Intel) <peterz@infradead.org>
Tue, 24 Feb 2026 16:35:22 +0000 (17:35 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 27 Feb 2026 15:40:03 +0000 (16:40 +0100)
hrtick_update() was needed when the slice depended on nr_running, all that
code is gone. All that remains is starting the hrtick when nr_running
becomes more than 1.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260224163428.866374835@kernel.org
kernel/sched/fair.c
kernel/sched/sched.h

index 247fecd1ac41d4fb8639306f222ccd87730f5b99..0b6ce88f8e54fc1b271ecb87ea3e7c0933f36060 100644 (file)
@@ -6769,9 +6769,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
 }
 
 /*
- * called from enqueue/dequeue and updates the hrtick when the
- * current task is from our class and nr_running is low enough
- * to matter.
+ * Called on enqueue to start the hrtick when h_nr_queued becomes more than 1.
  */
 static void hrtick_update(struct rq *rq)
 {
@@ -6780,6 +6778,9 @@ static void hrtick_update(struct rq *rq)
        if (!hrtick_enabled_fair(rq) || donor->sched_class != &fair_sched_class)
                return;
 
+       if (hrtick_active(rq))
+               return;
+
        hrtick_start_fair(rq, donor);
 }
 #else /* !CONFIG_SCHED_HRTICK: */
@@ -7102,9 +7103,6 @@ static int dequeue_entities(struct rq *rq, struct sched_entity *se, int flags)
                WARN_ON_ONCE(!task_sleep);
                WARN_ON_ONCE(p->on_rq != 1);
 
-               /* Fix-up what dequeue_task_fair() skipped */
-               hrtick_update(rq);
-
                /*
                 * Fix-up what block_task() skipped.
                 *
@@ -7138,8 +7136,6 @@ static bool dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
        /*
         * Must not reference @p after dequeue_entities(DEQUEUE_DELAYED).
         */
-
-       hrtick_update(rq);
        return true;
 }
 
index b82fb70a9d5494055ea5b22e828b1c6bb75b0187..73bc20c47631d2f046a6ba2983e2c22c63c90be1 100644 (file)
@@ -3041,6 +3041,10 @@ static inline int hrtick_enabled_dl(struct rq *rq)
 }
 
 extern void hrtick_start(struct rq *rq, u64 delay);
+static inline bool hrtick_active(struct rq *rq)
+{
+       return hrtimer_active(&rq->hrtick_timer);
+}
 
 #else /* !CONFIG_SCHED_HRTICK: */