linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched: Make clangd usable
@ 2025-05-23 16:43 Peter Zijlstra
  2025-05-23 16:48 ` Tejun Heo
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Peter Zijlstra @ 2025-05-23 16:43 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, vschneid, rafael, viresh.kumar,
	mathieu.desnoyers, paulmck, hannes, surenb
  Cc: linux-kernel, linux-pm, tj


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.

(this excludes ext because those include games are worse than average)

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---

Ingo, the alternative is going back a normal make setup, hmm?


 kernel/sched/autogroup.c         |    3 +++
 kernel/sched/autogroup.h         |    2 ++
 kernel/sched/clock.c             |    3 +++
 kernel/sched/completion.c        |    5 +++++
 kernel/sched/core_sched.c        |    2 ++
 kernel/sched/cpuacct.c           |    2 ++
 kernel/sched/cpudeadline.c       |    1 +
 kernel/sched/cpudeadline.h       |    2 ++
 kernel/sched/cpufreq.c           |    1 +
 kernel/sched/cpufreq_schedutil.c |    2 ++
 kernel/sched/cpupri.c            |    1 +
 kernel/sched/cpupri.h            |    3 +++
 kernel/sched/cputime.c           |    3 +++
 kernel/sched/deadline.c          |    4 ++++
 kernel/sched/debug.c             |    3 +++
 kernel/sched/idle.c              |    5 +++++
 kernel/sched/isolation.c         |    2 ++
 kernel/sched/loadavg.c           |    2 ++
 kernel/sched/membarrier.c        |    2 ++
 kernel/sched/pelt.c              |    1 +
 kernel/sched/pelt.h              |    7 ++++++-
 kernel/sched/psi.c               |    2 ++
 kernel/sched/rt.c                |    3 +++
 kernel/sched/sched-pelt.h        |    1 +
 kernel/sched/sched.h             |    1 +
 kernel/sched/smp.h               |    1 +
 kernel/sched/stats.c             |    1 +
 kernel/sched/stop_task.c         |    1 +
 kernel/sched/swait.c             |    1 +
 kernel/sched/topology.c          |    2 ++
 kernel/sched/wait.c              |    1 +
 kernel/sched/wait_bit.c          |    3 +++
 32 files changed, 72 insertions(+), 1 deletion(-)

--- a/kernel/sched/autogroup.c
+++ b/kernel/sched/autogroup.c
@@ -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;
--- a/kernel/sched/autogroup.h
+++ b/kernel/sched/autogroup.h
@@ -2,6 +2,8 @@
 #ifndef _KERNEL_SCHED_AUTOGROUP_H
 #define _KERNEL_SCHED_AUTOGROUP_H
 
+#include "sched.h"
+
 #ifdef CONFIG_SCHED_AUTOGROUP
 
 struct autogroup {
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -54,6 +54,9 @@
  *
  */
 
+#include <linux/sched/clock.h>
+#include "sched.h"
+
 /*
  * Scheduler clock - returns current time in nanosec units.
  * This is default implementation.
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -13,6 +13,11 @@
  * 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;
--- a/kernel/sched/core_sched.c
+++ b/kernel/sched/core_sched.c
@@ -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;
 };
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -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 {
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -6,6 +6,7 @@
  *
  *  Author: Juri Lelli <j.lelli@sssup.it>
  */
+#include "sched.h"
 
 static inline int parent(int i)
 {
--- a/kernel/sched/cpudeadline.h
+++ b/kernel/sched/cpudeadline.h
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/types.h>
+#include <linux/spinlock.h>
 
 #define IDX_INVALID		-1
 
--- a/kernel/sched/cpufreq.c
+++ b/kernel/sched/cpufreq.c
@@ -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);
 
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -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)
 
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -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
--- a/kernel/sched/cpupri.h
+++ b/kernel/sched/cpupri.h
@@ -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)
 
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -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>
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -17,6 +17,10 @@
  */
 
 #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
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -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
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -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[];
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -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),
--- a/kernel/sched/loadavg.c
+++ b/kernel/sched/loadavg.c
@@ -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
--- a/kernel/sched/membarrier.c
+++ b/kernel/sched/membarrier.c
@@ -4,6 +4,8 @@
  *
  * membarrier system call
  */
+#include <uapi/linux/membarrier.h>
+#include "sched.h"
 
 /*
  * For documentation purposes, here are some membarrier ordering
--- a/kernel/sched/pelt.c
+++ b/kernel/sched/pelt.c
@@ -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:
--- a/kernel/sched/pelt.h
+++ b/kernel/sched/pelt.h
@@ -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 */
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -136,6 +136,8 @@
  * cost-wise, yet way more sensitive and accurate than periodic
  * sampling of the aggregate task states would be.
  */
+#include <linux/psi.h>
+#include "sched.h"
 
 static int psi_bug __read_mostly;
 
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -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;
--- a/kernel/sched/sched-pelt.h
+++ b/kernel/sched/sched-pelt.h
@@ -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,
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -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>
--- a/kernel/sched/smp.h
+++ b/kernel/sched/smp.h
@@ -3,6 +3,7 @@
  * 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);
 
--- a/kernel/sched/stats.c
+++ b/kernel/sched/stats.c
@@ -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)
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -7,6 +7,7 @@
  *
  * See kernel/stop_machine.c
  */
+#include "sched.h"
 
 #ifdef CONFIG_SMP
 static int
--- a/kernel/sched/swait.c
+++ b/kernel/sched/swait.c
@@ -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)
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -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)
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -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)
 {
--- a/kernel/sched/wait_bit.c
+++ b/kernel/sched/wait_bit.c
@@ -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:
  */

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 16:43 [PATCH] sched: Make clangd usable Peter Zijlstra
@ 2025-05-23 16:48 ` Tejun Heo
  2025-05-23 18:19   ` Tejun Heo
  2025-05-23 21:02   ` Andrea Righi
  2025-05-23 16:49 ` Peter Zijlstra
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 13+ messages in thread
From: Tejun Heo @ 2025-05-23 16:48 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, rafael, viresh.kumar,
	mathieu.desnoyers, paulmck, hannes, surenb, linux-kernel,
	linux-pm, Andrea Righi

On Fri, May 23, 2025 at 06:43:48PM +0200, Peter Zijlstra wrote:
> 
> 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.
> 
> (this excludes ext because those include games are worse than average)

Yeah, ext needs to move the stuff that's shared between ext.c and ext_idle.c
into ext.h. cc: Andrea.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 16:43 [PATCH] sched: Make clangd usable Peter Zijlstra
  2025-05-23 16:48 ` Tejun Heo
