From: Wei Yang <richard.weiyang@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
akpm@linux-foundation.org, rppt@kernel.org, linux-mm@kvack.org,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH 4/4] mm/page_alloc: no need to ClearPageReserved on giving page to buddy system
Date: Sun, 30 Jun 2024 07:30:07 +0000 [thread overview]
Message-ID: <20240630073007.5iz2jubzd3ws3kn3@master> (raw)
In-Reply-To: <ZoA6QS-mOiQFOvc3@casper.infradead.org>
On Sat, Jun 29, 2024 at 05:45:53PM +0100, Matthew Wilcox wrote:
>On Sat, Jun 29, 2024 at 05:28:34PM +0100, Matthew Wilcox wrote:
>> On Sat, Jun 29, 2024 at 08:44:11AM +0000, Wei Yang wrote:
>> > Per my understanding, prefetchw() is trying to load data to cache before we
>> > really accessing it. By doing so, we won't hit a cache miss when we really
>> > need it.
>>
>> Yes, but the CPU can also do this by itself without needing an explicit
>> hint from software. It can notice that we have a loop that's accessing
>> successive cachelines for write. This is approximately the easiest
>> prefetcher to design.
This is my first intuition on reading the code, while I *believed* there is a
reason for the prefetchw() to be put here.
>
>I tracked down prefetchw() being added:
>
>commit 3b901ea58a56
>Author: Josh Aas <josha@sgi.com>
>Date: Mon Aug 23 21:26:54 2004 -0700
>
> [PATCH] improve speed of freeing bootmem
>
> Attached is a patch that greatly improves the speed of freeing boot memory.
> On ia64 machines with 2GB or more memory (I didn't test with less, but I
> can't imagine there being a problem), the speed improvement is about 75%
> for the function free_all_bootmem_core. This translates to savings on the
> order of 1 minute / TB of memory during boot time. That number comes from
> testing on a machine with 512GB, and extrapolating based on profiling of an
> unpatched 4TB machine. For 4 and 8 TB machines, the time spent in this
> function is about 1 minutes/TB, which is painful especially given that
> there is no indication of what is going on put to the console (this issue
> to possibly be addressed later).
>
> The basic idea is to free higher order pages instead of going through every
> single one. Also, some unnecessary atomic operations are done away with
> and replaced with non-atomic equivalents, and prefetching is done where it
> helps the most. For a more in-depth discusion of this patch, please see
> the linux-ia64 archives (topic is "free bootmem feedback patch").
>
>(quoting the entire commit message because it's buried in linux-fullhistory,
>being a pre-git patch). For the thread he's referring to, see
>https://lore.kernel.org/linux-ia64/40F46962.4090604@sgi.com/
>
Thanks for digging the ancient history. And now I know the linux-fullhistory tree
:-)
>Itanium CPUs of this era had no prefetchers.
Oops, so sad to hear it.
So it looks the most helpful change is:
* free higher order pages
* non-atomic equivalent
A quick test on my 6G qemu virtual machine shows the prefetchw() here seems
not helpful. After removal, the meminit process even a little bit faster. From
135ms to 121ms as the sum of 3 times bootup test.
If you think it is ok, I would wrap up one patch on current mm-stable for
more audience to review.
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2024-06-30 7:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-29 1:33 [PATCH 1/4] mm: use zonelist_zone() to get zone Wei Yang
2024-06-29 1:33 ` [PATCH 2/4] mm: not __SetPageReserved on initializing hot-plugged memory Wei Yang
2024-06-29 6:19 ` David Hildenbrand
2024-06-29 8:32 ` Wei Yang
2024-06-29 14:38 ` David Hildenbrand
2024-06-30 7:32 ` Wei Yang
2024-06-29 1:33 ` [PATCH 3/4] mm/page_alloc: put __free_pages_core() in __meminit section Wei Yang
2024-06-29 1:33 ` [PATCH 4/4] mm/page_alloc: no need to ClearPageReserved on giving page to buddy system Wei Yang
2024-06-29 3:21 ` Matthew Wilcox
2024-06-29 8:44 ` Wei Yang
2024-06-29 16:28 ` Matthew Wilcox
2024-06-29 16:45 ` Matthew Wilcox
2024-06-30 7:30 ` Wei Yang [this message]
[not found] ` <4a93f7b7-8ba8-4877-99c7-1048674d074d@redhat.com>
[not found] ` <299a4d6a-6b76-49b7-be2e-573cd66fd46f@redhat.com>
2024-06-29 8:48 ` Wei Yang
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=20240630073007.5iz2jubzd3ws3kn3@master \
--to=richard.weiyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
--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