]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched: Make clangd usable
authorPeter Zijlstra <peterz@infradead.org>
Fri, 23 May 2025 16:26:21 +0000 (18:26 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 11 Jun 2025 09:20:53 +0000 (11:20 +0200)
Due to the weird Makefile setup of sched the various files do not
compile as stand alone units. The new generation of editors are trying
to do just this -- mostly to offer fancy things like completions but
also better syntax highlighting and code navigation.

Specifically, I've been playing around with neovim and clangd.

Setting up clangd on the kernel source is a giant pain in the arse
(this really should be improved), but once you do manage, you run into
dumb stuff like the above.

Fix up the scheduler files to at least pretend to work.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Juri Lelli <juri.lelli@redhat.com>
Link: https://lkml.kernel.org/r/20250523164348.GN39944@noisy.programming.kicks-ass.net
32 files changed:
kernel/sched/autogroup.c
kernel/sched/autogroup.h
kernel/sched/clock.c
kernel/sched/completion.c
kernel/sched/core_sched.c
kernel/sched/cpuacct.c
kernel/sched/cpudeadline.c
kernel/sched/cpudeadline.h
kernel/sched/cpufreq.c
kernel/sched/cpufreq_schedutil.c
kernel/sched/cpupri.c
kernel/sched/cpupri.h
kernel/sched/cputime.c
kernel/sched/deadline.c
kernel/sched/debug.c
kernel/sched/idle.c
kernel/sched/isolation.c
kernel/sched/loadavg.c
kernel/sched/membarrier.c
kernel/sched/pelt.c
kernel/sched/pelt.h
kernel/sched/psi.c
kernel/sched/rt.c
kernel/sched/sched-pelt.h
kernel/sched/sched.h
kernel/sched/smp.h
kernel/sched/stats.c
kernel/sched/stop_task.c
kernel/sched/swait.c
kernel/sched/topology.c
kernel/sched/wait.c
kernel/sched/wait_bit.c

index 2b331822c7e7705218eedc0060412623470947d1..e96a167c3f285e933d64438e7920a44514cc4358 100644 (file)
@@ -4,6 +4,9 @@
  * Auto-group scheduling implementation:
  */
 
+#include "autogroup.h"
+#include "sched.h"
+
 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
 static struct autogroup autogroup_default;
 static atomic_t autogroup_seq_nr;
index 90d69f2c5eafd2a1d96d42cbc99b6ec3cc6ea3f5..5c1796a463af2491c03181ca3f291c6834b8c373 100644 (file)
@@ -2,6 +2,8 @@
 #ifndef _KERNEL_SCHED_AUTOGROUP_H
 #define _KERNEL_SCHED_AUTOGROUP_H
 
+#include "sched.h"
+
 #ifdef CONFIG_SCHED_AUTOGROUP
 
 struct autogroup {
index a09655b48140257bf97e4e1769d29e76a2ffbdd5..e62b5510cd2ee5422b1f9065910bfcfe0dfe0742 100644 (file)
@@ -54,6 +54,9 @@
  *
  */
 
+#include <linux/sched/clock.h>
+#include "sched.h"
+
 /*
  * Scheduler clock - returns current time in nanosec units.
  * This is default implementation.
index 3561ab533dd4e33ddb5284bcab51736f9b9ab6bf..19ee702273c0fadd022cff3ba799b8dbfbbd5137 100644 (file)
  * Waiting for completion is a typically sync point, but not an exclusion point.
  */
 
+#include <linux/linkage.h>
+#include <linux/sched/debug.h>
+#include <linux/completion.h>
+#include "sched.h"
+
 static void complete_with_flags(struct completion *x, int wake_flags)
 {
        unsigned long flags;
index c4606ca892102c015b61ea33386daead0b1f16b9..9ede71ecba7f8aaad2911d1a3b21b81c505c4166 100644 (file)
@@ -4,6 +4,8 @@
  * A simple wrapper around refcount. An allocated sched_core_cookie's
  * address is used to compute the cookie of the task.
  */
+#include "sched.h"
+
 struct sched_core_cookie {
        refcount_t refcnt;
 };
index 0de9dda099496fddb804f6ebb5a7fa0f275a72e5..23a56ba12d81170dedd741892b7b41ee9860ed77 100644 (file)
@@ -6,6 +6,8 @@
  * Based on the work by Paul Menage (menage@google.com) and Balbir Singh
  * (balbir@in.ibm.com).
  */
+#include <linux/sched/cputime.h>
+#include "sched.h"
 
 /* Time spent by the tasks of the CPU accounting group executing in ... */
 enum cpuacct_stat_index {
index 95baa12a10293e0e92b7a65dbb63add7c23caa12..cdd740b3f774365aa2ad38577fe1d47d769ae65d 100644 (file)
@@ -6,6 +6,7 @@
  *
  *  Author: Juri Lelli <j.lelli@sssup.it>
  */
+#include "sched.h"
 
 static inline int parent(int i)
 {
index 0adeda93b5fb56e3086a3a059338ab2cc8fc58ba..3f7c73d1d1890d13e56c9be8c8b8b07f3cf95c30 100644 (file)
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/types.h>
+#include <linux/spinlock.h>
 
 #define IDX_INVALID            -1
 
index 5252fb191faea82555308fd4b83e05e89e5bc2cc..742fb9e62e1af9c20ac68e9938466a442cbf4319 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (C) 2016, Intel Corporation
  * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  */
+#include "sched.h"
 
 DEFINE_PER_CPU(struct update_util_data __rcu *, cpufreq_update_util_data);
 
index 461242ec958af040884c376cceec38cb38dac34c..3d7e9ccb99a0f0cf6ceea5907386ad5e39e3a4c5 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2016, Intel Corporation
  * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  */
+#include <uapi/linux/sched/types.h>
+#include "sched.h"
 
 #define IOWAIT_BOOST_MIN       (SCHED_CAPACITY_SCALE / 8)
 
index 42c40cfdf83630be349949e5498bd16522405461..76a9ac5eb794a2a5405b52e62c9005c2a9e09476 100644 (file)
@@ -22,6 +22,7 @@
  *  worst case complexity of O(min(101, nr_domcpus)), though the scenario that
  *  yields the worst case search is fairly contrived.
  */
+#include "sched.h"
 
 /*
  * p->rt_priority   p->prio   newpri   cpupri
index d6cba0020064cc7a70a18d762adb3600dfed065f..f0f5a734c0c1c8fdc413a3f64873de0f70c017dd 100644 (file)
@@ -1,4 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/atomic.h>
+#include <linux/cpumask.h>
+#include <linux/sched/rt.h>
 
 #define CPUPRI_NR_PRIORITIES   (MAX_RT_PRIO+1)
 
index 6dab4854c6c0843c97eca50646b6c55457d8b83a..f01f17acb4a8a37c505d4923ec1ef3b195e214cd 100644 (file)
@@ -2,6 +2,9 @@
 /*
  * Simple CPU accounting cgroup controller
  */
+#include <linux/sched/cputime.h>
+#include <linux/tsacct_kern.h>
+#include "sched.h"
 
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
  #include <asm/cputime.h>
index ad45a8fea245ee06e8e133d5729586ed2735ea44..ff5be80c5c9d80cd4411ca31e8f99fda93c5fdb3 100644 (file)
  */
 
 #include <linux/cpuset.h>
+#include <linux/sched/clock.h>
+#include <uapi/linux/sched/types.h>
+#include "sched.h"
+#include "pelt.h"
 
 /*
  * Default limits for DL period; on the top end we guard against small util
index 9d71baf08075154c8930070690ae1c4a0d051d2e..b384124d89d320a39834d34d61ecc4602bc2b7be 100644 (file)
@@ -6,6 +6,9 @@
  *
  * Copyright(C) 2007, Red Hat, Inc., Ingo Molnar
  */
+#include <linux/debugfs.h>
+#include <linux/nmi.h>
+#include "sched.h"
 
 /*
  * This allows printing both to /sys/kernel/debug/sched/debug and
index 2c85c86b455f7747d2064a631a901db667a6d746..cd3298653ef4e8dd8f18cd15d7980750a1b4dbf8 100644 (file)
@@ -6,6 +6,11 @@
  * (NOTE: these are not related to SCHED_IDLE batch scheduled
  *        tasks which are handled in sched/fair.c )
  */
+#include <linux/cpuidle.h>
+#include <linux/suspend.h>
+#include <linux/livepatch.h>
+#include "sched.h"
+#include "smp.h"
 
 /* Linker adds these: start and end of __cpuidle functions */
 extern char __cpuidle_text_start[], __cpuidle_text_end[];
index 93b038d48900a304a29ecc0c8aa8b7d419ea1397..a4cf17b1fab062f536c7f4f47c35f0e209fd25d6 100644 (file)
@@ -7,6 +7,8 @@
  * Copyright (C) 2017-2018 SUSE, Frederic Weisbecker
  *
  */
+#include <linux/sched/isolation.h>
+#include "sched.h"
 
 enum hk_flags {
        HK_FLAG_DOMAIN          = BIT(HK_TYPE_DOMAIN),
index c48900b856a2aa3f969803dc9a752bbba1faf3ab..f6df84ca69253e7d43c8e6e41f02d6826b71463b 100644 (file)
@@ -6,6 +6,8 @@
  * figure. Its a silly number but people think its important. We go through
  * great pains to make it work on big machines and tickless kernels.
  */
+#include <linux/sched/nohz.h>
+#include "sched.h"
 
 /*
  * Global load-average calculations
index 809194cd779f42fa57759b731c52685a14744f83..62fba83b7bb190565397312177088116c0e85da8 100644 (file)
@@ -4,6 +4,8 @@
  *
  * membarrier system call
  */
+#include <uapi/linux/membarrier.h>
+#include "sched.h"
 
 /*
  * For documentation purposes, here are some membarrier ordering
index 7a8534a2deffdba785fe734199be6a920bf52c2f..09be6a83e45a9e74fc3299b0c88eefe62ad3c722 100644 (file)
@@ -23,6 +23,7 @@
  *  Move PELT related code from fair.c into this pelt.c file
  *  Author: Vincent Guittot <vincent.guittot@linaro.org>
  */
+#include "pelt.h"
 
 /*
  * Approximate:
index f4f6a0875c66fb7a9d74ead3fc0b6226253b7fc4..19592077452e8431ef468327a927bab3e211155b 100644 (file)
@@ -1,3 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef _KERNEL_SCHED_PELT_H
+#define _KERNEL_SCHED_PELT_H
+#include "sched.h"
+
 #ifdef CONFIG_SMP
 #include "sched-pelt.h"
 
@@ -233,4 +238,4 @@ update_idle_rq_clock_pelt(struct rq *rq) { }
 static inline void update_idle_cfs_rq_clock_pelt(struct cfs_rq *cfs_rq) { }
 #endif
 
-
+#endif /* _KERNEL_SCHED_PELT_H */
index ad04a5c3162a26ad6071775e5433b42b2105fa90..333a7ba39668988fb55ece7af93cab4551f53ee7 100644 (file)
  * cost-wise, yet way more sensitive and accurate than periodic
  * sampling of the aggregate task states would be.
  */
+#include <linux/sched/clock.h>
+#include <linux/workqueue.h>
+#include <linux/psi.h>
+#include "sched.h"
 
 static int psi_bug __read_mostly;
 
index e40422c3703352e72f3c61145fdc20fd70738ecc..16008ac33e1441e19de702db3cf6f1260a336b27 100644 (file)
@@ -4,6 +4,9 @@
  * policies)
  */
 
+#include "sched.h"
+#include "pelt.h"
+
 int sched_rr_timeslice = RR_TIMESLICE;
 /* More than 4 hours if BW_SHIFT equals 20. */
 static const u64 max_rt_runtime = MAX_BW;
index c529706bed11531eea6e4301f126a0aaadefce15..6803cfec7a1e17a232a31232db504dea5330af43 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Generated by Documentation/scheduler/sched-pelt; do not modify. */
+#include <linux/types.h>
 
 static const u32 runnable_avg_yN_inv[] __maybe_unused = {
        0xffffffff, 0xfa83b2da, 0xf5257d14, 0xefe4b99a, 0xeac0c6e6, 0xe5b906e6,
index 475bb5998295e38a0a4a093ec10295928f204b23..f3a41487c96d0d654783de015ce1aab337e4deed 100644 (file)
@@ -69,6 +69,7 @@
 #include <linux/wait_bit.h>
 #include <linux/workqueue_api.h>
 #include <linux/delayacct.h>
+#include <linux/mmu_context.h>
 
 #include <trace/events/power.h>
 #include <trace/events/sched.h>
index 21ac44428bb02799e597b68424ef6da57bb6b189..7f151d96dba96672a69d937881f22406aa004e80 100644 (file)
@@ -1,8 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _KERNEL_SCHED_SMP_H
+#define _KERNEL_SCHED_SMP_H
+
 /*
  * Scheduler internal SMP callback types and methods between the scheduler
  * and other internal parts of the core kernel:
  */
+#include <linux/types.h>
 
 extern void sched_ttwu_pending(void *arg);
 
@@ -13,3 +18,5 @@ extern void flush_smp_call_function_queue(void);
 #else
 static inline void flush_smp_call_function_queue(void) { }
 #endif
+
+#endif /* _KERNEL_SCHED_SMP_H */
index 4346fd81c31fdd03d21a0ac5ac41146207568fdb..1faea875d0b3bc8dde3f3edb5931b99ad168b0fb 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * /proc/schedstat implementation
  */
+#include "sched.h"
 
 void __update_stats_wait_start(struct rq *rq, struct task_struct *p,
                               struct sched_statistics *stats)
index 058dd42e3d9b52c8fd7e378d55cea642547afca8..1c1bbc6e33b6093730ba535197ce508b22df7bf0 100644 (file)
@@ -7,6 +7,7 @@
  *
  * See kernel/stop_machine.c
  */
+#include "sched.h"
 
 #ifdef CONFIG_SMP
 static int
index 72505cd3b60a3e16c093d07da38eab6093155b2e..0fef6496c4c833eaf7475004da5590d28be7c6af 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * <linux/swait.h> (simple wait queues ) implementation:
  */
+#include "sched.h"
 
 void __init_swait_queue_head(struct swait_queue_head *q, const char *name,
                             struct lock_class_key *key)
index b958fe48e02051abb578b841ae686299e25de3ca..9026d325d0fdcca8a91c3da30430feb1261b3adf 100644 (file)
@@ -3,7 +3,9 @@
  * Scheduler topology setup/handling methods
  */
 
+#include <linux/sched/isolation.h>
 #include <linux/bsearch.h>
+#include "sched.h"
 
 DEFINE_MUTEX(sched_domains_mutex);
 void sched_domains_mutex_lock(void)
index 51e38f5f47018c953e31c834dc6385c182359359..a6f00012c72e1ded861d038e7ced1677d3ae4f7b 100644 (file)
@@ -4,6 +4,7 @@
  *
  * (C) 2004 Nadia Yvette Chambers, Oracle
  */
+#include "sched.h"
 
 void __init_waitqueue_head(struct wait_queue_head *wq_head, const char *name, struct lock_class_key *key)
 {
index b410b61cec959cefcf9946201345299e9f242d0b..1088d3b7012cfd7ea9a6797c4e46c2042e538cfe 100644 (file)
@@ -1,5 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
+#include <linux/sched/debug.h>
+#include "sched.h"
+
 /*
  * The implementation of the wait_bit*() and related waiting APIs:
  */