]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched_ext: Make kernel/sched/ext/ sources self-contained for clangd
authorTejun Heo <tj@kernel.org>
Mon, 22 Jun 2026 17:29:39 +0000 (07:29 -1000)
committerTejun Heo <tj@kernel.org>
Mon, 22 Jun 2026 20:41:26 +0000 (10:41 -1000)
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>
kernel/sched/ext/arena.c
kernel/sched/ext/arena.h
kernel/sched/ext/cid.c
kernel/sched/ext/cid.h
kernel/sched/ext/ext.c
kernel/sched/ext/idle.c
kernel/sched/ext/idle.h
kernel/sched/ext/internal.h
kernel/sched/ext/types.h

index 493c2424f8429be759f6fabc2bc644ac2389a210..5783694ec21da209eedf7c4f2de0046dab83870c 100644 (file)
  * 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 */
index 4f361016010242e0867a689e4b6380468b151dcf..c378ae5fbc02f52cc65cb24e8cded9b161844675 100644 (file)
@@ -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);
index aeaea88f34c55a611eaf0f09226a49816f0ef214..af83084ec740a8a89d3cbb9449127bea7e4c7298 100644 (file)
@@ -7,6 +7,9 @@
  */
 #include <linux/cacheinfo.h>
 
+#include "internal.h"
+#include "cid.h"
+
 /*
  * cid tables.
  *
index 6e657fd147b0452a18f276a04e647d0bfdb51bf0..41d0802c6af36f38d5b228bfeff6350ca87bd026 100644 (file)
@@ -33,6 +33,8 @@
 #ifndef _KERNEL_SCHED_EXT_CID_H
 #define _KERNEL_SCHED_EXT_CID_H
 
+#include "internal.h"
+
 struct scx_sched;
 
 /*
index 00fe6cc6d7e2796079d41854a4d82d9de07b63c8..f3253c9467646722f890e0ff13dba23a4b0d6e00 100644 (file)
@@ -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);
 
index 2077373d8da3b7b66f9db7dea5c1ef98d5066ae0..8e8c6201b7dfdcbcff9a53d88d8f05b3d67e1a5d 100644 (file)
@@ -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);
index 8d169d3bbdf98d2be5ffa6d3bdb6eb71727d3770..87a0e58f1eb7fcb8a2f6b6fd9131a0e785f63e6b 100644 (file)
 #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;
index b04701190b2361dad8ee813fe8ab0a0cab5c0089..1f5312b3b387ab6ce706d43dc7bc3185a842eb70 100644 (file)
@@ -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 */
index 8b3527e21fca70753bd9466d3f02aa4b0cc11e62..bc74eafd43f12779928a52c35abd113dd332e01d 100644 (file)
@@ -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,