Re: [UPSTREAM KERNEL] mm/zsmalloc.c: Add module parameter malloc_force_movable
From: Sergey Senozhatsky
Date: Wed May 29 2019 - 03:27:55 EST
On (05/29/19 09:22), Hui Zhu wrote:
> When it enabled:
> ~# echo 1 > /sys/module/zsmalloc/parameters/malloc_force_movable
> ~# echo lz4 > /sys/module/zswap/parameters/compressor
> ~# echo zsmalloc > /sys/module/zswap/parameters/zpool
> ~# echo 1 > /sys/module/zswap/parameters/enabled
> ~# swapon /swapfile
[..]
> * We assign a page to ZS_ALMOST_EMPTY fullness group when:
> * n <= N / f, where
> @@ -1479,6 +1486,9 @@ unsigned long zs_malloc(struct zs_pool *pool, size_t size, gfp_t gfp)
> if (unlikely(!size || size > ZS_MAX_ALLOC_SIZE))
> return 0;
>
> + if (zs_malloc_force_movable)
> + gfp |= __GFP_HIGHMEM | __GFP_MOVABLE;
> +
> handle = cache_alloc_handle(pool, gfp);
> if (!handle)
> return 0;
It's zsmalloc user's responsibility to pass appropriate GFP mask
to zs_malloc().
Take a loot at ZRAM, for instance,
handle = zs_malloc(zram->mem_pool, comp_len,
__GFP_KSWAPD_RECLAIM |
__GFP_NOWARN |
__GFP_HIGHMEM |
__GFP_MOVABLE);
zsmalloc should not change GFP. If zswap, for some reason,
doesn't pass __GFP_MOVABLE, then I'd suggest to patch zswap.
-ss