Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mm/vdso: make offset_in_page() usable without linux/mm.h
@ 2026-05-21  9:06 Thorsten Blum
  2026-05-21  9:06 ` [PATCH v2 1/2] vdso: move offset_in_page() from linux/mm.h to vdso/page.h Thorsten Blum
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Thorsten Blum @ 2026-05-21  9:06 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Andy Lutomirski,
	Thomas Gleixner, Vincenzo Frascino, Kees Cook, Andy Shevchenko,
	Yury Norov, David Laight
  Cc: linux-mm, linux-kernel, Thorsten Blum

offset_in_page() is a small page-arithmetic helper that has been around
for 20+ years. However, page-offset calculations are still open-coded in
many places and in different ways:

	(unsigned long)p & ~PAGE_MASK
	(unsigned long)p & (PAGE_SIZE - 1)
	(long)p & (PAGE_SIZE - 1)
	...

Some of these open-coded instances may be due to offset_in_page() being
buried 3000+ lines into linux/mm.h; others may have avoided including
linux/mm.h, which is a large header that pulls in many others.

Patch 1 moves offset_in_page() from linux/mm.h to vdso/page.h, which
keeps the helper with other low-level page definitions and allows users
that only need offset_in_page() to avoid including linux/mm.h.

Patch 2 shows a concrete example where including vdso/page.h is
sufficient and including the large linux/mm.h would be unnecessary.

Existing users of offset_in_page() do not need to change because patch 1
also includes vdso/page.h from linux/mm.h.

This series is based on akpm/mm.git mm-nonmm-unstable commit
d067a83c8063 ("string: use min in sized_strscpy"), which is also in
linux-next.

Changes in v2:
- Add a cover letter and drop the bytes_to_page_end() helper
- Move offset_in_page() to vdso/page.h as suggested by David and Lorenzo
- Use offset_in_page() in lib/string.c as an example since
  bitmap_print_to_pagebuf() in lib/bitmap-str.c is being removed [1]
- v1: https://lore.kernel.org/lkml/20260517123428.1181981-4-thorsten.blum@linux.dev/

[1] https://lore.kernel.org/lkml/20260519163058.953690-3-ynorov@nvidia.com/
---
Thorsten Blum (2):
  vdso: move offset_in_page() from linux/mm.h to vdso/page.h
  string: use offset_in_page() in sized_strscpy()

 include/linux/mm.h  | 2 +-
 include/vdso/page.h | 2 ++
 lib/string.c        | 3 ++-
 3 files changed, 5 insertions(+), 2 deletions(-)


base-commit: d067a83c8063d1bdcbd9af8e1326d846f85138b8


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

end of thread, other threads:[~2026-05-22 12:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21  9:06 [PATCH v2 0/2] mm/vdso: make offset_in_page() usable without linux/mm.h Thorsten Blum
2026-05-21  9:06 ` [PATCH v2 1/2] vdso: move offset_in_page() from linux/mm.h to vdso/page.h Thorsten Blum
2026-05-21  9:30   ` David Laight
2026-05-21 11:45     ` Thomas Gleixner
2026-05-21 11:15   ` Lorenzo Stoakes
2026-05-21 14:56     ` Lorenzo Stoakes
2026-05-21 18:34       ` Andy Shevchenko
2026-05-22 10:52         ` Lorenzo Stoakes
2026-05-22 12:18       ` Thorsten Blum
2026-05-21 14:03   ` Yury Norov
2026-05-21  9:06 ` [PATCH v2 2/2] string: use offset_in_page() in sized_strscpy() Thorsten Blum
2026-05-21 11:31   ` Lorenzo Stoakes
2026-05-21 13:47     ` Thorsten Blum
2026-05-21 14:53       ` Lorenzo Stoakes
2026-05-21 11:33 ` [PATCH v2 0/2] mm/vdso: make offset_in_page() usable without linux/mm.h Lorenzo Stoakes
2026-05-21 13:59 ` Yury Norov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox