[PATCH] zsmalloc: use copy_page for full page copy

Sergey Senozhatsky senozhatsky at chromium.org
Fri Oct 6 04:11:44 PDT 2023


On (23/10/06 14:02), Mark-PK Tsai wrote:
> Some architectures have implemented optimized
> copy_page for full page copying, such as arm.
> 
> On my arm platform, use the copy_page helper
> for single page copying is about 10 percent faster
> than memcpy.
> 
> Signed-off-by: Mark-PK Tsai <mark-pk.tsai at mediatek.com>

TIL

I've never heard of arm's copy_page() before. Is it really much
faster than memcpy()?

Reviewed-by: Sergey Senozhatsky <senozhatsky at chromium.org>


> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index c743ce7a5f49..b1c0dad7f4cf 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -1839,7 +1839,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
>  	 * Here, any user cannot access all objects in the zspage so let's move.
>  	 */
>  	d_addr = kmap_atomic(newpage);
> -	memcpy(d_addr, s_addr, PAGE_SIZE);
> +	copy_page(d_addr, s_addr);

I guess you can also look into patching zram_drv.c, which seem to have
at least one PAGE_SIZE memcpy().



More information about the linux-arm-kernel mailing list