From c920e7ddef197d523f30ae96f8ea81f25e726ecc Mon Sep 17 00:00:00 2001 From: David Gow Date: Fri, 1 Jul 2022 17:16:19 +0800 Subject: [PATCH] UPSTREAM: mm: Add PAGE_ALIGN_DOWN macro This is just the same as PAGE_ALIGN(), but rounds the address down, not up. Suggested-by: Dmitry Vyukov Signed-off-by: David Gow Acked-by: Andrew Morton Signed-off-by: Richard Weinberger Bug: 254721825 (cherry picked from commit 335e52c28cf9954d65b819cb68912fd32de3c844) Change-Id: I33bebcffbe4af3937e00243228b71d531b56e89d Signed-off-by: Andrey Konovalov --- include/linux/mm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index fa42ef44c466..4935f58c249e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -234,6 +234,9 @@ int __add_to_page_cache_locked(struct page *page, struct address_space *mapping, /* 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)