@ 2025-05-23 16:49 ` Peter Zijlstra
  2025-05-23 18:09   ` Steven Rostedt
  2025-05-26  8:11 ` Ingo Molnar
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Peter Zijlstra @ 2025-05-23 16:49 UTC (permalink / raw)
  To: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, rafael, viresh.kumar,
	mathieu.desnoyers, paulmck, hannes, surenb
  Cc: linux-kernel, linux-pm, tj

On Fri, May 23, 2025 at 06:43:48PM +0200, Peter Zijlstra wrote:
> 
> 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.

To be fair, by far the biggest help has turned out to be to get instant
compiler warning/fails while you type code. This has drastically reduced
the stupid typo, doesn't compile, try again cycle.

Code completion is 'cute' but I'm not really limited in typing speed,
getting pop-up function arguments while typing is useful.

The better code navigation is also very useful.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 16:49 ` Peter Zijlstra
@ 2025-05-23 18:09   ` Steven Rostedt
  2025-05-26  7:41     ` Peter Zijlstra
  0 siblings, 1 reply; 13+ messages in thread
From: Steven Rostedt @ 2025-05-23 18:09 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, bsegall,
	mgorman, vschneid, rafael, viresh.kumar, mathieu.desnoyers,
	paulmck, hannes, surenb, linux-kernel, linux-pm, tj

On Fri, 23 May 2025 18:49:14 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> On Fri, May 23, 2025 at 06:43:48PM +0200, Peter Zijlstra wrote:
> > 
> > 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.  
> 
> To be fair, by far the biggest help has turned out to be to get instant
> compiler warning/fails while you type code. This has drastically reduced
> the stupid typo, doesn't compile, try again cycle.
> 
> Code completion is 'cute' but I'm not really limited in typing speed,
> getting pop-up function arguments while typing is useful.
> 
> The better code navigation is also very useful.

Is there an emacs extension? (I'm sure there is, I'm just too lazy to look ;-)

