From: David Hildenbrand <david@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-doc@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Jonathan Corbet <corbet@lwn.net>,
Mike Kravetz <mike.kravetz@oracle.com>,
Hugh Dickins <hughd@google.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Yin Fengwei <fengwei.yin@intel.com>,
Yang Shi <shy828301@gmail.com>, Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH mm-unstable v1] mm: add a total mapcount for large folios
Date: Fri, 11 Aug 2023 00:16:52 +0200 [thread overview]
Message-ID: <0ec6c371-c183-a8aa-614b-a23abbf3b233@redhat.com> (raw)
In-Reply-To: <ZNVPJ9xxd2oarR3I@x1n>
>> Okay, so your speculation right now is:
>>
>> 1) The change in cacheline might be problematic.
>>
>> 2) The additional atomic operation might be problematic.
>>
>>> then measure the split (by e.g. mprotect() at offset 1M on a 4K?) time it
>>> takes before/after this patch.
>>
>> I can certainly try getting some numbers on that. If you're aware of other
>> micro-benchmarks that would likely notice slower pte-mapping of THPs, please
>> let me know.
>
> Thanks.
If I effectively only measure the real PTE->PMD remapping (only measure
the for loop that mprotects() one 4k page inside each of 512 THPs )
without any of the mmap+populate+munmap, I can certainly measure a real
difference.
I briefly looked at some perf data across the overall benchmark runtime.
For page_remove_rmap(), the new atomic_dec() doesn't seem to be
significant. Data indicates that it's significantly less relevant than a
later atomic_add_negative().
For page_add_anon_rmap(), it's a bit fuzzy. Definitely, the
atomic_inc_return_relaxed(mapped) seems to stick out, but I cannot rule
out that the atomic_add() also plays a role.
The PTE->PMD remapping effectively does (__split_huge_pmd_locked())
for (i = 0, addr = haddr; i < HPAGE_PMD_NR; i++, addr += PAGE_SIZE) {
...
page_add_anon_rmap(page + i, vma, addr, RMAP_NONE);
...
}
...
page_remove_rmap(page, vma, true);
Inside that loop we're repeatedly accessing the total_mapcount and
_nr_pages_mapped. So my best guess would have been that both are already
hot in the cache.
RMAP batching certainly sounds like a good idea for
__split_huge_pmd_locked(), independent of this patch.
What would probably also interesting is observing happens when we unmap
a single PTE of a THP and we cannot batch, to see if the
page_remove_rmap() matters in the bigger scale.
I'll do some more digging tomorrow to clarify some details. Running some
kernel compile tests with thp=always at least didn't reveal any
surprises so far.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-08-10 22:16 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 8:32 David Hildenbrand
2023-08-09 15:45 ` Zi Yan
2023-08-09 19:07 ` Ryan Roberts
2023-08-09 19:17 ` David Hildenbrand
2023-08-10 10:40 ` Ryan Roberts
2023-08-10 11:14 ` David Hildenbrand
2023-08-10 11:27 ` David Hildenbrand
2023-08-10 11:32 ` David Hildenbrand
2023-08-10 11:35 ` Ryan Roberts
2023-08-09 19:21 ` Matthew Wilcox
2023-08-09 19:26 ` David Hildenbrand
2023-08-10 3:14 ` Yin Fengwei
2023-08-09 21:23 ` Peter Xu
2023-08-10 3:25 ` Matthew Wilcox
2023-08-10 8:37 ` David Hildenbrand
2023-08-10 21:48 ` Peter Xu
2023-08-10 21:54 ` Matthew Wilcox
2023-08-10 21:59 ` David Hildenbrand
2023-08-11 15:03 ` Peter Xu
2023-08-11 15:14 ` Zi Yan
2023-08-11 15:17 ` David Hildenbrand
2023-08-10 8:59 ` David Hildenbrand
2023-08-10 10:48 ` Ryan Roberts
2023-08-10 17:15 ` Peter Xu
2023-08-10 17:47 ` David Hildenbrand
2023-08-10 19:02 ` Ryan Roberts
2023-08-10 20:57 ` Peter Xu
2023-08-10 21:48 ` Matthew Wilcox
2023-08-10 22:27 ` David Hildenbrand
2023-08-11 15:18 ` Peter Xu
2023-08-11 15:32 ` David Hildenbrand
2023-08-11 15:58 ` Peter Xu
2023-08-11 16:08 ` David Hildenbrand
2023-08-11 16:11 ` Zi Yan
2023-08-11 22:18 ` Peter Xu
2023-08-10 22:16 ` David Hildenbrand [this message]
2023-08-10 3:24 ` Yin Fengwei
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=0ec6c371-c183-a8aa-614b-a23abbf3b233@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=fengwei.yin@intel.com \
--cc=hughd@google.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=peterx@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--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