On (22/10/27 11:27), Nhat Pham wrote: > + > +static int zs_zpool_shrink(void *pool, unsigned int pages, > + unsigned int *reclaimed) > +{ > + unsigned int total = 0; > + int ret = -EINVAL; > + > + while (total < pages) { > + ret = zs_reclaim_page(pool, 8); > + if (ret < 0) > + break; > + total++; > + } > + > + if (reclaimed) > + *reclaimed = total; > + > + return ret; > +} The name collides with shrinker callbacks (compaction). That's a bit confusing, took me some time. > @@ -482,6 +504,7 @@ static struct zpool_driver zs_zpool_driver = { > .malloc_support_movable = true, > .malloc = zs_zpool_malloc, > .free = zs_zpool_free, > + .shrink = zs_zpool_shrink, > .map = zs_zpool_map, > .unmap = zs_zpool_unmap, > .total_size = zs_zpool_total_size, > @@ -955,6 +978,21 @@ static int trylock_zspage(struct zspage *zspage) > return 0; > } [..] > +#ifdef CONFIG_ZPOOL > +static int zs_reclaim_page(struct zs_pool *pool, unsigned int retries) > +{ > + int i, obj_idx, ret = 0; > + unsigned long handle; > + struct zspage *zspage; > + struct page *page; > + enum fullness_group fullness; > + > + /* Lock LRU and fullness list */ > + spin_lock(&pool->lock); > + if (!pool->ops || !pool->ops->evict || list_empty(&pool->lru) || You don't need pool->lock for pool->ops/pool->ops->evict checks. But, more importantly, I don't understand why is it even checked here? Why do we use ops->evict? Why cannot we call into zsmalloc evict directly? All of these are statically defined in zsmalloc, just don't provide .shrink if !define CONFIG_ZPOOL? Under what circumstances zsmalloc can provide .shrink but no ->evict?