-- Steve

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 16:48 ` Tejun Heo
@ 2025-05-23 18:19   ` Tejun Heo
  2025-05-23 21:02   ` Andrea Righi
  1 sibling, 0 replies; 13+ messages in thread
From: Tejun Heo @ 2025-05-23 18:19 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, rafael, viresh.kumar,
	mathieu.desnoyers, paulmck, hannes, surenb, linux-kernel,
	linux-pm, Andrea Righi

On Fri, May 23, 2025 at 06:48:08AM -1000, Tejun Heo wrote:
> On Fri, May 23, 2025 at 06:43:48PM +0200, Peter Zijlstra wrote:
> > 
> > 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.
> > 
> > (this excludes ext because those include games are worse than average)
> 
> Yeah, ext needs to move the stuff that's shared between ext.c and ext_idle.c
> into ext.h. cc: Andrea.

Thinking more about it, I wonder whether what should happen is re-splitting
the includes and all that but add the combined compilation as a
default-enabled option, so that the files can be built separately at least
when verifying the source files are in sane states. Including the same files
multiple times don't really cost anything signficant, so that still
maintains the benefits of faster build speed. The way things are set up now,
the separation across files are bound to decay over time.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 16:48 ` Tejun Heo
  2025-05-23 18:19   ` Tejun Heo
@ 2025-05-23 21:02   ` Andrea Righi
  1 sibling, 0 replies; 13+ messages in thread
From: Andrea Righi @ 2025-05-23 21:02 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Peter Zijlstra, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid, rafael,
	viresh.kumar, mathieu.desnoyers, paulmck, hannes, surenb,
	linux-kernel, linux-pm

On Fri, May 23, 2025 at 06:48:08AM -1000, Tejun Heo wrote:
> On Fri, May 23, 2025 at 06:43:48PM +0200, Peter Zijlstra wrote:
> > 
> > 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.
> > 
> > (this excludes ext because those include games are worse than average)
> 
> Yeah, ext needs to move the stuff that's shared between ext.c and ext_idle.c
> into ext.h. cc: Andrea.

Ack, will take a look at ext_idle.c and do some cleanups.

Thanks,
-Andrea

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 18:09   ` Steven Rostedt
@ 2025-05-26  7:41     ` Peter Zijlstra
  0 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2025-05-26  7:41 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, bsegall,
	mgorman, vschneid, rafael, viresh.kumar, mathieu.desnoyers,
	paulmck, hannes, surenb, linux-kernel, linux-pm, tj

On Fri, May 23, 2025 at 02:09:35PM -0400, Steven Rostedt wrote:
> On Fri, 23 May 2025 18:49:14 +0200
> Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > On Fri, May 23, 2025 at 06:43:48PM +0200, Peter Zijlstra wrote:
> > > 
> > > 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.  
> > 
> > To be fair, by far the biggest help has turned out to be to get instant
> > compiler warning/fails while you type code. This has drastically reduced
> > the stupid typo, doesn't compile, try again cycle.
> > 
> > Code completion is 'cute' but I'm not really limited in typing speed,
> > getting pop-up function arguments while typing is useful.
> > 
> > The better code navigation is also very useful.
> 
> Is there an emacs extension? (I'm sure there is, I'm just too lazy to look ;-)

Google redirected me here: https://emacs-lsp.github.io/lsp-mode/page/lsp-clangd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 16:43 [PATCH] sched: Make clangd usable Peter Zijlstra
  2025-05-23 16:48 ` Tejun Heo
  2025-05-23 16:49 ` Peter Zijlstra
@ 2025-05-26  8:11 ` Ingo Molnar
  2025-05-26  8:59 ` Peter Zijlstra
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Ingo Molnar @ 2025-05-26  8:11 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, rafael, viresh.kumar,
	mathieu.desnoyers, paulmck, hannes, surenb, linux-kernel,
	linux-pm, tj


* Peter Zijlstra <peterz@infradead.org> wrote:

> 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.

