zsmalloc: add zpool_ops field to zs_pool to store evict handlers

This adds a new field to zs_pool to store evict handlers for writeback,
analogous to the zbud allocator.

Link: https://lkml.kernel.org/r/20221128191616.1261026-6-nphamcs@gmail.com
Signed-off-by: Nhat Pham <nphamcs@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Nhat Pham 2022-11-28 11:16:14 -08:00 committed by Andrew Morton
parent 64f768c6b3
commit bd0fded296
1 changed files with 10 additions and 1 deletions

View File

@ -242,6 +242,8 @@ struct zs_pool {
#ifdef CONFIG_ZPOOL
/* List tracking the zspages in LRU order by most recently added object */
struct list_head lru;
struct zpool *zpool;
const struct zpool_ops *zpool_ops;
#endif
#ifdef CONFIG_ZSMALLOC_STAT
@ -382,7 +384,14 @@ static void *zs_zpool_create(const char *name, gfp_t gfp,
* different contexts and its caller must provide a valid
* gfp mask.
*/
return zs_create_pool(name);
struct zs_pool *pool = zs_create_pool(name);
if (pool) {
pool->zpool = zpool;
pool->zpool_ops = zpool_ops;
}
return pool;
}
static void zs_zpool_destroy(void *pool)