* [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd
@ 2026-06-22 17:39 Tejun Heo
2026-06-22 17:39 ` [PATCH sched_ext/for-7.2 2/2] sched_ext: Move shared helpers from ext.c into internal.h and cid.h Tejun Heo
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Tejun Heo @ 2026-06-22 17:39 UTC (permalink / raw)
To: linux-kernel
Cc: Peter Zijlstra, Ingo Molnar, Juri Lelli, Vincent Guittot,
David Vernet, Andrea Righi, Changwoo Min, Emil Tsalapatis,
Linus Torvalds, sched-ext, Tejun Heo
The sources under kernel/sched/ext/ build as a single translation unit:
build_policy.c includes the source files and headers. An LSP/clangd editor
parses each as a standalone unit, sees no types, and reports a flood of
errors.
Give each header its dependencies and include guard, and have each source
include the headers it uses.
ext.c, arena.c and the ext headers now parse clean standalone. idle.c and
cid.c still reference a few macros and helpers defined in ext.c. The next
patch moves those to shared headers.
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/sched/ext/arena.c | 4 ++++
kernel/sched/ext/arena.h | 2 ++
kernel/sched/ext/cid.c | 3 +++
kernel/sched/ext/cid.h | 2 ++
kernel/sched/ext/ext.c | 12 ++++++++++++
kernel/sched/ext/idle.c | 3 +++
kernel/sched/ext/idle.h | 4 ++++
kernel/sched/ext/internal.h | 8 ++++++++
kernel/sched/ext/types.h | 6 ++++++
9 files changed, 44 insertions(+)
diff --git a/kernel/sched/ext/arena.c b/kernel/sched/ext/arena.c
index 493c2424f842..5783694ec21d 100644
--- a/kernel/sched/ext/arena.c
+++ b/kernel/sched/ext/arena.c
@@ -15,6 +15,10 @@
* Copyright (c) 2026 Meta Platforms, Inc. and affiliates.
* Copyright (c) 2026 Tejun Heo <tj@kernel.org>
*/
+#include <linux/genalloc.h>
+
+#include "internal.h"
+#include "arena.h"
enum scx_arena_consts {
SCX_ARENA_MIN_ORDER = 3, /* 8-byte minimum sub-allocation */
diff --git a/kernel/sched/ext/arena.h b/kernel/sched/ext/arena.h
index 4f3610160102..c378ae5fbc02 100644
--- a/kernel/sched/ext/arena.h
+++ b/kernel/sched/ext/arena.h
@@ -8,6 +8,8 @@
#ifndef _KERNEL_SCHED_EXT_ARENA_H
#define _KERNEL_SCHED_EXT_ARENA_H
+#include <linux/types.h>
+
struct scx_sched;
s32 scx_arena_pool_init(struct scx_sched *sch);
diff --git a/kernel/sched/ext/cid.c b/kernel/sched/ext/cid.c
index aeaea88f34c5..af83084ec740 100644
--- a/kernel/sched/ext/cid.c
+++ b/kernel/sched/ext/cid.c
@@ -7,6 +7,9 @@
*/
#include <linux/cacheinfo.h>
+#include "internal.h"
+#include "cid.h"
+
/*
* cid tables.
*
diff --git a/kernel/sched/ext/cid.h b/kernel/sched/ext/cid.h
index 6e657fd147b0..41d0802c6af3 100644
--- a/kernel/sched/ext/cid.h
+++ b/kernel/sched/ext/cid.h
@@ -33,6 +33,8 @@
#ifndef _KERNEL_SCHED_EXT_CID_H
#define _KERNEL_SCHED_EXT_CID_H
+#include "internal.h"
+
struct scx_sched;
/*
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 00fe6cc6d7e2..ebf6dc84cb4d 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -6,6 +6,18 @@
* Copyright (c) 2022 Tejun Heo <tj@kernel.org>
* Copyright (c) 2022 David Vernet <dvernet@meta.com>
*/
+#include <linux/bitmap.h>
+#include <linux/btf_ids.h>
+#include <linux/rhashtable.h>
+#include <linux/sched/isolation.h>
+#include <linux/suspend.h>
+#include <linux/sysrq.h>
+
+#include "../pelt.h"
+#include "internal.h"
+#include "cid.h"
+#include "arena.h"
+#include "idle.h"
static DEFINE_RAW_SPINLOCK(scx_sched_lock);
diff --git a/kernel/sched/ext/idle.c b/kernel/sched/ext/idle.c
index 2077373d8da3..8e8c6201b7df 100644
--- a/kernel/sched/ext/idle.c
+++ b/kernel/sched/ext/idle.c
@@ -9,6 +9,9 @@
* Copyright (c) 2022 David Vernet <dvernet@meta.com>
* Copyright (c) 2024 Andrea Righi <arighi@nvidia.com>
*/
+#include "internal.h"
+#include "cid.h"
+#include "idle.h"
/* Enable/disable built-in idle CPU selection policy */
static DEFINE_STATIC_KEY_FALSE(scx_builtin_idle_enabled);
diff --git a/kernel/sched/ext/idle.h b/kernel/sched/ext/idle.h
index 8d169d3bbdf9..f75699d22177 100644
--- a/kernel/sched/ext/idle.h
+++ b/kernel/sched/ext/idle.h
@@ -10,6 +10,10 @@
#ifndef _KERNEL_SCHED_EXT_IDLE_H
#define _KERNEL_SCHED_EXT_IDLE_H
+#include <linux/btf_ids.h>
+
+#include "../sched.h"
+
struct sched_ext_ops;
extern struct btf_id_set8 scx_kfunc_ids_idle;
diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
index b04701190b23..1f5312b3b387 100644
--- a/kernel/sched/ext/internal.h
+++ b/kernel/sched/ext/internal.h
@@ -5,6 +5,12 @@
* Copyright (c) 2025 Meta Platforms, Inc. and affiliates.
* Copyright (c) 2025 Tejun Heo <tj@kernel.org>
*/
+#ifndef _KERNEL_SCHED_EXT_INTERNAL_H
+#define _KERNEL_SCHED_EXT_INTERNAL_H
+
+#include "../sched.h"
+#include "types.h"
+
#define SCX_OP_IDX(op) (offsetof(struct sched_ext_ops, op) / sizeof(void (*)(void)))
#define SCX_MOFF_IDX(moff) ((moff) / sizeof(void (*)(void)))
@@ -1651,3 +1657,5 @@ static inline struct scx_sched *scx_prog_sched(const struct bpf_prog_aux *aux)
return rcu_dereference_all(scx_root);
}
#endif /* CONFIG_EXT_SUB_SCHED */
+
+#endif /* _KERNEL_SCHED_EXT_INTERNAL_H */
diff --git a/kernel/sched/ext/types.h b/kernel/sched/ext/types.h
index 8b3527e21fca..bc74eafd43f1 100644
--- a/kernel/sched/ext/types.h
+++ b/kernel/sched/ext/types.h
@@ -8,6 +8,12 @@
#ifndef _KERNEL_SCHED_EXT_TYPES_H
#define _KERNEL_SCHED_EXT_TYPES_H
+#include <linux/types.h>
+#include <linux/jiffies.h>
+#include <linux/overflow.h>
+#include <linux/time64.h>
+#include <linux/sched/topology.h>
+
enum scx_consts {
SCX_DSP_DFL_MAX_BATCH = 32,
SCX_DSP_MAX_LOOPS = 32,
--
2.54.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH sched_ext/for-7.2 2/2] sched_ext: Move shared helpers from ext.c into internal.h and cid.h
2026-06-22 17:39 [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd Tejun Heo
@ 2026-06-22 17:39 ` Tejun Heo
2026-06-22 18:45 ` Andrea Righi
2026-06-22 18:26 ` [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd Andrea Righi
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Tejun Heo @ 2026-06-22 17:39 UTC (permalink / raw)
To: linux-kernel
Cc: Peter Zijlstra, Ingo Molnar, Juri Lelli, Vincent Guittot,
David Vernet, Andrea Righi, Changwoo Min, Emil Tsalapatis,
Linus Torvalds, sched-ext, Tejun Heo
idle.c and cid.c are included into build_policy.c together with ext.c and
use helpers that ext.c defines. Because the helpers live in ext.c, the two
files can not parse as standalone units and clangd reports errors in them.
Move the helpers to the headers they belong to. The op-dispatch macros and
helpers plus scx_parent() to internal.h, and scx_cpu_arg()/scx_cpu_ret() to
cid.h. No functional change. idle.c and cid.c now parse clean standalone.
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/sched/ext/cid.h | 21 ++++++
kernel/sched/ext/ext.c | 141 ------------------------------------
kernel/sched/ext/internal.h | 121 +++++++++++++++++++++++++++++++
3 files changed, 142 insertions(+), 141 deletions(-)
diff --git a/kernel/sched/ext/cid.h b/kernel/sched/ext/cid.h
index 41d0802c6af3..9c4f4b907f12 100644
--- a/kernel/sched/ext/cid.h
+++ b/kernel/sched/ext/cid.h
@@ -270,4 +270,25 @@ static inline u32 scx_cmask_nr_used_words(const struct scx_cmask *m)
__w && ((cid) = __bs + __wi * 64 + __ffs64(__w), true); \
__w &= __w - 1)
+/*
+ * scx_cpu_arg() wraps a cpu arg being handed to an SCX op. For cid-form
+ * schedulers it resolves to the matching cid; for cpu-form it passes @cpu
+ * through. scx_cpu_ret() is the inverse for a cpu/cid returned from an op
+ * (currently only ops.select_cpu); it validates the BPF-supplied cid and
+ * triggers scx_error() on @sch if invalid.
+ */
+static inline s32 scx_cpu_arg(s32 cpu)
+{
+ if (scx_is_cid_type())
+ return __scx_cpu_to_cid(cpu);
+ return cpu;
+}
+
+static inline s32 scx_cpu_ret(struct scx_sched *sch, s32 cpu_or_cid)
+{
+ if (cpu_or_cid < 0 || !scx_is_cid_type())
+ return cpu_or_cid;
+ return scx_cid_to_cpu(sch, cpu_or_cid);
+}
+
#endif /* _KERNEL_SCHED_EXT_CID_H */
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index ebf6dc84cb4d..dd41b84ae680 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -258,8 +258,6 @@ __printf(5, 6) bool __scx_exit(struct scx_sched *sch,
return ret;
}
-#define SCX_HAS_OP(sch, op) test_bit(SCX_OP_IDX(op), (sch)->has_op)
-
static long jiffies_delta_msecs(unsigned long at, unsigned long now)
{
if (time_after(at, now))
@@ -274,20 +272,6 @@ static bool u32_before(u32 a, u32 b)
}
#ifdef CONFIG_EXT_SUB_SCHED
-/**
- * scx_parent - Find the parent sched
- * @sch: sched to find the parent of
- *
- * Returns the parent scheduler or %NULL if @sch is root.
- */
-static struct scx_sched *scx_parent(struct scx_sched *sch)
-{
- if (sch->level)
- return sch->ancestors[sch->level - 1];
- else
- return NULL;
-}
-
/**
* scx_next_descendant_pre - find the next descendant for pre-order walk
* @pos: the current position (%NULL to initiate traversal)
@@ -335,7 +319,6 @@ static void scx_set_task_sched(struct task_struct *p, struct scx_sched *sch)
rcu_assign_pointer(p->scx.sched, sch);
}
#else /* CONFIG_EXT_SUB_SCHED */
-static inline struct scx_sched *scx_parent(struct scx_sched *sch) { return NULL; }
static inline struct scx_sched *scx_next_descendant_pre(struct scx_sched *pos, struct scx_sched *root) { return pos ? NULL : root; }
static inline void scx_set_task_sched(struct task_struct *p, struct scx_sched *sch) {}
#endif /* CONFIG_EXT_SUB_SCHED */
@@ -495,123 +478,12 @@ static bool rq_is_open(struct rq *rq, u64 enq_flags)
*/
DEFINE_PER_CPU(struct rq *, scx_locked_rq_state);
-static inline void update_locked_rq(struct rq *rq)
-{
- /*
- * Check whether @rq is actually locked. This can help expose bugs
- * or incorrect assumptions about the context in which a kfunc or
- * callback is executed.
- */
- if (rq)
- lockdep_assert_rq_held(rq);
- __this_cpu_write(scx_locked_rq_state, rq);
-}
-
-/*
- * SCX ops can recurse via scx_bpf_sub_dispatch() - the inner call must not
- * clobber the outer's scx_locked_rq_state. Save it on entry, restore on exit.
- */
-#define SCX_CALL_OP(sch, op, locked_rq, args...) \
-do { \
- struct rq *__prev_locked_rq; \
- \
- if (locked_rq) { \
- __prev_locked_rq = scx_locked_rq(); \
- update_locked_rq(locked_rq); \
- } \
- (sch)->ops.op(args); \
- if (locked_rq) \
- update_locked_rq(__prev_locked_rq); \
-} while (0)
-
/*
* Flipped on enable per sch->is_cid_type. Declared in internal.h so
* subsystem inlines can read it.
*/
DEFINE_STATIC_KEY_FALSE(__scx_is_cid_type);
-/*
- * scx_cpu_arg() wraps a cpu arg being handed to an SCX op. For cid-form
- * schedulers it resolves to the matching cid; for cpu-form it passes @cpu
- * through. scx_cpu_ret() is the inverse for a cpu/cid returned from an op
- * (currently only ops.select_cpu); it validates the BPF-supplied cid and
- * triggers scx_error() on @sch if invalid.
- */
-static s32 scx_cpu_arg(s32 cpu)
-{
- if (scx_is_cid_type())
- return __scx_cpu_to_cid(cpu);
- return cpu;
-}
-
-static s32 scx_cpu_ret(struct scx_sched *sch, s32 cpu_or_cid)
-{
- if (cpu_or_cid < 0 || !scx_is_cid_type())
- return cpu_or_cid;
- return scx_cid_to_cpu(sch, cpu_or_cid);
-}
-
-#define SCX_CALL_OP_RET(sch, op, locked_rq, args...) \
-({ \
- struct rq *__prev_locked_rq; \
- __typeof__((sch)->ops.op(args)) __ret; \
- \
- if (locked_rq) { \
- __prev_locked_rq = scx_locked_rq(); \
- update_locked_rq(locked_rq); \
- } \
- __ret = (sch)->ops.op(args); \
- if (locked_rq) \
- update_locked_rq(__prev_locked_rq); \
- __ret; \
-})
-
-/*
- * SCX_CALL_OP_TASK*() invokes an SCX op that takes one or two task arguments
- * and records them in current->scx.kf_tasks[] for the duration of the call. A
- * kfunc invoked from inside such an op can then use
- * scx_kf_arg_task_ok() to verify that its task argument is one of
- * those subject tasks.
- *
- * Every SCX_CALL_OP_TASK*() call site invokes its op with @p's rq lock held -
- * either via the @locked_rq argument here, or (for ops.select_cpu()) via @p's
- * pi_lock held by try_to_wake_up() with rq tracking via scx_rq.in_select_cpu.
- * So if kf_tasks[] is set, @p's scheduler-protected fields are stable.
- *
- * kf_tasks[] can not stack, so task-based SCX ops must not nest. The
- * WARN_ON_ONCE() in each macro catches a re-entry of any of the three variants
- * while a previous one is still in progress.
- */
-#define SCX_CALL_OP_TASK(sch, op, locked_rq, task, args...) \
-do { \
- WARN_ON_ONCE(current->scx.kf_tasks[0]); \
- current->scx.kf_tasks[0] = task; \
- SCX_CALL_OP((sch), op, locked_rq, task, ##args); \
- current->scx.kf_tasks[0] = NULL; \
-} while (0)
-
-#define SCX_CALL_OP_TASK_RET(sch, op, locked_rq, task, args...) \
-({ \
- __typeof__((sch)->ops.op(task, ##args)) __ret; \
- WARN_ON_ONCE(current->scx.kf_tasks[0]); \
- current->scx.kf_tasks[0] = task; \
- __ret = SCX_CALL_OP_RET((sch), op, locked_rq, task, ##args); \
- current->scx.kf_tasks[0] = NULL; \
- __ret; \
-})
-
-#define SCX_CALL_OP_2TASKS_RET(sch, op, locked_rq, task0, task1, args...) \
-({ \
- __typeof__((sch)->ops.op(task0, task1, ##args)) __ret; \
- WARN_ON_ONCE(current->scx.kf_tasks[0]); \
- current->scx.kf_tasks[0] = task0; \
- current->scx.kf_tasks[1] = task1; \
- __ret = SCX_CALL_OP_RET((sch), op, locked_rq, task0, task1, ##args); \
- current->scx.kf_tasks[0] = NULL; \
- current->scx.kf_tasks[1] = NULL; \
- __ret; \
-})
-
/**
* scx_call_op_set_cpumask - invoke ops.set_cpumask / ops_cid.set_cmask for @task
* @sch: scx_sched being invoked
@@ -650,19 +522,6 @@ static inline void scx_call_op_set_cpumask(struct scx_sched *sch, struct rq *rq,
current->scx.kf_tasks[0] = NULL;
}
-/* see SCX_CALL_OP_TASK() */
-static __always_inline bool scx_kf_arg_task_ok(struct scx_sched *sch,
- struct task_struct *p)
-{
- if (unlikely((p != current->scx.kf_tasks[0] &&
- p != current->scx.kf_tasks[1]))) {
- scx_error(sch, "called on a task not being operated on");
- return false;
- }
-
- return true;
-}
-
enum scx_dsq_iter_flags {
/* iterate in the reverse dispatch order */
SCX_DSQ_ITER_REV = 1U << 16,
diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
index 1f5312b3b387..145272cb4d8a 100644
--- a/kernel/sched/ext/internal.h
+++ b/kernel/sched/ext/internal.h
@@ -1553,6 +1553,111 @@ static inline struct rq *scx_locked_rq(void)
return __this_cpu_read(scx_locked_rq_state);
}
+static inline void update_locked_rq(struct rq *rq)
+{
+ /*
+ * Check whether @rq is actually locked. This can help expose bugs
+ * or incorrect assumptions about the context in which a kfunc or
+ * callback is executed.
+ */
+ if (rq)
+ lockdep_assert_rq_held(rq);
+ __this_cpu_write(scx_locked_rq_state, rq);
+}
+
+#define SCX_HAS_OP(sch, op) test_bit(SCX_OP_IDX(op), (sch)->has_op)
+
+/*
+ * SCX ops can recurse via scx_bpf_sub_dispatch() - the inner call must not
+ * clobber the outer's scx_locked_rq_state. Save it on entry, restore on exit.
+ */
+#define SCX_CALL_OP(sch, op, locked_rq, args...) \
+do { \
+ struct rq *__prev_locked_rq; \
+ \
+ if (locked_rq) { \
+ __prev_locked_rq = scx_locked_rq(); \
+ update_locked_rq(locked_rq); \
+ } \
+ (sch)->ops.op(args); \
+ if (locked_rq) \
+ update_locked_rq(__prev_locked_rq); \
+} while (0)
+
+#define SCX_CALL_OP_RET(sch, op, locked_rq, args...) \
+({ \
+ struct rq *__prev_locked_rq; \
+ __typeof__((sch)->ops.op(args)) __ret; \
+ \
+ if (locked_rq) { \
+ __prev_locked_rq = scx_locked_rq(); \
+ update_locked_rq(locked_rq); \
+ } \
+ __ret = (sch)->ops.op(args); \
+ if (locked_rq) \
+ update_locked_rq(__prev_locked_rq); \
+ __ret; \
+})
+
+/*
+ * SCX_CALL_OP_TASK*() invokes an SCX op that takes one or two task arguments
+ * and records them in current->scx.kf_tasks[] for the duration of the call. A
+ * kfunc invoked from inside such an op can then use
+ * scx_kf_arg_task_ok() to verify that its task argument is one of
+ * those subject tasks.
+ *
+ * Every SCX_CALL_OP_TASK*() call site invokes its op with @p's rq lock held -
+ * either via the @locked_rq argument here, or (for ops.select_cpu()) via @p's
+ * pi_lock held by try_to_wake_up() with rq tracking via scx_rq.in_select_cpu.
+ * So if kf_tasks[] is set, @p's scheduler-protected fields are stable.
+ *
+ * kf_tasks[] can not stack, so task-based SCX ops must not nest. The
+ * WARN_ON_ONCE() in each macro catches a re-entry of any of the three variants
+ * while a previous one is still in progress.
+ */
+#define SCX_CALL_OP_TASK(sch, op, locked_rq, task, args...) \
+do { \
+ WARN_ON_ONCE(current->scx.kf_tasks[0]); \
+ current->scx.kf_tasks[0] = task; \
+ SCX_CALL_OP((sch), op, locked_rq, task, ##args); \
+ current->scx.kf_tasks[0] = NULL; \
+} while (0)
+
+#define SCX_CALL_OP_TASK_RET(sch, op, locked_rq, task, args...) \
+({ \
+ __typeof__((sch)->ops.op(task, ##args)) __ret; \
+ WARN_ON_ONCE(current->scx.kf_tasks[0]); \
+ current->scx.kf_tasks[0] = task; \
+ __ret = SCX_CALL_OP_RET((sch), op, locked_rq, task, ##args); \
+ current->scx.kf_tasks[0] = NULL; \
+ __ret; \
+})
+
+#define SCX_CALL_OP_2TASKS_RET(sch, op, locked_rq, task0, task1, args...) \
+({ \
+ __typeof__((sch)->ops.op(task0, task1, ##args)) __ret; \
+ WARN_ON_ONCE(current->scx.kf_tasks[0]); \
+ current->scx.kf_tasks[0] = task0; \
+ current->scx.kf_tasks[1] = task1; \
+ __ret = SCX_CALL_OP_RET((sch), op, locked_rq, task0, task1, ##args); \
+ current->scx.kf_tasks[0] = NULL; \
+ current->scx.kf_tasks[1] = NULL; \
+ __ret; \
+})
+
+/* see SCX_CALL_OP_TASK() */
+static __always_inline bool scx_kf_arg_task_ok(struct scx_sched *sch,
+ struct task_struct *p)
+{
+ if (unlikely((p != current->scx.kf_tasks[0] &&
+ p != current->scx.kf_tasks[1]))) {
+ scx_error(sch, "called on a task not being operated on");
+ return false;
+ }
+
+ return true;
+}
+
static inline bool scx_bypassing(struct scx_sched *sch, s32 cpu)
{
return unlikely(per_cpu_ptr(sch->pcpu, cpu)->flags &
@@ -1633,6 +1738,20 @@ static inline struct scx_sched *scx_prog_sched(const struct bpf_prog_aux *aux)
return NULL;
}
+
+/**
+ * scx_parent - Find the parent sched
+ * @sch: sched to find the parent of
+ *
+ * Returns the parent scheduler or %NULL if @sch is root.
+ */
+static inline struct scx_sched *scx_parent(struct scx_sched *sch)
+{
+ if (sch->level)
+ return sch->ancestors[sch->level - 1];
+ else
+ return NULL;
+}
#else /* CONFIG_EXT_SUB_SCHED */
static inline struct scx_sched *scx_task_sched(const struct task_struct *p)
{
@@ -1656,6 +1775,8 @@ static inline struct scx_sched *scx_prog_sched(const struct bpf_prog_aux *aux)
{
return rcu_dereference_all(scx_root);
}
+
+static inline struct scx_sched *scx_parent(struct scx_sched *sch) { return NULL; }
#endif /* CONFIG_EXT_SUB_SCHED */
#endif /* _KERNEL_SCHED_EXT_INTERNAL_H */
--
2.54.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd
2026-06-22 17:39 [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd Tejun Heo
2026-06-22 17:39 ` [PATCH sched_ext/for-7.2 2/2] sched_ext: Move shared helpers from ext.c into internal.h and cid.h Tejun Heo
@ 2026-06-22 18:26 ` Andrea Righi
2026-06-22 20:37 ` [PATCH v2 " Tejun Heo
2026-06-22 21:05 ` [PATCH " Tejun Heo
3 siblings, 0 replies; 6+ messages in thread
From: Andrea Righi @ 2026-06-22 18:26 UTC (permalink / raw)
To: Tejun Heo
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, Juri Lelli,
Vincent Guittot, David Vernet, Changwoo Min, Emil Tsalapatis,
Linus Torvalds, sched-ext
Hi Tejun,
On Mon, Jun 22, 2026 at 07:39:03AM -1000, Tejun Heo wrote:
> The sources under kernel/sched/ext/ build as a single translation unit:
> build_policy.c includes the source files and headers. An LSP/clangd editor
> parses each as a standalone unit, sees no types, and reports a flood of
> errors.
>
> Give each header its dependencies and include guard, and have each source
> include the headers it uses.
>
> ext.c, arena.c and the ext headers now parse clean standalone. idle.c and
> cid.c still reference a few macros and helpers defined in ext.c. The next
> patch moves those to shared headers.
>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---
...
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 00fe6cc6d7e2..ebf6dc84cb4d 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -6,6 +6,18 @@
> * Copyright (c) 2022 Tejun Heo <tj@kernel.org>
> * Copyright (c) 2022 David Vernet <dvernet@meta.com>
> */
> +#include <linux/bitmap.h>
> +#include <linux/btf_ids.h>
> +#include <linux/rhashtable.h>
> +#include <linux/sched/isolation.h>
> +#include <linux/suspend.h>
> +#include <linux/sysrq.h>
I'm getting the following errors here:
kernel/sched/ext/ext.c|1296 col 26-41 error| Call to undeclared function 'sched_clock_cpu'; ISO C99 and later do not support implicit function declarations (fix available)
kernel/sched/ext/ext.c|7772 col 10-11 error| In included file: conflicting types for 'sched_clock_cpu'
They can be fixed adding:
#include <linux/sched/clock.h>
> +
> +#include "../pelt.h"
> +#include "internal.h"
> +#include "cid.h"
> +#include "arena.h"
> +#include "idle.h"
>
> static DEFINE_RAW_SPINLOCK(scx_sched_lock);
>
> diff --git a/kernel/sched/ext/idle.c b/kernel/sched/ext/idle.c
> index 2077373d8da3..8e8c6201b7df 100644
> --- a/kernel/sched/ext/idle.c
> +++ b/kernel/sched/ext/idle.c
> @@ -9,6 +9,9 @@
> * Copyright (c) 2022 David Vernet <dvernet@meta.com>
> * Copyright (c) 2024 Andrea Righi <arighi@nvidia.com>
> */
> +#include "internal.h"
> +#include "cid.h"
> +#include "idle.h"
>
> /* Enable/disable built-in idle CPU selection policy */
> static DEFINE_STATIC_KEY_FALSE(scx_builtin_idle_enabled);
> diff --git a/kernel/sched/ext/idle.h b/kernel/sched/ext/idle.h
> index 8d169d3bbdf9..f75699d22177 100644
> --- a/kernel/sched/ext/idle.h
> +++ b/kernel/sched/ext/idle.h
> @@ -10,6 +10,10 @@
> #ifndef _KERNEL_SCHED_EXT_IDLE_H
> #define _KERNEL_SCHED_EXT_IDLE_H
>
> +#include <linux/btf_ids.h>
> +
> +#include "../sched.h"
And here I'm getting a warning, I've fixed it adding the following forward
declarations instead of including sched.h:
struct cpumask;
struct task_struct;
> +
> struct sched_ext_ops;
>
> extern struct btf_id_set8 scx_kfunc_ids_idle;
With these two additional changes, everything looks good to me.
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Thanks,
-Andrea
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH sched_ext/for-7.2 2/2] sched_ext: Move shared helpers from ext.c into internal.h and cid.h
2026-06-22 17:39 ` [PATCH sched_ext/for-7.2 2/2] sched_ext: Move shared helpers from ext.c into internal.h and cid.h Tejun Heo
@ 2026-06-22 18:45 ` Andrea Righi
0 siblings, 0 replies; 6+ messages in thread
From: Andrea Righi @ 2026-06-22 18:45 UTC (permalink / raw)
To: Tejun Heo
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, Juri Lelli,
Vincent Guittot, David Vernet, Changwoo Min, Emil Tsalapatis,
Linus Torvalds, sched-ext
Hi Tejun,
On Mon, Jun 22, 2026 at 07:39:04AM -1000, Tejun Heo wrote:
> idle.c and cid.c are included into build_policy.c together with ext.c and
> use helpers that ext.c defines. Because the helpers live in ext.c, the two
> files can not parse as standalone units and clangd reports errors in them.
>
> Move the helpers to the headers they belong to. The op-dispatch macros and
> helpers plus scx_parent() to internal.h, and scx_cpu_arg()/scx_cpu_ret() to
> cid.h. No functional change. idle.c and cid.c now parse clean standalone.
>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---
Looks good to me.
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Thanks,
-Andrea
> kernel/sched/ext/cid.h | 21 ++++++
> kernel/sched/ext/ext.c | 141 ------------------------------------
> kernel/sched/ext/internal.h | 121 +++++++++++++++++++++++++++++++
> 3 files changed, 142 insertions(+), 141 deletions(-)
>
> diff --git a/kernel/sched/ext/cid.h b/kernel/sched/ext/cid.h
> index 41d0802c6af3..9c4f4b907f12 100644
> --- a/kernel/sched/ext/cid.h
> +++ b/kernel/sched/ext/cid.h
> @@ -270,4 +270,25 @@ static inline u32 scx_cmask_nr_used_words(const struct scx_cmask *m)
> __w && ((cid) = __bs + __wi * 64 + __ffs64(__w), true); \
> __w &= __w - 1)
>
> +/*
> + * scx_cpu_arg() wraps a cpu arg being handed to an SCX op. For cid-form
> + * schedulers it resolves to the matching cid; for cpu-form it passes @cpu
> + * through. scx_cpu_ret() is the inverse for a cpu/cid returned from an op
> + * (currently only ops.select_cpu); it validates the BPF-supplied cid and
> + * triggers scx_error() on @sch if invalid.
> + */
> +static inline s32 scx_cpu_arg(s32 cpu)
> +{
> + if (scx_is_cid_type())
> + return __scx_cpu_to_cid(cpu);
> + return cpu;
> +}
> +
> +static inline s32 scx_cpu_ret(struct scx_sched *sch, s32 cpu_or_cid)
> +{
> + if (cpu_or_cid < 0 || !scx_is_cid_type())
> + return cpu_or_cid;
> + return scx_cid_to_cpu(sch, cpu_or_cid);
> +}
> +
> #endif /* _KERNEL_SCHED_EXT_CID_H */
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index ebf6dc84cb4d..dd41b84ae680 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -258,8 +258,6 @@ __printf(5, 6) bool __scx_exit(struct scx_sched *sch,
> return ret;
> }
>
> -#define SCX_HAS_OP(sch, op) test_bit(SCX_OP_IDX(op), (sch)->has_op)
> -
> static long jiffies_delta_msecs(unsigned long at, unsigned long now)
> {
> if (time_after(at, now))
> @@ -274,20 +272,6 @@ static bool u32_before(u32 a, u32 b)
> }
>
> #ifdef CONFIG_EXT_SUB_SCHED
> -/**
> - * scx_parent - Find the parent sched
> - * @sch: sched to find the parent of
> - *
> - * Returns the parent scheduler or %NULL if @sch is root.
> - */
> -static struct scx_sched *scx_parent(struct scx_sched *sch)
> -{
> - if (sch->level)
> - return sch->ancestors[sch->level - 1];
> - else
> - return NULL;
> -}
> -
> /**
> * scx_next_descendant_pre - find the next descendant for pre-order walk
> * @pos: the current position (%NULL to initiate traversal)
> @@ -335,7 +319,6 @@ static void scx_set_task_sched(struct task_struct *p, struct scx_sched *sch)
> rcu_assign_pointer(p->scx.sched, sch);
> }
> #else /* CONFIG_EXT_SUB_SCHED */
> -static inline struct scx_sched *scx_parent(struct scx_sched *sch) { return NULL; }
> static inline struct scx_sched *scx_next_descendant_pre(struct scx_sched *pos, struct scx_sched *root) { return pos ? NULL : root; }
> static inline void scx_set_task_sched(struct task_struct *p, struct scx_sched *sch) {}
> #endif /* CONFIG_EXT_SUB_SCHED */
> @@ -495,123 +478,12 @@ static bool rq_is_open(struct rq *rq, u64 enq_flags)
> */
> DEFINE_PER_CPU(struct rq *, scx_locked_rq_state);
>
> -static inline void update_locked_rq(struct rq *rq)
> -{
> - /*
> - * Check whether @rq is actually locked. This can help expose bugs
> - * or incorrect assumptions about the context in which a kfunc or
> - * callback is executed.
> - */
> - if (rq)
> - lockdep_assert_rq_held(rq);
> - __this_cpu_write(scx_locked_rq_state, rq);
> -}
> -
> -/*
> - * SCX ops can recurse via scx_bpf_sub_dispatch() - the inner call must not
> - * clobber the outer's scx_locked_rq_state. Save it on entry, restore on exit.
> - */
> -#define SCX_CALL_OP(sch, op, locked_rq, args...) \
> -do { \
> - struct rq *__prev_locked_rq; \
> - \
> - if (locked_rq) { \
> - __prev_locked_rq = scx_locked_rq(); \
> - update_locked_rq(locked_rq); \
> - } \
> - (sch)->ops.op(args); \
> - if (locked_rq) \
> - update_locked_rq(__prev_locked_rq); \
> -} while (0)
> -
> /*
> * Flipped on enable per sch->is_cid_type. Declared in internal.h so
> * subsystem inlines can read it.
> */
> DEFINE_STATIC_KEY_FALSE(__scx_is_cid_type);
>
> -/*
> - * scx_cpu_arg() wraps a cpu arg being handed to an SCX op. For cid-form
> - * schedulers it resolves to the matching cid; for cpu-form it passes @cpu
> - * through. scx_cpu_ret() is the inverse for a cpu/cid returned from an op
> - * (currently only ops.select_cpu); it validates the BPF-supplied cid and
> - * triggers scx_error() on @sch if invalid.
> - */
> -static s32 scx_cpu_arg(s32 cpu)
> -{
> - if (scx_is_cid_type())
> - return __scx_cpu_to_cid(cpu);
> - return cpu;
> -}
> -
> -static s32 scx_cpu_ret(struct scx_sched *sch, s32 cpu_or_cid)
> -{
> - if (cpu_or_cid < 0 || !scx_is_cid_type())
> - return cpu_or_cid;
> - return scx_cid_to_cpu(sch, cpu_or_cid);
> -}
> -
> -#define SCX_CALL_OP_RET(sch, op, locked_rq, args...) \
> -({ \
> - struct rq *__prev_locked_rq; \
> - __typeof__((sch)->ops.op(args)) __ret; \
> - \
> - if (locked_rq) { \
> - __prev_locked_rq = scx_locked_rq(); \
> - update_locked_rq(locked_rq); \
> - } \
> - __ret = (sch)->ops.op(args); \
> - if (locked_rq) \
> - update_locked_rq(__prev_locked_rq); \
> - __ret; \
> -})
> -
> -/*
> - * SCX_CALL_OP_TASK*() invokes an SCX op that takes one or two task arguments
> - * and records them in current->scx.kf_tasks[] for the duration of the call. A
> - * kfunc invoked from inside such an op can then use
> - * scx_kf_arg_task_ok() to verify that its task argument is one of
> - * those subject tasks.
> - *
> - * Every SCX_CALL_OP_TASK*() call site invokes its op with @p's rq lock held -
> - * either via the @locked_rq argument here, or (for ops.select_cpu()) via @p's
> - * pi_lock held by try_to_wake_up() with rq tracking via scx_rq.in_select_cpu.
> - * So if kf_tasks[] is set, @p's scheduler-protected fields are stable.
> - *
> - * kf_tasks[] can not stack, so task-based SCX ops must not nest. The
> - * WARN_ON_ONCE() in each macro catches a re-entry of any of the three variants
> - * while a previous one is still in progress.
> - */
> -#define SCX_CALL_OP_TASK(sch, op, locked_rq, task, args...) \
> -do { \
> - WARN_ON_ONCE(current->scx.kf_tasks[0]); \
> - current->scx.kf_tasks[0] = task; \
> - SCX_CALL_OP((sch), op, locked_rq, task, ##args); \
> - current->scx.kf_tasks[0] = NULL; \
> -} while (0)
> -
> -#define SCX_CALL_OP_TASK_RET(sch, op, locked_rq, task, args...) \
> -({ \
> - __typeof__((sch)->ops.op(task, ##args)) __ret; \
> - WARN_ON_ONCE(current->scx.kf_tasks[0]); \
> - current->scx.kf_tasks[0] = task; \
> - __ret = SCX_CALL_OP_RET((sch), op, locked_rq, task, ##args); \
> - current->scx.kf_tasks[0] = NULL; \
> - __ret; \
> -})
> -
> -#define SCX_CALL_OP_2TASKS_RET(sch, op, locked_rq, task0, task1, args...) \
> -({ \
> - __typeof__((sch)->ops.op(task0, task1, ##args)) __ret; \
> - WARN_ON_ONCE(current->scx.kf_tasks[0]); \
> - current->scx.kf_tasks[0] = task0; \
> - current->scx.kf_tasks[1] = task1; \
> - __ret = SCX_CALL_OP_RET((sch), op, locked_rq, task0, task1, ##args); \
> - current->scx.kf_tasks[0] = NULL; \
> - current->scx.kf_tasks[1] = NULL; \
> - __ret; \
> -})
> -
> /**
> * scx_call_op_set_cpumask - invoke ops.set_cpumask / ops_cid.set_cmask for @task
> * @sch: scx_sched being invoked
> @@ -650,19 +522,6 @@ static inline void scx_call_op_set_cpumask(struct scx_sched *sch, struct rq *rq,
> current->scx.kf_tasks[0] = NULL;
> }
>
> -/* see SCX_CALL_OP_TASK() */
> -static __always_inline bool scx_kf_arg_task_ok(struct scx_sched *sch,
> - struct task_struct *p)
> -{
> - if (unlikely((p != current->scx.kf_tasks[0] &&
> - p != current->scx.kf_tasks[1]))) {
> - scx_error(sch, "called on a task not being operated on");
> - return false;
> - }
> -
> - return true;
> -}
> -
> enum scx_dsq_iter_flags {
> /* iterate in the reverse dispatch order */
> SCX_DSQ_ITER_REV = 1U << 16,
> diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
> index 1f5312b3b387..145272cb4d8a 100644
> --- a/kernel/sched/ext/internal.h
> +++ b/kernel/sched/ext/internal.h
> @@ -1553,6 +1553,111 @@ static inline struct rq *scx_locked_rq(void)
> return __this_cpu_read(scx_locked_rq_state);
> }
>
> +static inline void update_locked_rq(struct rq *rq)
> +{
> + /*
> + * Check whether @rq is actually locked. This can help expose bugs
> + * or incorrect assumptions about the context in which a kfunc or
> + * callback is executed.
> + */
> + if (rq)
> + lockdep_assert_rq_held(rq);
> + __this_cpu_write(scx_locked_rq_state, rq);
> +}
> +
> +#define SCX_HAS_OP(sch, op) test_bit(SCX_OP_IDX(op), (sch)->has_op)
> +
> +/*
> + * SCX ops can recurse via scx_bpf_sub_dispatch() - the inner call must not
> + * clobber the outer's scx_locked_rq_state. Save it on entry, restore on exit.
> + */
> +#define SCX_CALL_OP(sch, op, locked_rq, args...) \
> +do { \
> + struct rq *__prev_locked_rq; \
> + \
> + if (locked_rq) { \
> + __prev_locked_rq = scx_locked_rq(); \
> + update_locked_rq(locked_rq); \
> + } \
> + (sch)->ops.op(args); \
> + if (locked_rq) \
> + update_locked_rq(__prev_locked_rq); \
> +} while (0)
> +
> +#define SCX_CALL_OP_RET(sch, op, locked_rq, args...) \
> +({ \
> + struct rq *__prev_locked_rq; \
> + __typeof__((sch)->ops.op(args)) __ret; \
> + \
> + if (locked_rq) { \
> + __prev_locked_rq = scx_locked_rq(); \
> + update_locked_rq(locked_rq); \
> + } \
> + __ret = (sch)->ops.op(args); \
> + if (locked_rq) \
> + update_locked_rq(__prev_locked_rq); \
> + __ret; \
> +})
> +
> +/*
> + * SCX_CALL_OP_TASK*() invokes an SCX op that takes one or two task arguments
> + * and records them in current->scx.kf_tasks[] for the duration of the call. A
> + * kfunc invoked from inside such an op can then use
> + * scx_kf_arg_task_ok() to verify that its task argument is one of
> + * those subject tasks.
> + *
> + * Every SCX_CALL_OP_TASK*() call site invokes its op with @p's rq lock held -
> + * either via the @locked_rq argument here, or (for ops.select_cpu()) via @p's
> + * pi_lock held by try_to_wake_up() with rq tracking via scx_rq.in_select_cpu.
> + * So if kf_tasks[] is set, @p's scheduler-protected fields are stable.
> + *
> + * kf_tasks[] can not stack, so task-based SCX ops must not nest. The
> + * WARN_ON_ONCE() in each macro catches a re-entry of any of the three variants
> + * while a previous one is still in progress.
> + */
> +#define SCX_CALL_OP_TASK(sch, op, locked_rq, task, args...) \
> +do { \
> + WARN_ON_ONCE(current->scx.kf_tasks[0]); \
> + current->scx.kf_tasks[0] = task; \
> + SCX_CALL_OP((sch), op, locked_rq, task, ##args); \
> + current->scx.kf_tasks[0] = NULL; \
> +} while (0)
> +
> +#define SCX_CALL_OP_TASK_RET(sch, op, locked_rq, task, args...) \
> +({ \
> + __typeof__((sch)->ops.op(task, ##args)) __ret; \
> + WARN_ON_ONCE(current->scx.kf_tasks[0]); \
> + current->scx.kf_tasks[0] = task; \
> + __ret = SCX_CALL_OP_RET((sch), op, locked_rq, task, ##args); \
> + current->scx.kf_tasks[0] = NULL; \
> + __ret; \
> +})
> +
> +#define SCX_CALL_OP_2TASKS_RET(sch, op, locked_rq, task0, task1, args...) \
> +({ \
> + __typeof__((sch)->ops.op(task0, task1, ##args)) __ret; \
> + WARN_ON_ONCE(current->scx.kf_tasks[0]); \
> + current->scx.kf_tasks[0] = task0; \
> + current->scx.kf_tasks[1] = task1; \
> + __ret = SCX_CALL_OP_RET((sch), op, locked_rq, task0, task1, ##args); \
> + current->scx.kf_tasks[0] = NULL; \
> + current->scx.kf_tasks[1] = NULL; \
> + __ret; \
> +})
> +
> +/* see SCX_CALL_OP_TASK() */
> +static __always_inline bool scx_kf_arg_task_ok(struct scx_sched *sch,
> + struct task_struct *p)
> +{
> + if (unlikely((p != current->scx.kf_tasks[0] &&
> + p != current->scx.kf_tasks[1]))) {
> + scx_error(sch, "called on a task not being operated on");
> + return false;
> + }
> +
> + return true;
> +}
> +
> static inline bool scx_bypassing(struct scx_sched *sch, s32 cpu)
> {
> return unlikely(per_cpu_ptr(sch->pcpu, cpu)->flags &
> @@ -1633,6 +1738,20 @@ static inline struct scx_sched *scx_prog_sched(const struct bpf_prog_aux *aux)
>
> return NULL;
> }
> +
> +/**
> + * scx_parent - Find the parent sched
> + * @sch: sched to find the parent of
> + *
> + * Returns the parent scheduler or %NULL if @sch is root.
> + */
> +static inline struct scx_sched *scx_parent(struct scx_sched *sch)
> +{
> + if (sch->level)
> + return sch->ancestors[sch->level - 1];
> + else
> + return NULL;
> +}
> #else /* CONFIG_EXT_SUB_SCHED */
> static inline struct scx_sched *scx_task_sched(const struct task_struct *p)
> {
> @@ -1656,6 +1775,8 @@ static inline struct scx_sched *scx_prog_sched(const struct bpf_prog_aux *aux)
> {
> return rcu_dereference_all(scx_root);
> }
> +
> +static inline struct scx_sched *scx_parent(struct scx_sched *sch) { return NULL; }
> #endif /* CONFIG_EXT_SUB_SCHED */
>
> #endif /* _KERNEL_SCHED_EXT_INTERNAL_H */
> --
> 2.54.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd
2026-06-22 17:39 [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd Tejun Heo
2026-06-22 17:39 ` [PATCH sched_ext/for-7.2 2/2] sched_ext: Move shared helpers from ext.c into internal.h and cid.h Tejun Heo
2026-06-22 18:26 ` [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd Andrea Righi
@ 2026-06-22 20:37 ` Tejun Heo
2026-06-22 21:05 ` [PATCH " Tejun Heo
3 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2026-06-22 20:37 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Peter Zijlstra, Ingo Molnar, Juri Lelli,
Vincent Guittot, David Vernet, Changwoo Min, Emil Tsalapatis,
Linus Torvalds, sched-ext, Andrea Righi
The sources under kernel/sched/ext/ build as a single translation unit:
build_policy.c includes the source files and headers. An LSP/clangd editor
parses each as a standalone unit, sees no types, and reports a flood of
errors.
Give each header its dependencies and include guard, and have each source
include the headers it uses.
ext.c, arena.c and the ext headers now parse clean standalone. idle.c and
cid.c still reference a few macros and helpers defined in ext.c. The next
patch moves those to shared headers.
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
---
v2:
- ext.c includes <linux/sched/clock.h> for sched_clock_cpu() (Andrea).
- idle.h forward-declares struct cpumask/task_struct instead of
including ../sched.h (Andrea).
v1: https://lore.kernel.org/r/20260622173904.1169407-1-tj@kernel.org
kernel/sched/ext/arena.c | 4 ++++
kernel/sched/ext/arena.h | 2 ++
kernel/sched/ext/cid.c | 3 +++
kernel/sched/ext/cid.h | 2 ++
kernel/sched/ext/ext.c | 13 +++++++++++++
kernel/sched/ext/idle.c | 3 +++
kernel/sched/ext/idle.h | 4 ++++
kernel/sched/ext/internal.h | 8 ++++++++
kernel/sched/ext/types.h | 6 ++++++
9 files changed, 45 insertions(+)
diff --git a/kernel/sched/ext/arena.c b/kernel/sched/ext/arena.c
index 493c2424f842..5783694ec21d 100644
--- a/kernel/sched/ext/arena.c
+++ b/kernel/sched/ext/arena.c
@@ -15,6 +15,10 @@
* Copyright (c) 2026 Meta Platforms, Inc. and affiliates.
* Copyright (c) 2026 Tejun Heo <tj@kernel.org>
*/
+#include <linux/genalloc.h>
+
+#include "internal.h"
+#include "arena.h"
enum scx_arena_consts {
SCX_ARENA_MIN_ORDER = 3, /* 8-byte minimum sub-allocation */
diff --git a/kernel/sched/ext/arena.h b/kernel/sched/ext/arena.h
index 4f3610160102..c378ae5fbc02 100644
--- a/kernel/sched/ext/arena.h
+++ b/kernel/sched/ext/arena.h
@@ -8,6 +8,8 @@
#ifndef _KERNEL_SCHED_EXT_ARENA_H
#define _KERNEL_SCHED_EXT_ARENA_H
+#include <linux/types.h>
+
struct scx_sched;
s32 scx_arena_pool_init(struct scx_sched *sch);
diff --git a/kernel/sched/ext/cid.c b/kernel/sched/ext/cid.c
index aeaea88f34c5..af83084ec740 100644
--- a/kernel/sched/ext/cid.c
+++ b/kernel/sched/ext/cid.c
@@ -7,6 +7,9 @@
*/
#include <linux/cacheinfo.h>
+#include "internal.h"
+#include "cid.h"
+
/*
* cid tables.
*
diff --git a/kernel/sched/ext/cid.h b/kernel/sched/ext/cid.h
index 6e657fd147b0..41d0802c6af3 100644
--- a/kernel/sched/ext/cid.h
+++ b/kernel/sched/ext/cid.h
@@ -33,6 +33,8 @@
#ifndef _KERNEL_SCHED_EXT_CID_H
#define _KERNEL_SCHED_EXT_CID_H
+#include "internal.h"
+
struct scx_sched;
/*
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 00fe6cc6d7e2..f3253c946764 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -6,6 +6,19 @@
* Copyright (c) 2022 Tejun Heo <tj@kernel.org>
* Copyright (c) 2022 David Vernet <dvernet@meta.com>
*/
+#include <linux/bitmap.h>
+#include <linux/btf_ids.h>
+#include <linux/rhashtable.h>
+#include <linux/sched/clock.h>
+#include <linux/sched/isolation.h>
+#include <linux/suspend.h>
+#include <linux/sysrq.h>
+
+#include "../pelt.h"
+#include "internal.h"
+#include "cid.h"
+#include "arena.h"
+#include "idle.h"
static DEFINE_RAW_SPINLOCK(scx_sched_lock);
diff --git a/kernel/sched/ext/idle.c b/kernel/sched/ext/idle.c
index 2077373d8da3..8e8c6201b7df 100644
--- a/kernel/sched/ext/idle.c
+++ b/kernel/sched/ext/idle.c
@@ -9,6 +9,9 @@
* Copyright (c) 2022 David Vernet <dvernet@meta.com>
* Copyright (c) 2024 Andrea Righi <arighi@nvidia.com>
*/
+#include "internal.h"
+#include "cid.h"
+#include "idle.h"
/* Enable/disable built-in idle CPU selection policy */
static DEFINE_STATIC_KEY_FALSE(scx_builtin_idle_enabled);
diff --git a/kernel/sched/ext/idle.h b/kernel/sched/ext/idle.h
index 8d169d3bbdf9..87a0e58f1eb7 100644
--- a/kernel/sched/ext/idle.h
+++ b/kernel/sched/ext/idle.h
@@ -10,7 +10,11 @@
#ifndef _KERNEL_SCHED_EXT_IDLE_H
#define _KERNEL_SCHED_EXT_IDLE_H
+#include <linux/btf_ids.h>
+
+struct cpumask;
struct sched_ext_ops;
+struct task_struct;
extern struct btf_id_set8 scx_kfunc_ids_idle;
extern struct btf_id_set8 scx_kfunc_ids_select_cpu;
diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
index b04701190b23..1f5312b3b387 100644
--- a/kernel/sched/ext/internal.h
+++ b/kernel/sched/ext/internal.h
@@ -5,6 +5,12 @@
* Copyright (c) 2025 Meta Platforms, Inc. and affiliates.
* Copyright (c) 2025 Tejun Heo <tj@kernel.org>
*/
+#ifndef _KERNEL_SCHED_EXT_INTERNAL_H
+#define _KERNEL_SCHED_EXT_INTERNAL_H
+
+#include "../sched.h"
+#include "types.h"
+
#define SCX_OP_IDX(op) (offsetof(struct sched_ext_ops, op) / sizeof(void (*)(void)))
#define SCX_MOFF_IDX(moff) ((moff) / sizeof(void (*)(void)))
@@ -1651,3 +1657,5 @@ static inline struct scx_sched *scx_prog_sched(const struct bpf_prog_aux *aux)
return rcu_dereference_all(scx_root);
}
#endif /* CONFIG_EXT_SUB_SCHED */
+
+#endif /* _KERNEL_SCHED_EXT_INTERNAL_H */
diff --git a/kernel/sched/ext/types.h b/kernel/sched/ext/types.h
index 8b3527e21fca..bc74eafd43f1 100644
--- a/kernel/sched/ext/types.h
+++ b/kernel/sched/ext/types.h
@@ -8,6 +8,12 @@
#ifndef _KERNEL_SCHED_EXT_TYPES_H
#define _KERNEL_SCHED_EXT_TYPES_H
+#include <linux/types.h>
+#include <linux/jiffies.h>
+#include <linux/overflow.h>
+#include <linux/time64.h>
+#include <linux/sched/topology.h>
+
enum scx_consts {
SCX_DSP_DFL_MAX_BATCH = 32,
SCX_DSP_MAX_LOOPS = 32,
--
2.54.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd
2026-06-22 17:39 [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd Tejun Heo
` (2 preceding siblings ...)
2026-06-22 20:37 ` [PATCH v2 " Tejun Heo
@ 2026-06-22 21:05 ` Tejun Heo
3 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2026-06-22 21:05 UTC (permalink / raw)
To: Andrea Righi
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, Juri Lelli,
Vincent Guittot, David Vernet, Changwoo Min, Emil Tsalapatis,
Linus Torvalds, sched-ext
Hello,
Applied 1-2 to sched_ext/for-7.2 with Andrea's Reviewed-by added.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-22 21:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22 17:39 [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd Tejun Heo
2026-06-22 17:39 ` [PATCH sched_ext/for-7.2 2/2] sched_ext: Move shared helpers from ext.c into internal.h and cid.h Tejun Heo
2026-06-22 18:45 ` Andrea Righi
2026-06-22 18:26 ` [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd Andrea Righi
2026-06-22 20:37 ` [PATCH v2 " Tejun Heo
2026-06-22 21:05 ` [PATCH " Tejun Heo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.