Re: [PATCH] mm: zswap: shrink until can accept

From: Johannes Weiner
Date: Fri May 26 2023 - 09:56:25 EST


On Fri, May 26, 2023 at 12:18:21PM +0200, Vitaly Wool wrote:
> On Wed, May 24, 2023 at 8:50 AM Domenico Cerasuolo
> > @@ -587,9 +587,13 @@ static void shrink_worker(struct work_struct *w)
> > {
> > struct zswap_pool *pool = container_of(w, typeof(*pool),
> > shrink_work);
> > + int ret;
> >
> > - if (zpool_shrink(pool->zpool, 1, NULL))
> > - zswap_reject_reclaim_fail++;
> > + do {
> > + ret = zpool_shrink(pool->zpool, 1, NULL);
> > + if (ret)
> > + zswap_reject_reclaim_fail++;
> > + } while (!zswap_can_accept() && ret != -EINVAL);
> > zswap_pool_put(pool);
> > }
>
> while I do agree with your points, I have a concern about this
> shrinker logic change. The reason for not doing this as you do was
> possible real time/responsiveness characteristics degrade. Have you
> checked that it's not really the case?

Good point. Adding a cond_resched() to the loop would be a good idea.