mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Garg, Shivank" <shivankg@amd.com>
To: David Laight <david.laight.linux@gmail.com>,
	"David Hildenbrand (Arm)" <david@kernel.org>
Cc: 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: Tue, 19 May 2026 11:13:16 +0530	[thread overview]
Message-ID: <5753f479-e3c9-47bb-8549-b87d217d93cc@amd.com> (raw)
In-Reply-To: <20260518152038.7d959f39@pumpkin>



On 5/18/2026 7:50 PM, David Laight wrote:
> 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.

Hi David,

I have not benchmarked the specific case you mentioned. I tested only the aligned case.
If you can share your benchmarking script or test-cases, I'm happy to run it across the AMD
microarchitectures I have access to.

Thanks,
Shivank









  reply	other threads:[~2026-05-19  5:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 14:20 [RFC PATCH 0/1] " 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
2026-05-19  5:43           ` Garg, Shivank [this message]
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=5753f479-e3c9-47bb-8549-b87d217d93cc@amd.com \
    --to=shivankg@amd.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.laight.linux@gmail.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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome