Re: [PATCH 13/15] mm/hmm: factor out pte and pmd handling to simplify hmm_vma_walk_pmd()

From: Jerome Glisse
Date: Wed Mar 21 2018 - 11:08:28 EST


On Tue, Mar 20, 2018 at 10:07:29PM -0700, John Hubbard wrote:
> On 03/19/2018 07:00 PM, jglisse@xxxxxxxxxx wrote:
> > From: Jérôme Glisse <jglisse@xxxxxxxxxx>
> >
> > No functional change, just create one function to handle pmd and one
> > to handle pte (hmm_vma_handle_pmd() and hmm_vma_handle_pte()).
> >
> > Signed-off-by: Jérôme Glisse <jglisse@xxxxxxxxxx>
> > Cc: Evgeny Baskakov <ebaskakov@xxxxxxxxxx>
> > Cc: Ralph Campbell <rcampbell@xxxxxxxxxx>
> > Cc: Mark Hairgrove <mhairgrove@xxxxxxxxxx>
> > Cc: John Hubbard <jhubbard@xxxxxxxxxx>
> > ---
> > mm/hmm.c | 174 +++++++++++++++++++++++++++++++++++++--------------------------
> > 1 file changed, 102 insertions(+), 72 deletions(-)
> >
> > diff --git a/mm/hmm.c b/mm/hmm.c
> > index 52cdceb35733..dc703e9c3a95 100644
> > --- a/mm/hmm.c
> > +++ b/mm/hmm.c
> > @@ -351,6 +351,99 @@ static int hmm_vma_walk_hole(unsigned long addr,
> > return hmm_vma_walk->fault ? -EAGAIN : 0;
> > }
> >
> > +static int hmm_vma_handle_pmd(struct mm_walk *walk,
> > + unsigned long addr,
> > + unsigned long end,
> > + uint64_t *pfns,
>
> Hi Jerome,
>
> Nice cleanup, it makes it much easier to follow the code now.
>
> Let's please rename the pfns argument above to "pfn", because in this
> helper (and the _pte helper too), there is only one pfn involved, rather
> than an array of them.

This is only true to handle_pte, for handle_pmd it will go over several
pfn entries. But they will all get fill with same value modulo pfn which
will increase monotically (ie same flag as pmd permissions apply to all
entries).

Note sure s/pfns/pfn for hmm_vma_handle_pte() warrant a respin.

Cheers,
Jérôme