>  kernel/sched/autogroup.c         |    3 +++
>  kernel/sched/autogroup.h         |    2 ++
>  kernel/sched/clock.c             |    3 +++
>  kernel/sched/completion.c        |    5 +++++
>  kernel/sched/core_sched.c        |    2 ++
>  kernel/sched/cpuacct.c           |    2 ++
>  kernel/sched/cpudeadline.c       |    1 +
>  kernel/sched/cpudeadline.h       |    2 ++
>  kernel/sched/cpufreq.c           |    1 +
>  kernel/sched/cpufreq_schedutil.c |    2 ++
>  kernel/sched/cpupri.c            |    1 +
>  kernel/sched/cpupri.h            |    3 +++
>  kernel/sched/cputime.c           |    3 +++
>  kernel/sched/deadline.c          |    4 ++++
>  kernel/sched/debug.c             |    3 +++
>  kernel/sched/idle.c              |    5 +++++
>  kernel/sched/isolation.c         |    2 ++
>  kernel/sched/loadavg.c           |    2 ++
>  kernel/sched/membarrier.c        |    2 ++
>  kernel/sched/pelt.c              |    1 +
>  kernel/sched/pelt.h              |    7 ++++++-
>  kernel/sched/psi.c               |    2 ++
>  kernel/sched/rt.c                |    3 +++
>  kernel/sched/sched-pelt.h        |    1 +
>  kernel/sched/sched.h             |    1 +
>  kernel/sched/smp.h               |    1 +
>  kernel/sched/stats.c             |    1 +
>  kernel/sched/stop_task.c         |    1 +
>  kernel/sched/swait.c             |    1 +
>  kernel/sched/topology.c          |    2 ++
>  kernel/sched/wait.c              |    1 +
>  kernel/sched/wait_bit.c          |    3 +++
>  32 files changed, 72 insertions(+), 1 deletion(-)

Yeah, I see no reason why this wouldn't work - and the original build 
speedup will still be present.

Acked-by: Ingo Molnar <mingo@kernel.org>

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 16:43 [PATCH] sched: Make clangd usable Peter Zijlstra
                   ` (2 preceding siblings ...)
  2025-05-26  8:11 ` Ingo Molnar
@ 2025-05-26  8:59 ` Peter Zijlstra
  2025-05-26  9:04   ` Peter Zijlstra
  2025-05-26 11:44   ` Peter Zijlstra
  2025-05-26 14:49 ` Juri Lelli
  2025-06-11  9:29 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
  5 siblings, 2 replies; 13+ messages in thread
From: Peter Zijlstra @ 2025-05-26  8:59 UTC (permalink / raw)
  To: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, rafael, viresh.kumar,
	mathieu.desnoyers, paulmck, hannes, surenb
  Cc: linux-kernel, linux-pm, tj, masahiroy

On Fri, May 23, 2025 at 06:43:48PM +0200, Peter Zijlstra wrote:

> 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.

Given Steve asked for an emacs lsp plugin, I'm guessing he's going to be
wanting this part too.

The way I got clangd working is something like:


$ mkdir clangd-build
$ make O=clangd-build allmodconfig
$ make O=clangd-build LLVM=-19 -j128
$ cd clangd-build
$ ../scripts/clang-tools/gen_compile_commands.py
$ sed -i "s'randomize-layout-seed-file=\.'randomize-layout-seed-file=$PWD'g" compile_commands.json
$ cd -
$ ln -s clang-build/compile_commands.json 

I then also have:

$ cat .clangd
# https://clangd.llvm.org/config
CompileFlags:
  Add: -ferror-limit=0
Diagnostics:
  ClangTidy:
    Remove: bugprone-sizeof-expression
  UnusedIncludes: None
Completion:
  HeaderInsertion: Never
$


This has you sit on about 10G of build output, and while it is very
tempting to do make clean on clangd-build, this will in fact ruin
things. You can however manually delete all the compiler output, just
not the various generated files.

I've not been annoyed enough to (or out of diskspace enough) to go stare
at fixing the Makefiles to make all this easier. But ideally it would be
possible to do a no-op build to just generate the .cmd files without
doing any actual compiling -- building allmodconfig is slow, doubly so
with allmodconfig.

