From: David Laight <david.laight.linux@gmail.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: "Garg, Shivank" <shivankg@amd.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H . Peter Anvin" <hpa@zytor.com>,
Ankur Arora <ankur.a.arora@oracle.com>,
Bharata B Rao <bharata@amd.com>,
Hrushikesh Salunke <hsalunke@amd.com>,
David Rientjes <rientjes@google.com>,
sandipan.das@amd.com
Subject: Re: [RFC PATCH 1/1] mm: batch page copies in folio_copy() and folio_mc_copy()
Date: Mon, 18 May 2026 15:20:38 +0100 [thread overview]
Message-ID: <20260518152038.7d959f39@pumpkin> (raw)
In-Reply-To: <60fb497d-a35a-42b9-8bf1-7f9ccbde8ade@kernel.org>
On Mon, 18 May 2026 10:43:22 +0200
"David Hildenbrand (Arm)" <david@kernel.org> wrote:
...
> > Another option is to leave memcpy() untouched for this series and add
> > a new copy_pages() helper that the folio copy path can use. It would
> > use ALTERNATIVE_2 that picks rep movsb on ERMS/FSRM and rep movsq on
> > REP_GOOD and per-page copy_page() loop as the final fallback.
>
> That would fit the clear_pages() design we have. But if that's avoidable, that
> would be nice.
>
For full pages 'rep movsq' is likely to be 'almost the best' on all cpu.
The fixed overhead is amortised over a lot of copies so has little impact.
(My brain suggests a value of 30 clocks - ignoring P4 netburst.)
For Intel cpu the aligned destination will double throughput.
I did a load of benchmarking of 'rep movsb' on my Zen-5.
(I should be able to find the results again.)
The real oddity was copies where (something like):
0 < (dst - src) & 4095 < 128
when the startup time was a lot longer and the copy ran massively slower.
I need to run those tests on some other cpu.
However I don't have any older AMD ones (except a piledriver) or Intel
ones newer than an i7-7 (Kaby lake?).
(I need to get my Apollo Lake N3350 into the test set for comparison.)
From what I remember of some earlier benchmarking (which failed to
measure the fixed cost properly) even Sandy bridge handles 'rep movsb'
and 'rep movsq' the same way.
The problem with memcpy() is you want a hint from the source about the
likely length and any alignment assumptions.
Otherwise the costs of the conditionals become significant.
-- David
next prev parent reply other threads:[~2026-05-18 14:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 14:20 [RFC PATCH 0/1] batch page copies in folio_copy() and folio_mc_copy() Shivank Garg
2026-04-27 14:20 ` [RFC PATCH 1/1] mm: " Shivank Garg
2026-05-12 9:31 ` David Hildenbrand (Arm)
2026-05-14 5:17 ` Garg, Shivank
2026-05-18 8:43 ` David Hildenbrand (Arm)
2026-05-18 14:20 ` David Laight [this message]
2026-05-19 5:43 ` Garg, Shivank
2026-05-18 16:01 ` Borislav Petkov
2026-05-19 7:44 ` Garg, Shivank
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=20260518152038.7d959f39@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=ankur.a.arora@oracle.com \
--cc=bharata@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=hpa@zytor.com \
--cc=hsalunke@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=sandipan.das@amd.com \
--cc=shivankg@amd.com \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.