Re: [PATCH] powerpc/mm: use _raw variant of page table accessors

From
Michael Ellerman <mpe@ellerman.id.au>
Date
2016-06-02 07:44:47
Reply to
Ram Pai, 2016-06-01
On Wed, 2016-06-01 at 15:13 -0700, Ram Pai wrote:
On Tue, May 31, 2016 at 04:29:42PM +0530, Aneesh Kumar K.V wrote:
quoted
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
index 71e9abced493..9db83b4e017d 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
@@ -31,7 +31,7 @@ static inline int pgd_huge(pgd_t pgd)
 	 * leaf pte for huge page
 	 */
 	if (radix_enabled())
-		return !!(pgd_val(pgd) & _PAGE_PTE);
+		return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE));
pgd_raw() will not do the endian swapping.
But instead cpu_to_be64(_PAGE_PTE) will now do the endian swapping. So does it
really optimize anything? i tend to think it just moves the endian
swapping overhead from one place to the other. no?
Is cpu_to_be64(constant) faster than cpu_to_be64(variable)  ?
Yes, the compiler will do it at compile time for constants, or anything it can
prove is a constant.

You can also see from the asm dump that Aneesh posted that it drastically
improves the generated code.

cheers
Thread (6 messages) 6 messages, 5 authors, last reply 2016-06-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help