Hello,
On Fri, Dec 20, 2024 at 03:20:21PM +0900, Changwoo Min wrote:
...
+__bpf_kfunc u64 scx_bpf_now_ns(void)
Given that the default time unit is ns for the scheduler, the _ns suffix
can probably go.
It can be dropped as we do not track prev_clock.+ if (!(READ_ONCE(rq->scx.flags) & SCX_RQ_CLK_VALID)) {
+ clock = sched_clock_cpu(cpu_of(rq));
+
+ /*
+ * The rq clock is updated outside of the rq lock.
+ * In this case, keep the updated rq clock invalid so the next
+ * kfunc call outside the rq lock gets a fresh rq clock.
+ */
+ scx_rq_clock_update(rq, clock, false);
Hmm... what does this update do?
...
+static inline void scx_rq_clock_update(struct rq *rq, u64 clock, bool valid)
+{
+ if (!scx_enabled())
+ return;
+ WRITE_ONCE(rq->scx.clock, clock);
+ if (valid)
+ WRITE_ONCE(rq->scx.flags, rq->scx.flags | SCX_RQ_CLK_VALID);
+}
Isn't rq->scx.clock used iff VALID is set? If so, why does !VALID read need
to update rq->scx.clock?