Re: [PATCH 2/2] mm: devmap: refactor 1-based refcounting for ZONE_DEVICE pages

From: Dan Williams
Date: Mon Nov 18 2019 - 11:57:15 EST


On Sun, Nov 17, 2019 at 11:09 PM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
>
> On Thu, Nov 14, 2019 at 04:11:34PM -0800, John Hubbard wrote:
> > An upcoming patch changes and complicates the refcounting and
> > especially the "put page" aspects of it. In order to keep
> > everything clean, refactor the devmap page release routines:
> >
> > * Rename put_devmap_managed_page() to page_is_devmap_managed(),
> > and limit the functionality to "read only": return a bool,
> > with no side effects.
> >
> > * Add a new routine, put_devmap_managed_page(), to handle checking
> > what kind of page it is, and what kind of refcount handling it
> > requires.
> >
> > * Rename __put_devmap_managed_page() to free_devmap_managed_page(),
> > and limit the functionality to unconditionally freeing a devmap
> > page.
> >
> > This is originally based on a separate patch by Ira Weiny, which
> > applied to an early version of the put_user_page() experiments.
> > Since then, JÃrÃme Glisse suggested the refactoring described above.
>
> I can't say I'm a big fan of this as it adds a lot more inlined
> code to put_page, which has a lot of callsites. Can't we instead
> try to figure out a way to move away from the off by one refcounting?

That might be possible. David and I are discussing a pfn_online()
helper that might be a replacement for keeping ZONE_DEVICE pages out
of the page allocator rather than keeping their reference count
elevated.