linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/khugepaged: use round_{up,down}() for PMD alignment in madvise_collapse()
@ 2026-04-08  9:35 Ye Liu
  2026-04-08 10:34 ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 2+ messages in thread
From: Ye Liu @ 2026-04-08  9:35 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes
  Cc: Ye Liu, Zi Yan, Baolin Wang, Liam R. Howlett, Nico Pache,
	Ryan Roberts, Dev Jain, Barry Song, Lance Yang, linux-mm,
	linux-kernel

From: Ye Liu <liuye@kylinos.cn>

The PMD alignment in madvise_collapse() is currently implemented
using open-coded bitmask operations:

    (start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK
    end & HPAGE_PMD_MASK

Replace them with round_up() and round_down(), which express the
same alignment semantics more directly and match other PMD-alignment
code paths in khugepaged.

No functional change intended.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
 mm/khugepaged.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 1e2bff40d014..80d0b7136b58 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2835,8 +2835,8 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
 	mmgrab(mm);
 	lru_add_drain_all();
 
-	hstart = (start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
-	hend = end & HPAGE_PMD_MASK;
+	hstart = round_up(start, HPAGE_PMD_SIZE);
+	hend = round_down(end, HPAGE_PMD_SIZE);
 
 	for (addr = hstart; addr < hend; addr += HPAGE_PMD_SIZE) {
 		enum scan_result result = SCAN_FAIL;
-- 
2.43.0



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

end of thread, other threads:[~2026-04-08 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-08  9:35 [PATCH] mm/khugepaged: use round_{up,down}() for PMD alignment in madvise_collapse() Ye Liu
2026-04-08 10:34 ` David Hildenbrand (Arm)

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