All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] mm: Add PAGE_ALIGN_DOWN macro
@ 2022-06-30  7:47 ` David Gow
  0 siblings, 0 replies; 6+ messages in thread
From: David Gow @ 2022-06-30  7:47 UTC (permalink / raw)
  To: Vincent Whitchurch, Johannes Berg, Patricia Alfonso, Jeff Dike,
	Richard Weinberger, anton.ivanov, Dmitry Vyukov, Brendan Higgins,
	Andrew Morton, Andrey Konovalov, Andrey Ryabinin
  Cc: David Gow, kasan-dev, linux-um, LKML, Daniel Latypov, linux-mm,
	kunit-dev

This is just the same as PAGE_ALIGN(), but rounds the address down, not
up.

Suggested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
---

Please take this patch as part of the UML tree, along with patch #2,
thanks!

Changes since v2:
https://lore.kernel.org/lkml/20220527185600.1236769-1-davidgow@google.com/
- Add Andrew's Acked-by tag.

v2 was the first version of this patch (it having been introduced as
part of v2 of the UML/KASAN series).

There are almost certainly lots of places where this macro should be
used: just look for ALIGN_DOWN(..., PAGE_SIZE). I haven't gone through
to try to replace them all.

---
 include/linux/mm.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9f44254af8ce..9abe5975ad11 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -221,6 +221,9 @@ int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
 
+/* to align the pointer to the (prev) page boundary */
+#define PAGE_ALIGN_DOWN(addr) ALIGN_DOWN(addr, PAGE_SIZE)
+
 /* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */
 #define PAGE_ALIGNED(addr)	IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)
 
-- 
2.37.0.rc0.161.g10f37bed90-goog


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

end of thread, other threads:[~2022-06-30  8:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30  7:47 [PATCH v3 1/2] mm: Add PAGE_ALIGN_DOWN macro David Gow
2022-06-30  7:47 ` David Gow
2022-06-30  7:47 ` [PATCH v3 2/2] UML: add support for KASAN under x86_64 David Gow
2022-06-30  7:47   ` David Gow
2022-06-30  8:11   ` David Gow
2022-06-30  8:11     ` David Gow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.