powerpc/thp: Use ACCESS_ONCE when loading pmdp
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Wed, 13 Aug 2014 07:02:02 +0000 (12:32 +0530)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 13 Aug 2014 08:20:41 +0000 (18:20 +1000)
We would get wrong results in compiler recomputed old_pmd. Avoid
that by using ACCESS_ONCE

CC: <stable@vger.kernel.org>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/mm/hugepage-hash64.c

index 1fb609dcc49b27c34d33fb7711b0c32ed05b1c2b..5f5e6328c21c10f5a158d84f737ace3250602d61 100644 (file)
@@ -84,7 +84,9 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
         * atomically mark the linux large page PMD busy and dirty
         */
        do {
-               old_pmd = pmd_val(*pmdp);
+               pmd_t pmd = ACCESS_ONCE(*pmdp);
+
+               old_pmd = pmd_val(pmd);
                /* If PMD busy, retry the access */
                if (unlikely(old_pmd & _PAGE_BUSY))
                        return 0;