Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched_ext: Use sched_clock_cpu() instead of rq_clock_task() in touch_core_sched()

Since 3cf78c5d01d6 ("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 <tj@kernel.org>
Fixes: 3cf78c5d01d6 ("sched_ext: Unpin and repin rq lock from balance_scx()")
Acked-by: David Vernet <void@manifault.com>
Cc: Peter Zijlstra <peterz@infradead.org>

+6 -2
+6 -2
kernel/sched/ext.c
··· 1453 1453 */ 1454 1454 static void touch_core_sched(struct rq *rq, struct task_struct *p) 1455 1455 { 1456 + lockdep_assert_rq_held(rq); 1457 + 1456 1458 #ifdef CONFIG_SCHED_CORE 1457 1459 /* 1458 1460 * It's okay to update the timestamp spuriously. Use 1459 1461 * 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. 1460 1465 */ 1461 1466 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)); 1463 1468 #endif 1464 1469 } 1465 1470 ··· 1481 1476 static void touch_core_sched_dispatch(struct rq *rq, struct task_struct *p) 1482 1477 { 1483 1478 lockdep_assert_rq_held(rq); 1484 - assert_clock_updated(rq); 1485 1479 1486 1480 #ifdef CONFIG_SCHED_CORE 1487 1481 if (SCX_HAS_OP(core_sched_before))