Or maybe this is already possible and I just didn't find the magic
incantations.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-26  8:59 ` Peter Zijlstra
@ 2025-05-26  9:04   ` Peter Zijlstra
  2025-05-26 11:44   ` Peter Zijlstra
  1 sibling, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2025-05-26  9:04 UTC (permalink / raw)
  To: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, rafael, viresh.kumar,
	mathieu.desnoyers, paulmck, hannes, surenb
  Cc: linux-kernel, linux-pm, tj, masahiroy

On Mon, May 26, 2025 at 10:59:43AM +0200, Peter Zijlstra wrote:
> On Fri, May 23, 2025 at 06:43:48PM +0200, Peter Zijlstra wrote:
> 
> > 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.
> 
> Given Steve asked for an emacs lsp plugin, I'm guessing he's going to be
> wanting this part too.
> 
> The way I got clangd working is something like:
> 
> 
> $ mkdir clangd-build
> $ make O=clangd-build allmodconfig
> $ make O=clangd-build LLVM=-19 -j128
> $ cd clangd-build
> $ ../scripts/clang-tools/gen_compile_commands.py
> $ sed -i "s'randomize-layout-seed-file=\.'randomize-layout-seed-file=$PWD'g" compile_commands.json
> $ cd -
> $ ln -s clang-build/compile_commands.json 
> 
> I then also have:
> 
> $ cat .clangd
> # https://clangd.llvm.org/config
> CompileFlags:
>   Add: -ferror-limit=0
> Diagnostics:
>   ClangTidy:
>     Remove: bugprone-sizeof-expression
>   UnusedIncludes: None
> Completion:
>   HeaderInsertion: Never
> $
> 
> 
> This has you sit on about 10G of build output, and while it is very
> tempting to do make clean on clangd-build, this will in fact ruin
> things. You can however manually delete all the compiler output, just
> not the various generated files.
> 
> I've not been annoyed enough to (or out of diskspace enough) to go stare
> at fixing the Makefiles to make all this easier. But ideally it would be
> possible to do a no-op build to just generate the .cmd files without
> doing any actual compiling -- building allmodconfig is slow, doubly so
> with allmodconfig.

.. with clang -- gcc is still significantly faster; and I know there's a
k.org clang build optimized for kernels, however I seem to end up using
either distro builds or custom builds, neither of which are having
whatever goodness the k.org build has.

> Or maybe this is already possible and I just didn't find the magic
> incantations.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-26  8:59 ` Peter Zijlstra
  2025-05-26  9:04   ` Peter Zijlstra
@ 2025-05-26 11:44   ` Peter Zijlstra
  1 sibling, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2025-05-26 11:44 UTC (permalink / raw)
  To: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, rafael, viresh.kumar,
	mathieu.desnoyers, paulmck, hannes, surenb
  Cc: linux-kernel, linux-pm, tj, masahiroy

On Mon, May 26, 2025 at 10:59:43AM +0200, Peter Zijlstra wrote:

> I've not been annoyed enough to (or out of diskspace enough) to go stare
> at fixing the Makefiles to make all this easier. But ideally it would be
> possible to do a no-op build to just generate the .cmd files without
> doing any actual compiling -- building allmodconfig is slow, doubly so
> with allmodconfig.
> 
> Or maybe this is already possible and I just didn't find the magic
> incantations.

