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

Commit

Permalink
Merge pull request #224 from sched-ext/htejun/misc
Browse files Browse the repository at this point in the history
scx: Cosmetic changes
  • Loading branch information
htejun authored Jun 15, 2024
2 parents 68981ae + 159d0cf commit 4da57a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 deletions.
40 changes: 16 additions & 24 deletions kernel/sched/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ static u32 higher_bits(u32 flags)
static u32 highest_bit(u32 flags)
{
int bit = fls(flags);
return ((u64) 1 << bit) >> 1;
return ((u64)1 << bit) >> 1;
}

/*
Expand Down Expand Up @@ -1820,8 +1820,8 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
goto local_norefill;

/*
* If !rq->online, we already told the BPF scheduler that the CPU is
* offline. We're just trying to on/offline the CPU. Don't bother the
* If !scx_rq_online(), we already told the BPF scheduler that the CPU
* is offline and are just running the hotplug path. Don't bother the
* BPF scheduler.
*/
if (!scx_rq_online(rq))
Expand Down Expand Up @@ -2402,7 +2402,8 @@ dispatch_to_local_dsq(struct rq *rq, struct rq_flags *rf, u64 dsq_id,
}

/* if the destination CPU is idle, wake it up */
if (dsp && p->sched_class < dst_rq->curr->sched_class)
if (dsp && sched_class_above(p->sched_class,
dst_rq->curr->sched_class))
resched_curr(dst_rq);

dispatch_to_local_dsq_unlock(rq, rf, src_rq, locked_dst_rq);
Expand Down Expand Up @@ -3218,24 +3219,24 @@ static void handle_hotplug(struct rq *rq, bool online)
online ? "online" : "offline");
}

static void rq_online_scx(struct rq *rq)
void scx_rq_activate(struct rq *rq)
{
rq->scx.flags |= SCX_RQ_ONLINE;
handle_hotplug(rq, true);
}

static void rq_offline_scx(struct rq *rq)
void scx_rq_deactivate(struct rq *rq)
{
rq->scx.flags &= ~SCX_RQ_ONLINE;
handle_hotplug(rq, false);
}

void scx_rq_activate(struct rq *rq)
static void rq_online_scx(struct rq *rq)
{
handle_hotplug(rq, true);
rq->scx.flags |= SCX_RQ_ONLINE;
}

void scx_rq_deactivate(struct rq *rq)
static void rq_offline_scx(struct rq *rq)
{
handle_hotplug(rq, false);
rq->scx.flags &= ~SCX_RQ_ONLINE;
}

#else /* CONFIG_SMP */
Expand Down Expand Up @@ -5183,8 +5184,7 @@ extern struct btf *btf_vmlinux;
static const struct btf_type *task_struct_type;
static u32 task_struct_type_id;

static bool promote_op_nth_arg(int arg_n, const char *op,
int off, int size,
static bool set_arg_maybe_null(const char *op, int arg_n, int off, int size,
enum bpf_access_type type,
const struct bpf_prog *prog,
struct bpf_insn_access_aux *info)
Expand Down Expand Up @@ -5242,23 +5242,15 @@ static bool promote_op_nth_arg(int arg_n, const char *op,
return false;
}

static bool promote_op_arg(int off, int size,
enum bpf_access_type type,
const struct bpf_prog *prog,
struct bpf_insn_access_aux *info)
{
return promote_op_nth_arg(1, "dispatch", off, size, type, prog, info) ||
promote_op_nth_arg(1, "yield", off, size, type, prog, info);
}

static bool bpf_scx_is_valid_access(int off, int size,
enum bpf_access_type type,
const struct bpf_prog *prog,
struct bpf_insn_access_aux *info)
{
if (type != BPF_READ)
return false;
if (promote_op_arg(off, size, type, prog, info))
if (set_arg_maybe_null("dispatch", 1, off, size, type, prog, info) ||
set_arg_maybe_null("yield", 1, off, size, type, prog, info))
return true;
if (off < 0 || off >= sizeof(__u64) * MAX_BPF_FUNC_ARGS)
return false;
Expand Down
14 changes: 7 additions & 7 deletions kernel/sched/ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ void scx_pre_fork(struct task_struct *p);
int scx_fork(struct task_struct *p);
void scx_post_fork(struct task_struct *p);
void scx_cancel_fork(struct task_struct *p);
int scx_check_setscheduler(struct task_struct *p, int policy);
bool scx_can_stop_tick(struct rq *rq);
bool task_should_scx(struct task_struct *p);
void init_sched_ext_class(void);
void scx_rq_activate(struct rq *rq);
void scx_rq_deactivate(struct rq *rq);
int scx_check_setscheduler(struct task_struct *p, int policy);
bool task_should_scx(struct task_struct *p);
void init_sched_ext_class(void);

static inline u32 scx_cpuperf_target(s32 cpu)
{
Expand Down Expand Up @@ -97,13 +97,13 @@ static inline void scx_pre_fork(struct task_struct *p) {}
static inline int scx_fork(struct task_struct *p) { return 0; }
static inline void scx_post_fork(struct task_struct *p) {}
static inline void scx_cancel_fork(struct task_struct *p) {}
static inline int scx_check_setscheduler(struct task_struct *p, int policy) { return 0; }
static inline bool scx_can_stop_tick(struct rq *rq) { return true; }
static inline bool task_on_scx(const struct task_struct *p) { return false; }
static inline void init_sched_ext_class(void) {}
static inline u32 scx_cpuperf_target(s32 cpu) { return 0; }
static inline bool scx_can_stop_tick(struct rq *rq) { return true; }
static inline void scx_rq_activate(struct rq *rq) {}
static inline void scx_rq_deactivate(struct rq *rq) {}
static inline int scx_check_setscheduler(struct task_struct *p, int policy) { return 0; }
static inline bool task_on_scx(const struct task_struct *p) { return false; }
static inline void init_sched_ext_class(void) {}

#define for_each_active_class for_each_class
#define for_balance_class_range for_class_range
Expand Down

0 comments on commit 4da57a5

Please sign in to comment.