From: David Hildenbrand <david@redhat.com>
To: Ryan Roberts <ryan.roberts@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Yin Fengwei <fengwei.yin@intel.com>, Yu Zhao <yuzhao@google.com>,
Yang Shi <shy828301@gmail.com>,
"Huang, Ying" <ying.huang@intel.com>, Zi Yan <ziy@nvidia.com>,
Nathan Chancellor <nathan@kernel.org>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v4 3/3] mm: Batch-zap large anonymous folio PTE mappings
Date: Thu, 3 Aug 2023 16:10:17 +0200 [thread overview]
Message-ID: <b54e7885-3e49-150f-cf8a-36a880e5dfc9@redhat.com> (raw)
In-Reply-To: <4255e71a-63c9-b2f9-5e97-e46834f7837c@arm.com>
>>
>> With this patch, you'll might suddenly have mapcount > refcount for a folio, or
>> am I wrong?
>
> Yes you would. Does that break things?
>
It is problematic whenever you want to check for additional page
references that are not from mappings (i.e., GUP refs/pins or anything else)
One example lives in KSM code (!compound only):
page_mapcount(page) + 1 + swapped != page_count(page)
Another one in compaction code:
if (!mapping && (folio_ref_count(folio) - 1) > folio_mapcount(folio))
And another one in khugepaged (is_refcount_suitable)
... and in THP split can_split_folio() (although that can deal with
false positives and false negatives).
We want to avoid detecting "no other references" if there *are* other
references. Detecting "there are other references" although there are
not is usually better.
Assume you have mapcount > refcount for some time due to concurrent
unmapping, AND some unrelated reference. You would suddenly pass these
checks (mapcount == refcount) and might not detect other references.
>>
>>> +
>>> + for (i = 0; i < nr_pages;) {
>>> + ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm);
>>> + tlb_remove_tlb_entry(tlb, pte, addr);
>>> + zap_install_uffd_wp_if_needed(vma, addr, pte, details, ptent);
>>> + full = __tlb_remove_page(tlb, page, 0);
>>> +
>>> + if (unlikely(page_mapcount(page) < 1))
>>> + print_bad_pte(vma, addr, ptent, page);
>>
>> Can we avoid new users of page_mapcount() outside rmap code, please? :)
>
> Sure. This is just trying to replicate the same diagnstics that's done on the
> non-batched path. I'm happy to remove it.
Spotted it afterwards in the existing code already, so you're effetively
not adding new ones.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-08-03 14:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 14:18 [PATCH v4 0/3] Optimize large folio interaction with deferred split Ryan Roberts
2023-07-27 14:18 ` [PATCH v4 1/3] mm: Allow deferred splitting of arbitrary large anon folios Ryan Roberts
2023-07-27 14:18 ` [PATCH v4 2/3] mm: Implement folio_remove_rmap_range() Ryan Roberts
2023-07-27 14:18 ` [PATCH v4 3/3] mm: Batch-zap large anonymous folio PTE mappings Ryan Roberts
2023-07-27 17:22 ` Yu Zhao
2023-07-28 9:16 ` Ryan Roberts
2023-08-01 7:12 ` Yu Zhao
2023-08-03 13:57 ` David Hildenbrand
2023-08-03 13:38 ` David Hildenbrand
2023-08-03 13:50 ` David Hildenbrand
2023-08-03 13:56 ` Ryan Roberts
2023-08-03 14:10 ` David Hildenbrand [this message]
2023-08-03 14:15 ` Ryan Roberts
2023-08-03 14:21 ` David Hildenbrand
2023-08-03 14:28 ` Zi Yan
2023-08-02 16:42 ` [PATCH v4 0/3] Optimize large folio interaction with deferred split Ryan Roberts
2023-08-02 17:02 ` Yu Zhao
2023-08-03 12:01 ` Kirill A. Shutemov
2023-08-03 12:48 ` Ryan Roberts
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=b54e7885-3e49-150f-cf8a-36a880e5dfc9@redhat.com \
--to=david@redhat.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=fengwei.yin@intel.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nathan@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
--cc=yuzhao@google.com \
--cc=ziy@nvidia.com \
/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).