Re: [PATCH v2 2/5] sched_ext: Manage the validity of scx_rq_clock

From: Peter Zijlstra
Date: Mon Dec 02 2024 - 04:59:02 EST


On Mon, Dec 02, 2024 at 01:38:46PM +0900, Changwoo Min wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 95e40895a519..ab8015c8cab4 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -789,6 +789,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
> void update_rq_clock(struct rq *rq)
> {
> s64 delta;
> + u64 clock;
>
> lockdep_assert_rq_held(rq);
>
> @@ -800,11 +801,14 @@ void update_rq_clock(struct rq *rq)
> SCHED_WARN_ON(rq->clock_update_flags & RQCF_UPDATED);
> rq->clock_update_flags |= RQCF_UPDATED;
> #endif
> + clock = sched_clock_cpu(cpu_of(rq));
> + scx_rq_clock_update(rq, clock);

This adds a write to a second cacheline for *everyone* always.

Please don't do that.