1 From 7a71932d5676b7410ab64d149bad8bde6b0d8632 Mon Sep 17 00:00:00 2001
2 From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
3 Date: Mon, 8 Oct 2012 16:33:47 -0700
4 Subject: kpageflags: fix wrong KPF_THP on non-huge compound pages
6 From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
8 commit 7a71932d5676b7410ab64d149bad8bde6b0d8632 upstream.
10 KPF_THP can be set on non-huge compound pages (like slab pages or pages
11 allocated by drivers with __GFP_COMP) because PageTransCompound only
12 checks PG_head and PG_tail. Obviously this is a bug and breaks user space
13 applications which look for thp via /proc/kpageflags.
15 This patch rules out setting KPF_THP wrongly by additionally checking
16 PageLRU on the head pages.
18 Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
19 Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
20 Acked-by: David Rientjes <rientjes@google.com>
21 Reviewed-by: Fengguang Wu <fengguang.wu@intel.com>
22 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
23 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 fs/proc/page.c | 8 +++++++-
28 1 file changed, 7 insertions(+), 1 deletion(-)
32 @@ -115,7 +115,13 @@ u64 stable_page_flags(struct page *page)
33 u |= 1 << KPF_COMPOUND_TAIL;
36 - else if (PageTransCompound(page))
38 + * PageTransCompound can be true for non-huge compound pages (slab
39 + * pages or pages allocated by drivers with __GFP_COMP) because it
40 + * just checks PG_head/PG_tail, so we need to check PageLRU to make
41 + * sure a given page is a thp, not a non-huge compound page.
43 + else if (PageTransCompound(page) && PageLRU(compound_trans_head(page)))