Skip to content

Commit 086ed90

Browse files
arighihtejun
authored andcommitted
sched_ext: Make scx_locked_rq() inline
scx_locked_rq() is used both from ext.c and ext_idle.c, move it to ext.h as a static inline function. No functional changes. v2: Rename locked_rq to scx_locked_rq_state, expose it and make scx_locked_rq() inline, as suggested by Tejun. Signed-off-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent e212743 commit 086ed90

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

kernel/sched/ext.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ static void scx_kf_disallow(u32 mask)
12471247
* This allows kfuncs to safely operate on rq from any scx ops callback,
12481248
* knowing which rq is already locked.
12491249
*/
1250-
static DEFINE_PER_CPU(struct rq *, locked_rq);
1250+
DEFINE_PER_CPU(struct rq *, scx_locked_rq_state);
12511251

12521252
static inline void update_locked_rq(struct rq *rq)
12531253
{
@@ -1258,16 +1258,7 @@ static inline void update_locked_rq(struct rq *rq)
12581258
*/
12591259
if (rq)
12601260
lockdep_assert_rq_held(rq);
1261-
__this_cpu_write(locked_rq, rq);
1262-
}
1263-
1264-
/*
1265-
* Return the rq currently locked from an scx callback, or NULL if no rq is
1266-
* locked.
1267-
*/
1268-
static inline struct rq *scx_locked_rq(void)
1269-
{
1270-
return __this_cpu_read(locked_rq);
1261+
__this_cpu_write(scx_locked_rq_state, rq);
12711262
}
12721263

12731264
#define SCX_CALL_OP(sch, mask, op, rq, args...) \

kernel/sched/ext.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ static inline bool scx_rq_bypassing(struct rq *rq)
2020

2121
DECLARE_STATIC_KEY_FALSE(scx_ops_allow_queued_wakeup);
2222

23+
DECLARE_PER_CPU(struct rq *, scx_locked_rq_state);
24+
25+
/*
26+
* Return the rq currently locked from an scx callback, or NULL if no rq is
27+
* locked.
28+
*/
29+
static inline struct rq *scx_locked_rq(void)
30+
{
31+
return __this_cpu_read(scx_locked_rq_state);
32+
}
33+
2334
void scx_tick(struct rq *rq);
2435
void init_scx_entity(struct sched_ext_entity *scx);
2536
void scx_pre_fork(struct task_struct *p);

0 commit comments

Comments
 (0)