Re: [PATCH] mm: zswap: support exclusive loads

From: Johannes Weiner
Date: Tue May 30 2023 - 19:54:55 EST


On Tue, May 30, 2023 at 09:02:51PM +0000, Yosry Ahmed wrote:
> @@ -216,8 +216,13 @@ int __frontswap_load(struct page *page)
>
> /* Try loading from each implementation, until one succeeds. */
> ret = frontswap_ops->load(type, offset, page);
> - if (ret == 0)
> + if (ret == 0) {
> inc_frontswap_loads();
> + if (frontswap_ops->exclusive_loads) {
> + SetPageDirty(page);
> + __frontswap_clear(sis, offset);
> + }

Somewhat tangential, but is there still a point to the frontswap
layer? It seems usecases other than zswap have never materialized, at
least not in tree. Life would be a lot easier if we were to just
hardcode the zswap callbacks in the swap functions.

It's not the patch's fault, but it highlights the boiler plate the
indirection causes. ->load() already has the page and could just dirty
it directly. Instead now both layers have to handle invalidation,
which is a vector for bugs.

Can somebody think of reasons to keep it? If not, I'd take a stab at
removing it.