Re: [RFC PATCH 1/1] mm: mark folio accessed in minor fault

From: Matthew Wilcox
Date: Wed Dec 20 2023 - 23:09:47 EST


On Thu, Dec 21, 2023 at 09:58:25AM +0800, Zhaoyang Huang wrote:
> On Wed, Dec 20, 2023 at 10:14 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
> >
> > On Wed, Dec 20, 2023 at 06:29:48PM +0800, zhaoyang.huang wrote:
> > > From: Zhaoyang Huang <zhaoyang.huang@xxxxxxxxxx>
> > >
> > > Inactive mapped folio will be promoted to active only when it is
> > > scanned in shrink_inactive_list, while the vfs folio will do this
> > > immidiatly when it is accessed. These will introduce two affections:
> > >
> > > 1. NR_ACTIVE_FILE is not accurate as expected.
> > > 2. Low reclaiming efficiency caused by dummy nactive folio which should
> > > be kept as earlier as shrink_active_list.
> > >
> > > I would like to suggest mark the folio be accessed in minor fault to
> > > solve this situation.
> >
> > This isn't going to be as effective as you imagine. Almost all file
> > faults are handled through filemap_map_pages(). So I must ask, what
> > testing have you done with this patch?
> >
> > And while you're gathering data, what effect would this patch have on your
> > workloads?
> Thanks for heads-up, I am out of date for readahead mechanism. My goal

It's not a terribly new mechanism ... filemap_map_pages() was added nine
years ago in 2014 by commit f1820361f83d

> is to have mapped file pages behave like other pages which could be
> promoted immediately when they are accessed. I will update the patch
> and provide benchmark data in new patch set.

Understood. I don't know the history of this, so I'm not sure if the
decision to not mark folios as accessed here was intentional or not.
I suspect it's entirely unintentional.

By the way, rather than inserting an explicit call to folio_set_accessed()
in filemap_fault(), change the filemap_get_folio() call to
__filemap_get_folio() and add FGP_ACCESSED to the fgp flags.