Skip to content

Commit 0f130bc

Browse files
Changwoo Minhtejun
authored andcommitted
sched_ext: Replace bpf_ktime_get_ns() to scx_bpf_now()
In the BPF schedulers that use bpf_ktime_get_ns() -- scx_central and scx_flatcg, replace bpf_ktime_get_ns() calls to scx_bpf_now(). 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 d07be81 commit 0f130bc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tools/sched_ext/scx_central.bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void BPF_STRUCT_OPS(central_running, struct task_struct *p)
245245
s32 cpu = scx_bpf_task_cpu(p);
246246
u64 *started_at = ARRAY_ELEM_PTR(cpu_started_at, cpu, nr_cpu_ids);
247247
if (started_at)
248-
*started_at = bpf_ktime_get_ns() ?: 1; /* 0 indicates idle */
248+
*started_at = scx_bpf_now() ?: 1; /* 0 indicates idle */
249249
}
250250

251251
void BPF_STRUCT_OPS(central_stopping, struct task_struct *p, bool runnable)
@@ -258,7 +258,7 @@ void BPF_STRUCT_OPS(central_stopping, struct task_struct *p, bool runnable)
258258

259259
static int central_timerfn(void *map, int *key, struct bpf_timer *timer)
260260
{
261-
u64 now = bpf_ktime_get_ns();
261+
u64 now = scx_bpf_now();
262262
u64 nr_to_kick = nr_queued;
263263
s32 i, curr_cpu;
264264

tools/sched_ext/scx_flatcg.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ void BPF_STRUCT_OPS(fcg_dispatch, s32 cpu, struct task_struct *prev)
734734
struct fcg_cpu_ctx *cpuc;
735735
struct fcg_cgrp_ctx *cgc;
736736
struct cgroup *cgrp;
737-
u64 now = bpf_ktime_get_ns();
737+
u64 now = scx_bpf_now();
738738
bool picked_next = false;
739739

740740
cpuc = find_cpu_ctx();

0 commit comments

Comments
 (0)