So I had a quick peek at the Makefiles, and while there is a
compile_commands.json target (just not readily accessible without doing
other weird things), it still causes everything to be built :-(

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched: Make clangd usable
  2025-05-23 16:43 [PATCH] sched: Make clangd usable Peter Zijlstra
                   ` (3 preceding siblings ...)
  2025-05-26  8:59 ` Peter Zijlstra
@ 2025-05-26 14:49 ` Juri Lelli
  2025-06-11  9:29 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
  5 siblings, 0 replies; 13+ messages in thread
From: Juri Lelli @ 2025-05-26 14:49 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, vincent.guittot, dietmar.eggemann, rostedt, bsegall,
	mgorman, vschneid, rafael, viresh.kumar, mathieu.desnoyers,
	paulmck, hannes, surenb, linux-kernel, linux-pm, tj

Hi,

On 23/05/25 18:43, Peter Zijlstra wrote:
> 
> 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.

Me too very recently. :)

> 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.
> 
> (this excludes ext because those include games are worse than average)
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>

This indeed works for me as well. Thanks!

Tested-by: Juri Lelli <juri.lelli@redhat.com>

Best,
Juri


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tip: sched/core] sched: Make clangd usable
  2025-05-23 16:43 [PATCH] sched: Make clangd usable Peter Zijlstra
                   ` (4 preceding siblings ...)
  2025-05-26 14:49 ` Juri Lelli
@ 2025-06-11  9:29 ` tip-bot2 for Peter Zijlstra
  5 siblings, 0 replies; 13+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2025-06-11  9:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Peter Zijlstra (Intel), Ingo Molnar, Juri Lelli, x86,
	linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     3d7e10188ae0b68dadd60f611ca81ecf9d991f77
Gitweb:        https://git.kernel.org/tip/3d7e10188ae0b68dadd60f611ca81ecf9d991f77
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Fri, 23 May 2025 18:26:21 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 11 Jun 2025 11:20:53 +02:00

sched: Make clangd usable

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
---
 kernel/sched/autogroup.c         | 3 +++
 kernel/sched/autogroup.h         | 2 ++
 kernel/sched/clock.c             | 3 +++
 kernel/sched/completion.c        | 5 +++++
 kernel/sched/core_sched.c        | 2 ++
 kernel/sched/cpuacct.c           | 2 ++
 kernel/sched/cpudeadline.c       | 1 +
 kernel/sched/cpudeadline.h       | 2 ++
 kernel/sched/cpufreq.c           | 1 +
 kernel/sched/cpufreq_schedutil.c | 2 ++
 kernel/sched/cpupri.c            | 1 +
 kernel/sched/cpupri.h            | 3 +++
 kernel/sched/cputime.c           | 3 +++
 kernel/sched/deadline.c          | 4 ++++
 kernel/sched/debug.c             | 3 +++
 kernel/sched/idle.c              | 5 +++++
 kernel/sched/isolation.c         | 2 ++
 kernel/sched/loadavg.c           | 2 ++
 kernel/sched/membarrier.c        | 2 ++
 kernel/sched/pelt.c              | 1 +
 kernel/sched/pelt.h              | 7 ++++++-
 kernel/sched/psi.c               | 4 ++++
 kernel/sched/rt.c                | 3 +++
 kernel/sched/sched-pelt.h        | 1 +
 kernel/sched/sched.h             | 1 +
 kernel/sched/smp.h               | 7 +++++++
 kernel/sched/stats.c             | 1 +
 kernel/sched/stop_task.c         | 1 +
 kernel/sched/swait.c             | 1 +
 kernel/sched/topology.c          | 2 ++
 kernel/sched/wait.c              | 1 +
 kernel/sched/wait_bit.c          | 3 +++
 32 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/autogroup.c b/kernel/sched/autogroup.c
index 2b33182..e96a167 100644
--- a/kernel/sched/autogroup.c
+++ b/kernel/sched/autogroup.c
@@ -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;
diff --git a/kernel/sched/autogroup.h b/kernel/sched/autogroup.h
index 90d69f2..5c1796a 100644
--- a/kernel/sched/autogroup.h
+++ b/kernel/sched/autogroup.h
@@ -2,6 +2,8 @@
 #ifndef _KERNEL_SCHED_AUTOGROUP_H
 #define _KERNEL_SCHED_AUTOGROUP_H
 
+#include "sched.h"
+
 #ifdef CONFIG_SCHED_AUTOGROUP
 
 struct autogroup {
diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index a09655b..e62b551 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -54,6 +54,9 @@
  *
  */
 
+#include <linux/sched/clock.h>
+#include "sched.h"
+
 /*
  * Scheduler clock - returns current time in nanosec units.
  * This is default implementation.
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 3561ab5..19ee702 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -13,6 +13,11 @@
  * 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;
diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c
index c4606ca..9ede71e 100644
--- a/kernel/sched/core_sched.c
+++ b/kernel/sched/core_sched.c
@@ -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;
 };
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 0de9dda..23a56ba 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -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 {
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index 95baa12..cdd740b 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -6,6 +6,7 @@
  *
  *  Author: Juri Lelli <j.lelli@sssup.it>
  */
+#include "sched.h"
 
 static inline int parent(int i)
 {
diff --git a/kernel/sched/cpudeadline.h b/kernel/sched/cpudeadline.h
index 0adeda9..3f7c73d 100644
--- a/kernel/sched/cpudeadline.h
+++ b/kernel/sched/cpudeadline.h
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/types.h>
+#include <linux/spinlock.h>
 
 #define IDX_INVALID		-1
 
diff --git a/kernel/sched/cpufreq.c b/kernel/sched/cpufreq.c
index 5252fb1..742fb9e 100644
--- a/kernel/sched/cpufreq.c
+++ b/kernel/sched/cpufreq.c
@@ -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);
 
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 461242e..3d7e9cc 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -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)
 
diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index 42c40cf..76a9ac5 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -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
diff --git a/kernel/sched/cpupri.h b/kernel/sched/cpupri.h
index d6cba00..f0f5a73 100644
--- a/kernel/sched/cpupri.h
+++ b/kernel/sched/cpupri.h
@@ -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)
 
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 6dab485..f01f17a 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -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>
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index ad45a8f..ff5be80 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -17,6 +17,10 @@
  */
 
 #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
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 9d71baf..b384124 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -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
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index 2c85c86..cd32986 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -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[];
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 93b038d..a4cf17b 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -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),
diff --git a/kernel/sched/loadavg.c b/kernel/sched/loadavg.c
index c48900b..f6df84c 100644
--- a/kernel/sched/loadavg.c
+++ b/kernel/sched/loadavg.c
@@ -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
diff --git a/kernel/sched/membarrier.c b/kernel/sched/membarrier.c
index 809194c..62fba83 100644
--- a/kernel/sched/membarrier.c
+++ b/kernel/sched/membarrier.c
@@ -4,6 +4,8 @@
  *
  * membarrier system call
  */
+#include <uapi/linux/membarrier.h>
+#include "sched.h"
 
 /*
  * For documentation purposes, here are some membarrier ordering
diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
index 7a8534a..09be6a8 100644
--- a/kernel/sched/pelt.c
+++ b/kernel/sched/pelt.c
@@ -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:
diff --git a/kernel/sched/pelt.h b/kernel/sched/pelt.h
index f4f6a08..1959207 100644
--- a/kernel/sched/pelt.h
+++ b/kernel/sched/pelt.h
@@ -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 */
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index ad04a5c..333a7ba 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -136,6 +136,10 @@
  * 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;
 
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index e40422c..16008ac 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -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;
diff --git a/kernel/sched/sched-pelt.h b/kernel/sched/sched-pelt.h
index c529706..6803cfe 100644
--- a/kernel/sched/sched-pelt.h
+++ b/kernel/sched/sched-pelt.h
@@ -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,
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 475bb59..f3a4148 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -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>
diff --git a/kernel/sched/smp.h b/kernel/sched/smp.h
index 21ac444..7f151d9 100644
--- a/kernel/sched/smp.h
+++ b/kernel/sched/smp.h
@@ -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 */
diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c
index 4346fd8..1faea87 100644
--- a/kernel/sched/stats.c
+++ b/kernel/sched/stats.c
@@ -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)
diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index 058dd42..1c1bbc6 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -7,6 +7,7 @@
  *
  * See kernel/stop_machine.c
  */
+#include "sched.h"
 
 #ifdef CONFIG_SMP
 static int
diff --git a/kernel/sched/swait.c b/kernel/sched/swait.c
index 72505cd..0fef649 100644
--- a/kernel/sched/swait.c
+++ b/kernel/sched/swait.c
@@ -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)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index b958fe4..9026d32 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -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)
diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
index 51e38f5..a6f0001 100644
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -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)
 {
diff --git a/kernel/sched/wait_bit.c b/kernel/sched/wait_bit.c
index b410b61..1088d3b 100644
--- a/kernel/sched/wait_bit.c
+++ b/kernel/sched/wait_bit.c
@@ -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:
  */

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-06-11  9:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 16:43 [PATCH] sched: Make clangd usable Peter Zijlstra
2025-05-23 16:48 ` Tejun Heo
2025-05-23 18:19   ` Tejun Heo
2025-05-23 21:02   ` Andrea Righi
2025-05-23 16:49 ` Peter Zijlstra
2025-05-23 18:09   ` Steven Rostedt
2025-05-26  7:41     ` Peter Zijlstra
2025-05-26  8:11 ` Ingo Molnar
2025-05-26  8:59 ` Peter Zijlstra
2025-05-26  9:04   ` Peter Zijlstra
2025-05-26 11:44   ` Peter Zijlstra
2025-05-26 14:49 ` Juri Lelli
2025-06-11  9:29 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).