Re: [PATCH v2 4/5] mm: Add zap_skip_check_mapping() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday, 3 September 2021 11:39:32 AM AEST Peter Xu wrote:
> On Fri, Sep 03, 2021 at 10:58:53AM +1000, Alistair Popple wrote:
> > On Friday, 3 September 2021 6:18:19 AM AEST Peter Xu wrote:
> > > Use the helper for the checks.  Rename "check_mapping" into "zap_mapping"
> > > because "check_mapping" looks like a bool but in fact it stores the mapping
> > > itself.  When it's set, we check the mapping (it must be non-NULL).  When it's
> > > cleared we skip the check, which works like the old way.
> > >
> > > Move the duplicated comments to the helper too.
> > > 
> > > Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
> > > ---
> > >  include/linux/mm.h | 15 ++++++++++++++-
> > >  mm/memory.c        | 29 ++++++-----------------------
> > >  2 files changed, 20 insertions(+), 24 deletions(-)
> > > 
> > > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > > index 69259229f090..81e402a5fbc9 100644
> > > --- a/include/linux/mm.h
> > > +++ b/include/linux/mm.h
> > > @@ -1720,10 +1720,23 @@ extern void user_shm_unlock(size_t, struct ucounts *);
> > >   * Parameter block passed down to zap_pte_range in exceptional cases.
> > >   */
> > >  struct zap_details {
> > > -	struct address_space *check_mapping;	/* Check page->mapping if set */
> > > +	struct address_space *zap_mapping;	/* Check page->mapping if set */
> > >  	struct page *single_page;		/* Locked page to be unmapped */
> > >  };
> > >  
> > > +/*
> > > + * We set details->zap_mappings when we want to unmap shared but keep private
> > > + * pages. Return true if skip zapping this page, false otherwise.
> > > + */
> > > +static inline bool
> > > +zap_skip_check_mapping(struct zap_details *details, struct page *page)
> > > +{
> > > +	if (!details || !page)
> > > +		return false;
> > > +
> > > +	return details->zap_mapping != page_rmapping(page);
> > 
> > Shouldn't this check still be
> > details->zap_mapping && details->zap_mapping != page_rmapping(page)?
> > 
> > Previously we wouldn't skip zapping pages if even_cows == true (ie.
> > details->check_mapping == NULL). With this change the check when
> > even_cows == true becomes NULL != page_rmapping(page). Doesn't this mean we
> > will now skip zapping any pages with a mapping when even_cows == true?
> 
> Yes I think so.  Thanks for pointing that out, Alistair, I'll fix in v3.
> 
> But frankly I really think we should simply have that flag I used to introduce.
> It'll make everything much clearer.

Yeah, I think a flag would also be fine.

 - Alistair







[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux