[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <494b8851-ba5b-4205-bea0-dc504c2ffa33@igalia.com>
Date: Mon, 18 Nov 2024 00:46:32 +0900
From: Changwoo Min <changwoo@...lia.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: tj@...nel.org, void@...ifault.com, mingo@...hat.com,
kernel-dev@...lia.com, linux-kernel@...r.kernel.org,
Changwoo Min <changwoo@...lia.com>
Subject: Re: [PATCH 2/5] sched_ext: Manage the validity of scx_rq_clock
Hello,
On 24. 11. 17. 04:32, Peter Zijlstra wrote:
> It is not at all clear why you think you need to keep a second copy of
> that value. You like cache misses?
Of course not. :-) I always try to avoid cache misses whenever
possible.
The main reason to keep the second copy (rq->scx.clock) is that
a BPF scheduler can call scx_bpf_clock_get_ns() at almost any
time in any context, including any of sched_ext operations, BPF
timer callbacks, BPF syscalls, kprobes, and so on.
However, the rq->clock is supposed to be updated while holding
the rq lock (lockdep_assert_rq_held), which is not always the
case in a BPF scheduler. Also, rq->clock is also used in other
places (e.g., PELT), so updating rq->clock in arbitrary points by
a BPF scheduler will create unnecessary dependencies.
Another approach would be to extend struct sched_clock_data (in
kernel/sched/clock.c) to store the update flag
(SCX_RQ_CLK_UPDATED). This would be the best regarding the number
of cache line accesses. However, that would be an overkill since
now sched_clock_data stores the sched_ext-specific data.
I thought it would be better to keep sched_ext specific data in
one place, struct scx_rq, for managibility.
Regards,
Changwoo Min
Powered by blists - more mailing lists