Re: [PATCH v2 1/2] vdso: move offset_in_page() from linux/mm.h to vdso/page.h

From: David Laight

Date: Thu May 21 2026 - 06:03:30 EST


On Thu, 21 May 2026 11:06:57 +0200
Thorsten Blum <thorsten.blum@xxxxxxxxx> wrote:

> Move offset_in_page() out of linux/mm.h so users that only need page
> offset calculations can include the lightweight vdso/page.h header
> instead of pulling in the large linux/mm.h.
>
> Include vdso/page.h from linux/mm.h so existing users of
> offset_in_page() continue to build.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
> ---
> include/linux/mm.h | 2 +-
> include/vdso/page.h | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 9cedc5e75aa9..d5c7f1ca80ef 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -37,6 +37,7 @@
> #include <linux/bitmap.h>
> #include <linux/bitops.h>
> #include <linux/iommu-debug-pagealloc.h>
> +#include <vdso/page.h>

That is already picked up otherwise PAGE_MASK would be undefined.

The whole vdso headers is a mess.
I moved one of the definitions (to do with bitmasks) back into its main header.
The vdso compiled fine because all the 'normal' kernel headers get included
in vdso builds.

-- David

>
> struct mempolicy;
> struct anon_vma;
> @@ -3023,7 +3024,6 @@ static inline void clear_page_pfmemalloc(struct page *page)
> */
> extern void pagefault_out_of_memory(void);
>
> -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
> #define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1))
>
> /*
> diff --git a/include/vdso/page.h b/include/vdso/page.h
> index bc47186c07fc..948b13091084 100644
> --- a/include/vdso/page.h
> +++ b/include/vdso/page.h
> @@ -28,4 +28,6 @@
> #define PAGE_MASK (~(PAGE_SIZE - 1))
> #endif
>
> +#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
> +
> #endif /* __VDSO_PAGE_H */