Re: [PATCH sched_ext/for-7.2 1/2] sched_ext: Make kernel/sched/ext/ sources self-contained for clangd

From: Andrea Righi

Date: Mon Jun 22 2026 - 14:26:40 EST


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@xxxxxxxxxxxxx>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> ---

...

> 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@xxxxxxxxxx>
> * Copyright (c) 2022 David Vernet <dvernet@xxxxxxxx>
> */
> +#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@xxxxxxxx>
> * Copyright (c) 2024 Andrea Righi <arighi@xxxxxxxxxx>
> */
> +#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@xxxxxxxxxx>

Thanks,
-Andrea