linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] mm: Add PAGE_ALIGN_DOWN macro
@ 2022-05-27 18:55 David Gow
  2022-05-27 18:56 ` [PATCH v2 2/2] UML: add support for KASAN under x86_64 David Gow
  2022-05-30  0:06 ` [PATCH v2 1/2] mm: Add PAGE_ALIGN_DOWN macro Andrew Morton
  0 siblings, 2 replies; 10+ messages in thread
From: David Gow @ 2022-05-27 18:55 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

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>
---

Note: there is no v1 of this patch, it's just 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 e34edb775334..e68731f0ef20 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.36.1.124.g0e6072fb45-goog


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

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

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 18:55 [PATCH v2 1/2] mm: Add PAGE_ALIGN_DOWN macro David Gow
2022-05-27 18:56 ` [PATCH v2 2/2] UML: add support for KASAN under x86_64 David Gow
2022-05-27 20:14   ` Johannes Berg
2022-05-29 17:55     ` Johannes Berg
2022-06-30  7:53     ` David Gow
2022-05-29 17:04   ` Johannes Berg
2022-06-30  7:53     ` David Gow
2022-05-30 18:03   ` Andrey Konovalov
2022-06-30  7:54     ` David Gow
2022-05-30  0:06 ` [PATCH v2 1/2] mm: Add PAGE_ALIGN_DOWN macro Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).