1 From 7e467245bf5226db34c4b12d3cbacfa2f7a15a8b Mon Sep 17 00:00:00 2001
2 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
3 Date: Wed, 13 Aug 2014 12:32:02 +0530
4 Subject: powerpc/thp: Use ACCESS_ONCE when loading pmdp
6 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
8 commit 7e467245bf5226db34c4b12d3cbacfa2f7a15a8b upstream.
10 We would get wrong results in compiler recomputed old_pmd. Avoid
11 that by using ACCESS_ONCE
13 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 arch/powerpc/mm/hugepage-hash64.c | 4 +++-
19 1 file changed, 3 insertions(+), 1 deletion(-)
21 --- a/arch/powerpc/mm/hugepage-hash64.c
22 +++ b/arch/powerpc/mm/hugepage-hash64.c
23 @@ -84,7 +84,9 @@ int __hash_page_thp(unsigned long ea, un
24 * atomically mark the linux large page PMD busy and dirty
27 - old_pmd = pmd_val(*pmdp);
28 + pmd_t pmd = ACCESS_ONCE(*pmdp);
30 + old_pmd = pmd_val(pmd);
31 /* If PMD busy, retry the access */
32 if (unlikely(old_pmd & _PAGE_BUSY))