From: Ryan Roberts <ryan.roberts@arm.com>
To: David Hildenbrand <david@redhat.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 15:15:27 +0100 [thread overview]
Message-ID: <bb871b52-526a-d4aa-5249-6105bc06aaba@arm.com> (raw)
In-Reply-To: <b54e7885-3e49-150f-cf8a-36a880e5dfc9@redhat.com>
On 03/08/2023 15:10, David Hildenbrand wrote:
>>>
>>> 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.
OK. I'll rework with the 2 loop approach, assuming I can calculate the number of
free slots in the mmu_gather ahead of time.
>
>>>
>>>> +
>>>> + 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.
>
next prev parent reply other threads:[~2023-08-03 14:15 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
2023-08-03 14:15 ` Ryan Roberts [this message]
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=bb871b52-526a-d4aa-5249-6105bc06aaba@arm.com \
--to=ryan.roberts@arm.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--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=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