* Re: [PATCH] mm: add some missing includes to mm-local headers
[not found] ` <8179be78-a35c-4d0f-8034-27f3154db0e7@kernel.org>
@ 2026-08-04 11:02 ` Lorenzo Stoakes (ARM)
2026-08-04 12:17 ` David Hildenbrand (Arm)
[not found] ` <7e7c8e04-646f-4135-9ba5-e0c7fd6d8b41@kernel.org>
1 sibling, 1 reply; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-08-04 11:02 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Andrew Morton, Muchun Song, Oscar Salvador, Johannes Weiner,
Michal Hocko, Roman Gushchin, Shakeel Butt, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan,
Brendan Jackman, Zi Yan, Chris Li, Kairui Song, Kemeng Shi,
Nhat Pham, Baoquan He, Barry Song, Youngjun Park,
Uladzislau Rezki, Michal Hocko, linux-mm, linux-kernel, cgroups
On Tue, Aug 04, 2026 at 12:45:22PM +0200, David Hildenbrand (Arm) wrote:
> On 8/4/26 12:08, Lorenzo Stoakes (ARM) wrote:
> > There are a number of internal headers local to mm/ which reference
> > functions and data types without including the relevant headers.
> >
> > mm/vma.h is a special case that intentionally does not include additional
> > headers, but the others are not.
> >
> > This breaks tooling like clangd (which is where I noticed this), though the
> > build is OK due to the C files including the headers happening to include
> > required dependencies.
> >
> > It's better to be explicit about dependencies anyway, so add the missing
> > includes and fix clangd as a bonus.
>
> I'm curious, how did you identify these? The mm/vmalloc.h is rather easy, but I wonder about
> e.g., mm/shuffle.h including mmzone.h.
Well I got AI to look them up ;) but I pared down what it gave me to a simpler
subset and checked everything so I don't consider myself in a state of
slopper-sin :)
[this kind of check ideas, look things up stuff I don't consider warrants an
Assisted-by tag btw].
The headers for everything but shuffle.h are obvious, so that's the tricky one -
it's for pg_data_t and struct zone specifically.
How I discovered this with clangd initially was - Do something like 'C-c l g r' or
'C-c l g g' in emacs via LSP and it reports 'no symbols' for something I _know_ is
compiled in.
>
> --
> Cheers,
>
> David
--
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: add some missing includes to mm-local headers
[not found] ` <7e7c8e04-646f-4135-9ba5-e0c7fd6d8b41@kernel.org>
@ 2026-08-04 11:05 ` Lorenzo Stoakes (ARM)
2026-08-04 11:11 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-08-04 11:05 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Andrew Morton, Muchun Song, Oscar Salvador, Johannes Weiner,
Michal Hocko, Roman Gushchin, Shakeel Butt, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan,
Brendan Jackman, Zi Yan, Chris Li, Kairui Song, Kemeng Shi,
Nhat Pham, Baoquan He, Barry Song, Youngjun Park,
Uladzislau Rezki, Michal Hocko, linux-mm, linux-kernel, cgroups
On Tue, Aug 04, 2026 at 12:51:40PM +0200, David Hildenbrand (Arm) wrote:
> On 8/4/26 12:45, David Hildenbrand (Arm) wrote:
> > On 8/4/26 12:08, Lorenzo Stoakes (ARM) wrote:
> >> There are a number of internal headers local to mm/ which reference
> >> functions and data types without including the relevant headers.
> >>
> >> mm/vma.h is a special case that intentionally does not include additional
> >> headers, but the others are not.
> >>
> >> This breaks tooling like clangd (which is where I noticed this), though the
> >> build is OK due to the C files including the headers happening to include
> >> required dependencies.
> >>
> >> It's better to be explicit about dependencies anyway, so add the missing
> >> includes and fix clangd as a bonus.
> >
> > I'm curious, how did you identify these? The mm/vmalloc.h is rather easy, but I wonder about
> > e.g., mm/shuffle.h including mmzone.h.
> >
>
> To clarify, I have clangd running behind a vim plugin, and so far it just worked.
>
> I had to generate a weird XML at some point that does magical things for clangd.
Well for me I get the kernel build to generate compiler_commands.json and use
that via:
scripts/clang-tools/gen_compile_commands.py vmlinux.a arch/x86/boot/
In a build script.
But maybe I need your weird XML... I do get frustrated that it limits things to
what I happened to compile. It'd be nice to get it to index literally everything
somehow.
>
> So I'm curious how to invoke clangd manually to actually get these reports.
See other reply, it's just that I noticed missing symbols.
Actually this happened with vma.h (I sloppily got AI to figure out any other
cases) which _intentionally_ doesn't have includes.
But clangd lets you work around that in .clangd:
If:
PathMatch: mm/vma\.h
CompileFlags:
Add: [-include, mm/vma_internal.h]
:)
>
> --
> Cheers,
>
> David
--
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: add some missing includes to mm-local headers
2026-08-04 11:05 ` Lorenzo Stoakes (ARM)
@ 2026-08-04 11:11 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand (Arm) @ 2026-08-04 11:11 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: Andrew Morton, Muchun Song, Oscar Salvador, Johannes Weiner,
Michal Hocko, Roman Gushchin, Shakeel Butt, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan,
Brendan Jackman, Zi Yan, Chris Li, Kairui Song, Kemeng Shi,
Nhat Pham, Baoquan He, Barry Song, Youngjun Park,
Uladzislau Rezki, Michal Hocko, linux-mm, linux-kernel, cgroups
On 8/4/26 13:05, Lorenzo Stoakes (ARM) wrote:
> On Tue, Aug 04, 2026 at 12:51:40PM +0200, David Hildenbrand (Arm) wrote:
>> On 8/4/26 12:45, David Hildenbrand (Arm) wrote:
>>>
>>> I'm curious, how did you identify these? The mm/vmalloc.h is rather easy, but I wonder about
>>> e.g., mm/shuffle.h including mmzone.h.
>>>
>>
>> To clarify, I have clangd running behind a vim plugin, and so far it just worked.
>>
>> I had to generate a weird XML at some point that does magical things for clangd.
>
> Well for me I get the kernel build to generate compiler_commands.json and use
> that via:
>
> scripts/clang-tools/gen_compile_commands.py vmlinux.a arch/x86/boot/
>
> In a build script.
>
> But maybe I need your weird XML... I do get frustrated that it limits things to
> what I happened to compile. It'd be nice to get it to index literally everything
> somehow.
Nah, it was that magical json I had in mind.
>
>>
>> So I'm curious how to invoke clangd manually to actually get these reports.
>
> See other reply, it's just that I noticed missing symbols.
>
> Actually this happened with vma.h (I sloppily got AI to figure out any other
> cases) which _intentionally_ doesn't have includes.
>
> But clangd lets you work around that in .clangd:
>
> If:
> PathMatch: mm/vma\.h
> CompileFlags:
> Add: [-include, mm/vma_internal.h]
>
> :)
I was hoping for an easy-to-run script that complains, instead of people just randomly
running into "missing symbols" and then having to fix it.
But there doesn't seem to be a low hanging fruit.
--
Cheers,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: add some missing includes to mm-local headers
2026-08-04 11:02 ` [PATCH] mm: add some missing includes to mm-local headers Lorenzo Stoakes (ARM)
@ 2026-08-04 12:17 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand (Arm) @ 2026-08-04 12:17 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: Andrew Morton, Muchun Song, Oscar Salvador, Johannes Weiner,
Michal Hocko, Roman Gushchin, Shakeel Butt, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan,
Brendan Jackman, Zi Yan, Chris Li, Kairui Song, Kemeng Shi,
Nhat Pham, Baoquan He, Barry Song, Youngjun Park,
Uladzislau Rezki, Michal Hocko, linux-mm, linux-kernel, cgroups
On 8/4/26 13:02, Lorenzo Stoakes (ARM) wrote:
> On Tue, Aug 04, 2026 at 12:45:22PM +0200, David Hildenbrand (Arm) wrote:
>> On 8/4/26 12:08, Lorenzo Stoakes (ARM) wrote:
>>> There are a number of internal headers local to mm/ which reference
>>> functions and data types without including the relevant headers.
>>>
>>> mm/vma.h is a special case that intentionally does not include additional
>>> headers, but the others are not.
>>>
>>> This breaks tooling like clangd (which is where I noticed this), though the
>>> build is OK due to the C files including the headers happening to include
>>> required dependencies.
>>>
>>> It's better to be explicit about dependencies anyway, so add the missing
>>> includes and fix clangd as a bonus.
>>
>> I'm curious, how did you identify these? The mm/vmalloc.h is rather easy, but I wonder about
>> e.g., mm/shuffle.h including mmzone.h.
>
> Well I got AI to look them up ;) but I pared down what it gave me to a simpler
> subset and checked everything so I don't consider myself in a state of
> slopper-sin :)
>
> [this kind of check ideas, look things up stuff I don't consider warrants an
> Assisted-by tag btw].
>
> The headers for everything but shuffle.h are obvious, so that's the tricky one -
> it's for pg_data_t and struct zone specifically.
>
> How I discovered this with clangd initially was - Do something like 'C-c l g r' or
> 'C-c l g g' in emacs via LSP and it reports 'no symbols' for something I _know_ is
> compiled in.
emacs ... there's your problem :P
Thanks for the explanation, I'm afraid this might become a whack-a-mole without
a proper way to detect this automatically. But that does not really seem doable
easily.
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: add some missing includes to mm-local headers
[not found] <20260804-fix-some-local-headers-v1-1-a7beb173c116@kernel.org>
[not found] ` <8179be78-a35c-4d0f-8034-27f3154db0e7@kernel.org>
@ 2026-08-04 20:00 ` Zi Yan
2026-08-04 22:21 ` Barry Song
2026-08-05 2:45 ` Baoquan He
3 siblings, 0 replies; 7+ messages in thread
From: Zi Yan @ 2026-08-04 20:00 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: Andrew Morton, Muchun Song, Oscar Salvador, David Hildenbrand,
Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Brendan Jackman, Chris Li, Kairui Song,
Kemeng Shi, Nhat Pham, Baoquan He, Barry Song, Youngjun Park,
Uladzislau Rezki, Michal Hocko, linux-mm, linux-kernel, cgroups
On 4 Aug 2026, at 6:08, Lorenzo Stoakes (ARM) wrote:
> There are a number of internal headers local to mm/ which reference
> functions and data types without including the relevant headers.
>
> mm/vma.h is a special case that intentionally does not include additional
> headers, but the others are not.
>
> This breaks tooling like clangd (which is where I noticed this), though the
> build is OK due to the C files including the headers happening to include
> required dependencies.
>
> It's better to be explicit about dependencies anyway, so add the missing
> includes and fix clangd as a bonus.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> ---
> mm/cma.h | 1 +
> mm/hugetlb_cma.h | 2 ++
> mm/memcontrol-v1.h | 1 +
> mm/pgalloc-track.h | 3 +++
> mm/shuffle.h | 2 ++
> mm/swap.h | 1 +
> mm/vmalloc.h | 2 ++
> 7 files changed, 12 insertions(+)
>
Acked-by: Zi Yan <ziy@nvidia.com>
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: add some missing includes to mm-local headers
[not found] <20260804-fix-some-local-headers-v1-1-a7beb173c116@kernel.org>
[not found] ` <8179be78-a35c-4d0f-8034-27f3154db0e7@kernel.org>
2026-08-04 20:00 ` Zi Yan
@ 2026-08-04 22:21 ` Barry Song
2026-08-05 2:45 ` Baoquan He
3 siblings, 0 replies; 7+ messages in thread
From: Barry Song @ 2026-08-04 22:21 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: Andrew Morton, Muchun Song, Oscar Salvador, David Hildenbrand,
Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Brendan Jackman, Zi Yan, Chris Li,
Kairui Song, Kemeng Shi, Nhat Pham, Baoquan He, Youngjun Park,
Uladzislau Rezki, Michal Hocko, linux-mm, linux-kernel, cgroups
On Tue, Aug 4, 2026 at 6:09 PM Lorenzo Stoakes (ARM) <ljs@kernel.org> wrote:
>
> There are a number of internal headers local to mm/ which reference
> functions and data types without including the relevant headers.
>
> mm/vma.h is a special case that intentionally does not include additional
> headers, but the others are not.
>
> This breaks tooling like clangd (which is where I noticed this), though the
> build is OK due to the C files including the headers happening to include
> required dependencies.
>
> It's better to be explicit about dependencies anyway, so add the missing
> includes and fix clangd as a bonus.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> ---
Reviewed-by: Barry Song <baohua@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: add some missing includes to mm-local headers
[not found] <20260804-fix-some-local-headers-v1-1-a7beb173c116@kernel.org>
` (2 preceding siblings ...)
2026-08-04 22:21 ` Barry Song
@ 2026-08-05 2:45 ` Baoquan He
3 siblings, 0 replies; 7+ messages in thread
From: Baoquan He @ 2026-08-05 2:45 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: Andrew Morton, Muchun Song, Oscar Salvador, David Hildenbrand,
Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Brendan Jackman, Zi Yan, Chris Li,
Kairui Song, Kemeng Shi, Nhat Pham, Barry Song, Youngjun Park,
Uladzislau Rezki, Michal Hocko, linux-mm, linux-kernel, cgroups
On 08/04/26 at 11:08am, Lorenzo Stoakes (ARM) wrote:
> There are a number of internal headers local to mm/ which reference
> functions and data types without including the relevant headers.
>
> mm/vma.h is a special case that intentionally does not include additional
> headers, but the others are not.
>
> This breaks tooling like clangd (which is where I noticed this), though the
> build is OK due to the C files including the headers happening to include
> required dependencies.
>
> It's better to be explicit about dependencies anyway, so add the missing
> includes and fix clangd as a bonus.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> ---
> mm/cma.h | 1 +
> mm/hugetlb_cma.h | 2 ++
> mm/memcontrol-v1.h | 1 +
> mm/pgalloc-track.h | 3 +++
> mm/shuffle.h | 2 ++
> mm/swap.h | 1 +
> mm/vmalloc.h | 2 ++
> 7 files changed, 12 insertions(+)
Reviewed-by: Baoquan He <baoquan.he@linux.dev>
>
> diff --git a/mm/cma.h b/mm/cma.h
> index c70180c36559..ab6d39898ea5 100644
> --- a/mm/cma.h
> +++ b/mm/cma.h
> @@ -2,6 +2,7 @@
> #ifndef __MM_CMA_H__
> #define __MM_CMA_H__
>
> +#include <linux/cma.h>
> #include <linux/debugfs.h>
> #include <linux/kobject.h>
>
> diff --git a/mm/hugetlb_cma.h b/mm/hugetlb_cma.h
> index 3aa483573d17..730b2b4965b6 100644
> --- a/mm/hugetlb_cma.h
> +++ b/mm/hugetlb_cma.h
> @@ -2,6 +2,8 @@
> #ifndef _LINUX_HUGETLB_CMA_H
> #define _LINUX_HUGETLB_CMA_H
>
> +#include <linux/hugetlb.h>
> +
> #ifdef CONFIG_CMA
> void hugetlb_cma_free_frozen_folio(struct folio *folio);
> struct folio *hugetlb_cma_alloc_frozen_folio(int order, gfp_t gfp_mask,
> diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h
> index 0f703f239c80..1e394269c613 100644
> --- a/mm/memcontrol-v1.h
> +++ b/mm/memcontrol-v1.h
> @@ -4,6 +4,7 @@
> #define __MM_MEMCONTROL_V1_H
>
> #include <linux/cgroup-defs.h>
> +#include <linux/memcontrol.h>
>
> /* Cgroup v1 and v2 common declarations */
>
> diff --git a/mm/pgalloc-track.h b/mm/pgalloc-track.h
> index e9e879de8649..1a6de1358a21 100644
> --- a/mm/pgalloc-track.h
> +++ b/mm/pgalloc-track.h
> @@ -2,6 +2,9 @@
> #ifndef _LINUX_PGALLOC_TRACK_H
> #define _LINUX_PGALLOC_TRACK_H
>
> +#include <linux/mm.h>
> +#include <linux/pgtable.h>
> +
> #if defined(CONFIG_MMU)
> static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd,
> unsigned long address,
> diff --git a/mm/shuffle.h b/mm/shuffle.h
> index 61bbcddeeee6..11bec7521ab8 100644
> --- a/mm/shuffle.h
> +++ b/mm/shuffle.h
> @@ -2,7 +2,9 @@
> // Copyright(c) 2018 Intel Corporation. All rights reserved.
> #ifndef _MM_SHUFFLE_H
> #define _MM_SHUFFLE_H
> +
> #include <linux/jump_label.h>
> +#include <linux/mmzone.h>
>
> #define SHUFFLE_ORDER MAX_PAGE_ORDER
>
> diff --git a/mm/swap.h b/mm/swap.h
> index d077e5893a42..ec580c713204 100644
> --- a/mm/swap.h
> +++ b/mm/swap.h
> @@ -5,6 +5,7 @@
> #include <linux/atomic.h> /* for atomic_long_t */
> #include <linux/mm.h> /* for PAGE_SHIFT */
> #include <linux/memcontrol.h> /* for mem_cgroup_swappiness() */
> +#include <linux/swap.h> /* for MAX_SWAPFILES_SHIFT, struct swap_info_struct */
>
> struct mempolicy;
> struct swap_iocb;
> diff --git a/mm/vmalloc.h b/mm/vmalloc.h
> index dcfe30eaa80c..8866ddcff668 100644
> --- a/mm/vmalloc.h
> +++ b/mm/vmalloc.h
> @@ -5,6 +5,8 @@
> #ifndef __MM_VMALLOC_H
> #define __MM_VMALLOC_H
>
> +#include <linux/vmalloc.h>
> +
> #ifdef CONFIG_MMU
> void __init vmalloc_init(void);
> int __must_check vmap_pages_range_noflush(unsigned long addr, unsigned long end,
>
> ---
> base-commit: e47602c51d20a93fa1711ed896dc9480de4374d9
> change-id: 20260804-fix-some-local-headers-0ebc15f34c72
>
> Cheers,
> --
> Lorenzo Stoakes (ARM) <ljs@kernel.org>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-05 2:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260804-fix-some-local-headers-v1-1-a7beb173c116@kernel.org>
[not found] ` <8179be78-a35c-4d0f-8034-27f3154db0e7@kernel.org>
2026-08-04 11:02 ` [PATCH] mm: add some missing includes to mm-local headers Lorenzo Stoakes (ARM)
2026-08-04 12:17 ` David Hildenbrand (Arm)
[not found] ` <7e7c8e04-646f-4135-9ba5-e0c7fd6d8b41@kernel.org>
2026-08-04 11:05 ` Lorenzo Stoakes (ARM)
2026-08-04 11:11 ` David Hildenbrand (Arm)
2026-08-04 20:00 ` Zi Yan
2026-08-04 22:21 ` Barry Song
2026-08-05 2:45 ` Baoquan He
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox