Skip to contentSkip to conversation

mm/page-flags: Check enforce parameter in PF_ONLY_HEAD()

PATCH In review Anshuman Khandual 2 participants 3 messages Mar 27, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/page-flags: Check enforce parameter in PF_ONLY_HEAD()

Just check for enforce parameter in PF_ONLY_HEAD() wrapper before calling VM_BUG_ON_PGFLAGS() for tail pages.

Fixes 62906027091f ("mm: add PageWaiters indicating tasks are waiting for a page bit")
---
 include/linux/page-flags.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/page-flags.h +1 -1
index 9f8712a4b1a5..82539e287bc6 100644
@@ -229,7 +229,7 @@ static inline void page_init_poison(struct page *page, size_t size)
 #define PF_ANY(page, enforce)	PF_POISONED_CHECK(page)
 #define PF_HEAD(page, enforce)	PF_POISONED_CHECK(compound_head(page))
 #define PF_ONLY_HEAD(page, enforce) ({					\
-		VM_BUG_ON_PGFLAGS(PageTail(page), page);		\
+		VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page);	\
 		PF_POISONED_CHECK(page); })
 #define PF_NO_TAIL(page, enforce) ({					\
 		VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page);	\
Signature · 1 line
2.20.1
#1 lore raw

[Cc Nick]

Quoted 2 lines · Anshuman Khandual

Just check for enforce parameter in PF_ONLY_HEAD() wrapper before calling VM_BUG_ON_PGFLAGS() for tail pages.

Why is this an actual fix? Only TESTPAGEFLAG doesn't enforce the check but I suspect that Nick just wanted the check to be _always_ performed as the name suggests. What kind of problem are you trying to solve?

Quoted 22 lines
Fixes 62906027091f ("mm: add PageWaiters indicating tasks are waiting for a page bit")
---
 include/linux/page-flags.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/page-flags.h +1 -1
index 9f8712a4b1a5..82539e287bc6 100644
@@ -229,7 +229,7 @@ static inline void page_init_poison(struct page *page, size_t size)
 #define PF_ANY(page, enforce)	PF_POISONED_CHECK(page)
 #define PF_HEAD(page, enforce)	PF_POISONED_CHECK(compound_head(page))
 #define PF_ONLY_HEAD(page, enforce) ({					\
-		VM_BUG_ON_PGFLAGS(PageTail(page), page);		\
+		VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page);	\
 		PF_POISONED_CHECK(page); })
 #define PF_NO_TAIL(page, enforce) ({					\
 		VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page);	\
Signature · 1 line
2.20.1
Signature · 2 lines
Michal Hocko
SUSE Labs
#2 lore raw
Quoted 8 lines · Michal Hocko

[Cc Nick]

Quoted 2 lines · Anshuman Khandual

Just check for enforce parameter in PF_ONLY_HEAD() wrapper before calling VM_BUG_ON_PGFLAGS() for tail pages.

Why is this an actual fix? Only TESTPAGEFLAG doesn't enforce the check but I suspect that Nick just wanted the check to be _always_ performed as the name suggests. What kind of problem are you trying to solve?

Did not hit any problem directly. Just from code inspection it seemed that the enforce check was missing as compared to other wrappers there. I felt that the commit could have probably omitted the check by mistake.