Skip to content

Commit 2e1ce39

Browse files
Changwoo Minhtejun
authored andcommitted
sched_ext: Add scx_bpf_now() for BPF scheduler
scx_bpf_now() is added to the header files so the BPF scheduler can use it. Signed-off-by: Changwoo Min <changwoo@igalia.com> Acked-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 3a9910b commit 2e1ce39

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tools/sched_ext/include/scx/common.bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ bool scx_bpf_task_running(const struct task_struct *p) __ksym;
7676
s32 scx_bpf_task_cpu(const struct task_struct *p) __ksym;
7777
struct rq *scx_bpf_cpu_rq(s32 cpu) __ksym;
7878
struct cgroup *scx_bpf_task_cgroup(struct task_struct *p) __ksym __weak;
79+
u64 scx_bpf_now(void) __ksym __weak;
7980

8081
/*
8182
* Use the following as @it__iter when calling scx_bpf_dsq_move[_vtime]() from

tools/sched_ext/include/scx/compat.bpf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ bool scx_bpf_dispatch_vtime_from_dsq___compat(struct bpf_iter_scx_dsq *it__iter,
125125
false; \
126126
})
127127

128+
#define scx_bpf_now() \
129+
(bpf_ksym_exists(scx_bpf_now) ? \
130+
scx_bpf_now() : \
131+
bpf_ktime_get_ns())
132+
128133
/*
129134
* Define sched_ext_ops. This may be expanded to define multiple variants for
130135
* backward compatibility. See compat.h::SCX_OPS_LOAD/ATTACH().

0 commit comments

Comments
 (0)