Re: [PATCH 1/8] mm: implement cleancache

From: Suren Baghdasaryan
Date: Fri Oct 10 2025 - 10:54:20 EST


On Thu, Oct 9, 2025 at 7:39 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> On Thu, Oct 09, 2025 at 06:19:44PM -0700, Suren Baghdasaryan wrote:
> > + /*
> > + * 99% of the time, we don't need to flush the cleancache on the bdev.
> > + * But, for the strange corners, lets be cautious
> > + */
> > + cleancache_invalidate_inode(mapping, mapping->host);
>
> Why do we need to pass in both address_space and inode?

Ah, you mean why I don't use inode->i_mapping to get to its address
space? I think I can. I'll try, and unless something blows up, I'll
apply the change in the next version.

>
> > +/*
> > + * Backend API
> > + *
> > + * Cleancache does not touch page reference. Page refcount should be 1 when
> > + * page is placed or returned into cleancache and pages obtained from
> > + * cleancache will also have their refcount at 1.
>
> I don't like these references to page refcount. Surely you mean folio
> refcount?

Yes, mea culpa :) Will fix.

>
> > + help
> > + Cleancache can be thought of as a page-granularity victim cache
> > + for clean pages that the kernel's pageframe replacement algorithm
> > + (PFRA) would like to keep around, but can't since there isn't enough
>
> PFRA seems to be an acronym you've just made up. Why?

Inherited from the original cleancache documentation. Will remove.

>
> > +struct cleancache_inode {
> > + struct inode *inode;
> > + struct hlist_node hash;
> > + refcount_t ref_count;
> > + struct xarray folios; /* protected by folios.xa_lock */
>
> This is a pointless comment. All xarrays are protected by their own
> xa_lock.

Ack.

>
> > +static DEFINE_IDR(fs_idr);
>
> No. The IDR is deprecated. Use an allocating XArray.

Ah, good to know. I'll change to xarray.

>
> > +/*
> > + * Folio attributes:
> > + * folio->_mapcount - pool_id
> > + * folio->mapping - ccinode reference or NULL if folio is unused
> > + * folio->index - file offset
>
> No. Don't reuse fields for something entirely different. Put a
> properly named field in the union.

Ack.

>
> > +static void folio_attachment(struct folio *folio, struct cleancache_inode **ccinode,
>
> Unnecessarily long line

Ack.

Thanks for the feedback, Matthew!

>