Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
scx/compat.bpf.h: Replace __COMPAT_scx_bpf_kick_cpu_IDLE() with __COM…
Browse files Browse the repository at this point in the history
…PAT_SCX_KICK_IDLE

This is less clumsy and more in line with __COMPAT_SCX_OPS_SWITCH_PARTIAL.
  • Loading branch information
htejun committed Mar 6, 2024
1 parent 07d365a commit 89a6fab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions tools/sched_ext/include/scx/compat.bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
#ifndef __SCX_COMPAT_BPF_H
#define __SCX_COMPAT_BPF_H

/* SCX_KICK_IDLE is a later addition, use if available */
static inline void __COMPAT_scx_bpf_kick_cpu_IDLE(s32 cpu)
static inline u64 __COMPAT_SCX_KICK_IDLE(void)
{
if (bpf_core_enum_value_exists(enum scx_kick_flags, SCX_KICK_IDLE))
scx_bpf_kick_cpu(cpu, SCX_KICK_IDLE);
return SCX_KICK_IDLE;
else
scx_bpf_kick_cpu(cpu, 0);
return 0;
}

/*
* %SCX_KICK_IDLE is a later addition. To support both before and after, use
* %__COMPAT_SCX_KICK_IDLE which becomes 0 on kernels which don't support it.
*/
#define __COMPAT_SCX_KICK_IDLE __COMPAT_SCX_KICK_IDLE()

/*
* scx_switch_all() was replaced by %SCX_OPS_SWITCH_PARTIAL. See
* %__COMPAT_SCX_OPS_SWITCH_PARTIAL in compat.h.
Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/scx_central.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static bool dispatch_to_cpu(s32 cpu)
scx_bpf_dispatch(p, SCX_DSQ_LOCAL_ON | cpu, SCX_SLICE_INF, 0);

if (cpu != central_cpu)
__COMPAT_scx_bpf_kick_cpu_IDLE(cpu);
scx_bpf_kick_cpu(cpu, __COMPAT_SCX_KICK_IDLE);

bpf_task_release(p);
return true;
Expand Down
2 changes: 1 addition & 1 deletion tools/sched_ext/scx_qmap.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void BPF_STRUCT_OPS(qmap_enqueue, struct task_struct *p, u64 enq_flags)
scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, 0, enq_flags);
cpu = scx_bpf_pick_idle_cpu(p->cpus_ptr, 0);
if (cpu >= 0)
__COMPAT_scx_bpf_kick_cpu_IDLE(cpu);
scx_bpf_kick_cpu(cpu, __COMPAT_SCX_KICK_IDLE);
return;
}

Expand Down

0 comments on commit 89a6fab

Please sign in to comment.