Hi Changwoo,Opps. My bad.
On Fri, Dec 20, 2024 at 03:20:21PM +0900, Changwoo Min wrote:
...
+ /*
+ * If the rq clock is valid, use the cached rq clock.
+ * Otherwise, return a fresh rq glock.
s/glock/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);
+ }
I was wondering if we could use a special value for clock (like ~0ULL or
similar) to mark the clock as invalid.
This way, we could get rid of the extra READ_ONCE(rq->scx.flags) logic for
checking the clock validity. And if the actual clock happens to match the
special value, we'd simply re-read the TSC, which shouldn't be a big issue
in theory.