[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <12fa0797-05ea-aede-eeae-826133f03499@redhat.com>
Date: Fri, 24 Sep 2021 12:11:15 +0200
From: David Hildenbrand <david@...hat.com>
To: Peter Xu <peterx@...hat.com>, linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org
Cc: Hugh Dickins <hughd@...gle.com>,
Liam Howlett <liam.howlett@...cle.com>,
Mike Rapoport <rppt@...ux.vnet.ibm.com>,
Alistair Popple <apopple@...dia.com>,
Matthew Wilcox <willy@...radead.org>,
Yang Shi <shy828301@...il.com>,
"Kirill A . Shutemov" <kirill@...temov.name>,
Jerome Glisse <jglisse@...hat.com>,
Miaohe Lin <linmiaohe@...wei.com>,
Andrea Arcangeli <aarcange@...hat.com>
Subject: Re: [PATCH v4 4/4] mm: Add zap_skip_check_mapping() helper
On 15.09.21 20:15, 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.
>
> Reviewed-by: Alistair Popple <apopple@...dia.com>
> Signed-off-by: Peter Xu <peterx@...hat.com>
> ---
> include/linux/mm.h | 16 +++++++++++++++-
> mm/memory.c | 29 ++++++-----------------------
> 2 files changed, 21 insertions(+), 24 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index d1126f731221..ed44f31615d9 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1721,10 +1721,24 @@ 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)
I agree with Hugh that the name of this helper is suboptimal.
What about inverting the conditions and getting
static inline bool should_zap_page()
{
...
}
The calling code is then
if (unlikely(!should_zap_page(details, page)))
continue;
I don't really like renaming "zap_mapping", again, because it's
contained within "struct zap_details" already.
Factoring this out into a helper sounds like a good idea to me. Clear
case of code de-duplication.
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists