Skip to content

Commit 62607d0

Browse files
committed
sched_ext: Use sched_clock_cpu() instead of rq_clock_task() in touch_core_sched()
Since 3cf78c5 ("sched_ext: Unpin and repin rq lock from balance_scx()"), sched_ext's balance path terminates rq_pin in the outermost function. This is simpler and in line with what other balance functions are doing but it loses control over rq->clock_update_flags which makes assert_clock_udpated() trigger if other CPUs pins the rq lock. The only place this matters is touch_core_sched() which uses the timestamp to order tasks from sibling rq's. Switch to sched_clock_cpu(). Later, it may be better to use per-core dispatch sequence number. v2: Use sched_clock_cpu() instead of ktime_get_ns() per David. Signed-off-by: Tejun Heo <[email protected]> Fixes: 3cf78c5 ("sched_ext: Unpin and repin rq lock from balance_scx()") Acked-by: David Vernet <[email protected]> Cc: Peter Zijlstra <[email protected]>
1 parent 0366017 commit 62607d0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kernel/sched/ext.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,13 +1453,18 @@ static void schedule_deferred(struct rq *rq)
14531453
*/
14541454
static void touch_core_sched(struct rq *rq, struct task_struct *p)
14551455
{
1456+
lockdep_assert_rq_held(rq);
1457+
14561458
#ifdef CONFIG_SCHED_CORE
14571459
/*
14581460
* It's okay to update the timestamp spuriously. Use
14591461
* sched_core_disabled() which is cheaper than enabled().
1462+
*
1463+
* As this is used to determine ordering between tasks of sibling CPUs,
1464+
* it may be better to use per-core dispatch sequence instead.
14601465
*/
14611466
if (!sched_core_disabled())
1462-
p->scx.core_sched_at = rq_clock_task(rq);
1467+
p->scx.core_sched_at = sched_clock_cpu(cpu_of(rq));
14631468
#endif
14641469
}
14651470

@@ -1476,7 +1481,6 @@ static void touch_core_sched(struct rq *rq, struct task_struct *p)
14761481
static void touch_core_sched_dispatch(struct rq *rq, struct task_struct *p)
14771482
{
14781483
lockdep_assert_rq_held(rq);
1479-
assert_clock_updated(rq);
14801484

14811485
#ifdef CONFIG_SCHED_CORE
14821486
if (SCX_HAS_OP(core_sched_before))

0 commit comments

Comments
 (0)