From: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx> Instead of doing quite so much macro trickery, just use functions. Signed-off-by: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx> --- include/linux/page-flags.h | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index c74b880a1b85..ac55f6c94c0a 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -163,6 +163,29 @@ static __always_inline struct page *CheckPageInit(struct page *page) return page; } +static __always_inline struct page *PagePolicyOnlyHead(struct page *page) +{ + CheckPageInit(page); + VM_BUG_ON_PGFLAGS(PageTail(page), page); + return page; +} + +static __always_inline +struct page *PagePolicyTailRead(struct page *page, bool modify) +{ + CheckPageInit(page); + VM_BUG_ON_PGFLAGS(modify && PageTail(page), page); + return compound_head(page); +} + +static __always_inline +struct page *PagePolicyNoCompound(struct page *page, bool modify) +{ + CheckPageInit(page); + VM_BUG_ON_PGFLAGS(modify && PageCompound(page), page); + return page; +} + /* * Page flag policies describe how each page flag is used for compound pages. * @@ -185,17 +208,11 @@ static __always_inline struct page *CheckPageInit(struct page *page) * PF_NO_COMPOUND: * The page flag is not used for compound pages. */ -#define PF_ANY(page, modify) CheckPageInit(page) -#define PF_HEAD(page, modify) compound_head(CheckPageInit(page)) -#define PF_ONLY_HEAD(page, modify) ({ \ - VM_BUG_ON_PGFLAGS(PageTail(page), page); \ - CheckPageInit(page); }) -#define PF_TAIL_READ(page, modify) ({ \ - VM_BUG_ON_PGFLAGS(modify && PageTail(page), page); \ - compound_head(CheckPageInit(page)); }) -#define PF_NO_COMPOUND(page, modify) ({ \ - VM_BUG_ON_PGFLAGS(modify && PageCompound(page), page); \ - CheckPageInit(page); }) +#define PF_ANY(page, modify) CheckPageInit(page) +#define PF_HEAD(page, modify) compound_head(CheckPageInit(page)) +#define PF_ONLY_HEAD(page, modify) PagePolicyOnlyHead(page) +#define PF_TAIL_READ(page, modify) PagePolicyTailRead(page, modify) +#define PF_NO_COMPOUND(page, modify) PagePolicyNoCompound(page, modify) /* * Macros to create function definitions for page flags -- 2.16.3