From: David Hildenbrand <david@redhat.com>
To: Alistair Popple <apopple@nvidia.com>, Peter Xu <peterx@redhat.com>
Cc: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
"Kirill A . Shutemov" <kirill@shutemov.name>,
Jerome Glisse <jglisse@redhat.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Miaohe Lin <linmiaohe@huawei.com>, Yang Shi <shy828301@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
Mike Rapoport <rppt@linux.vnet.ibm.com>
Subject: Re: [PATCH v2 4/5] mm: Add zap_skip_check_mapping() helper
Date: Fri, 3 Sep 2021 09:07:23 +0200 [thread overview]
Message-ID: <072aa3aa-e4f8-96f0-50b5-92707404926d@redhat.com> (raw)
In-Reply-To: <2306207.EELmk4mpEQ@nvdebian>
On 03.09.21 03:50, Alistair Popple wrote:
> 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@redhat.com>
>>>> ---
>>>> 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.
I still don't see the need for a flag quite frankly. Just factor out the
checks we already have ... no change in behavior.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2021-09-03 7:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-02 20:17 [PATCH v2 0/5] mm: A few cleanup patches around zap, shmem and uffd Peter Xu
2021-09-02 20:17 ` [PATCH v2 1/5] mm/shmem: Unconditionally set pte dirty in mfill_atomic_install_pte Peter Xu
2021-09-03 7:42 ` David Hildenbrand
2021-09-03 20:00 ` Peter Xu
2021-09-03 20:02 ` David Hildenbrand
2021-09-02 20:17 ` [PATCH v2 2/5] mm: Clear vmf->pte after pte_unmap_same() returns Peter Xu
2021-09-08 1:12 ` Liam Howlett
2021-09-02 20:17 ` [PATCH v2 3/5] mm: Drop first_index/last_index in zap_details Peter Xu
2021-09-02 20:18 ` [PATCH v2 4/5] mm: Add zap_skip_check_mapping() helper Peter Xu
2021-09-03 0:58 ` Alistair Popple
2021-09-03 1:39 ` Peter Xu
2021-09-03 1:50 ` Alistair Popple
2021-09-03 7:07 ` David Hildenbrand [this message]
2021-09-02 20:18 ` [PATCH v2 5/5] mm: Add ZAP_FLAG_SKIP_SWAP and zap_flags Peter Xu
2021-09-03 7:25 ` David Hildenbrand
2021-09-03 7:31 ` David Hildenbrand
2021-09-08 0:43 ` Peter Xu
2021-09-08 0:35 ` [PATCH v2 0/5] mm: A few cleanup patches around zap, shmem and uffd Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=072aa3aa-e4f8-96f0-50b5-92707404926d@redhat.com \
--to=david@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=hughd@google.com \
--cc=jglisse@redhat.com \
--cc=kirill@shutemov.name \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).