Re: [PATCH v2 20/25] powerpc32: Remove clear_pages() and define clear_page() inline

From: Joakim Tjernlund
Date: Tue Sep 22 2015 - 13:58:02 EST


Hi Christophe

Really nice patchset!

On Tue, 2015-09-22 at 18:51 +0200, Christophe Leroy wrote:
> clear_pages() is never used, and PPC32 is the only architecture
> (still) having this function. Neither PPC64 nor any other
> architecture has it.
>
> This patch removes clear_page() and move clear_page() function
> inline (same as PPC64) as it only is a few isns
>
> Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxx>
> ---
> No change in v2
>
> arch/powerpc/include/asm/page_32.h | 17 ++++++++++++++---
> arch/powerpc/kernel/misc_32.S | 16 ----------------
> arch/powerpc/kernel/ppc_ksyms_32.c | 1 -
> 3 files changed, 14 insertions(+), 20 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/page_32.h b/arch/powerpc/include/asm/page_32.h
> index 68d73b2..6a8e179 100644
> --- a/arch/powerpc/include/asm/page_32.h
> +++ b/arch/powerpc/include/asm/page_32.h
> @@ -1,6 +1,8 @@
> #ifndef _ASM_POWERPC_PAGE_32_H
> #define _ASM_POWERPC_PAGE_32_H
>
> +#include <asm/cache.h>
> +
> #if defined(CONFIG_PHYSICAL_ALIGN) && (CONFIG_PHYSICAL_START != 0)
> #if (CONFIG_PHYSICAL_START % CONFIG_PHYSICAL_ALIGN) != 0
> #error "CONFIG_PHYSICAL_START must be a multiple of CONFIG_PHYSICAL_ALIGN"
> @@ -36,9 +38,18 @@ typedef unsigned long long pte_basic_t;
> typedef unsigned long pte_basic_t;
> #endif
>
> -struct page;
> -extern void clear_pages(void *page, int order);
> -static inline void clear_page(void *page) { clear_pages(page, 0); }
> +/*
> + * Clear page using the dcbz instruction, which doesn't cause any
> + * memory traffic (except to write out any cache lines which get
> + * displaced). This only works on cacheable memory.
> + */
> +static inline void clear_page(void *addr)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < PAGE_SIZE / L1_CACHE_BYTES; i++, addr += L1_CACHE_BYTES)
> + dcbz(addr);
> +}

Does gcc manage to transform this into efficient asm?
Otherwise you could help gcc by using do { .. } while(--i); instead.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/