mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Garg, Shivank" <shivankg@amd.com>
To: "joannelkoong@gmail.com" <joannelkoong@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kmanaouil.dev@gmail.com" <kmanaouil.dev@gmail.com>,
	"rppt@kernel.org" <rppt@kernel.org>,
	"weixugc@google.com" <weixugc@google.com>,
	"byungchul@sk.com" <byungchul@sk.com>,
	"rakie.kim@sk.com" <rakie.kim@sk.com>,
	"vbabka@kernel.org" <vbabka@kernel.org>,
	"harry@kernel.org" <harry@kernel.org>,
	"ying.huang@linux.alibaba.com" <ying.huang@linux.alibaba.com>,
	"riel@surriel.com" <riel@surriel.com>,
	"david@kernel.org" <david@kernel.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"matthew.brost@intel.com" <matthew.brost@intel.com>,
	"surenb@google.com" <surenb@google.com>,
	"rientjes@google.com" <rientjes@google.com>,
	"kinseyho@google.com" <kinseyho@google.com>,
	"Rao, Bharata Bhasker" <bharata@amd.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"gourry@gourry.net" <gourry@gourry.net>,
	"ziy@nvidia.com" <ziy@nvidia.com>,
	"usama.arif@linux.dev" <usama.arif@linux.dev>,
	"dev.jain@arm.com" <dev.jain@arm.com>,
	"jannh@google.com" <jannh@google.com>,
	"liam@infradead.org" <liam@infradead.org>,
	"mhocko@suse.com" <mhocko@suse.com>,
	"ljs@kernel.org" <ljs@kernel.org>,
	"lance.yang@linux.dev" <lance.yang@linux.dev>,
	"joshua.hahnjy@gmail.com" <joshua.hahnjy@gmail.com>,
	"apopple@nvidia.com" <apopple@nvidia.com>,
	"fvdl@google.com" <fvdl@google.com>
Subject: Re: [PATCH v2 0/7] mm: batch rmap walks during large folio migration
Date: Wed, 11 Nov 2026 19:37:09 +0000	[thread overview]
Message-ID: <2ed65a57aaa676a59651abd671f18dc9b55f9195.camel@amd.com> (raw)
In-Reply-To: <CAJnrk1ZkhvyGLUyZrf_gA3XBv1XTfHArGOMgqr=5XbSCBJHz4Q@mail.gmail.com>

On Tue, 2026-11-10 at 16:08 -0800, Joanne Koong wrote:
> On Wed, Aug 12, 2026 at 9:24 PM Shivank Garg <shivankg@amd.com> wrote:
> > 
> > Migrating a PTE-mapped large folio currently walks the folio's rmap
> > one page at a time. It does so twice per migration:
> > 1. try_to_migrate_one(): Replace present PTEs with migration entries
> > 2. remove_migration_pte(): Restore migration entries to working PTEs.
> > 
> > For a folio with N contiguous PTEs, each walk repeats page_vma_mapped_walk()
> > and the associated operation per subpage of the folio. (256 iterations
> > for 1M folio).
> > 
> > This series enables both walks to process a batch of consecutive PTEs
> > that map the same large folio and do some refactoring and clean up on
> > the way.
> > 
> > Performance:
> > 
> > AMD EPYC ZEN 3, 2-socket system (1 node per socket).
> > move_pages() migrating 1 GB from node 0 -> node 1, throughput
> > in GB/s:
> >                        batch-         batch-restore
> > folio     vanilla       restore-only   + unmap         restore%   restore+unmap%
> > 4K        2.96±0.15     3.02±0.14      2.99±0.17         +2.2%    +1.0%
> > 64K       5.99±0.10     6.12±0.08      7.65±0.16         +2.2%   +27.7%
> > 256K      6.48±0.09     6.67±0.08      9.23±0.14         +2.9%   +42.4%
> > 1M        6.76±0.10     6.98±0.10      9.74±0.19         +3.1%   +44.0%
> > 2M       10.50±0.20    10.44±0.16     10.67±0.21         -0.5%    +1.6%
> > 
> > In plain migration, the folio copy itself dominates the cost, so these rmap walk
> > savings are only partly visible end-to-end.
> > 
> > When the folio copy is batched-copy and offloaded to DMA engine [1], the copy is
> > no longer the bottleneck and rmap-walk batching translates into much larger gains:
> > 
> > This series + [1], DMA Offload on PTDMA (DCBM), 16 channels:
> > 
> >                     batch-copy                      dcbm+restore
> > folio    vanilla    -offload(dcbm)  dcbm+restore    +unmap          (rmap batch impact)
> > 4K       3.05±0.13   2.76±0.11       2.77±0.12        2.74±0.09
> > 64K      5.85±0.11  10.66±0.27      11.56±1.45       17.55±0.56
> > 256K     6.26±0.08  13.64±2.73      13.68±0.16       34.76±0.57       (2.54x)
> > 1M       6.58±0.08  14.25±0.07      15.27±0.77       44.28±0.27       (3.11x)
> > 2M      10.61±0.24  65.26±0.96      65.25±1.65       65.66±0.87
> > 
> 
> Hi Shivank,
> 
> Are you planning to send a v3 of this series? My reason for asking is
> because batching the unmap also fixes an existing issue where when
> try_to_migrate_one() unmaps a PTE-mapped anon mTHP one PTE at a time,
> the folio looks partially mapped partway through and gets flagged for
> deferred split. My mTHP underused shrinker series [1] makes this more
> common since every underused mTHP split will now go through this path,
> which makes this bug a blocker for the series. More context can be
> found in [2], which was my attempt to fix this bug, but then David
> suggested we fix it in a better way by batching, and Zi pointed me to
> this series.
> 
> Thanks,
> Joanne
> 
> [1] https://lore.kernel.org/linux-mm/20261103212004.1356327-1-joannelkoong@gmail.com/
> [2] https://lore.kernel.org/linux-mm/20261109220958.2071687-1-joannelkoong@gmail.com/


Glad to hear this series helps your use case.

Yes, I'm working on v3. I slowed down on it because it depends on
Optimize anonymous large folio unmapping series [1], which hasn't been
merged yet.

If it helps, I can send v3 sooner, addressing the v2 comments, rebase
on the current tree, and split into unmap-side and restore-side series
for easier review.

[1] https://lore.kernel.org/linux-mm/20260924131106.1730494-1-dev.jain@arm.com/

Thanks,
Shivank

      reply	other threads:[~2026-11-11 19:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13  4:23 Shivank Garg
2026-08-13  4:23 ` [PATCH v2 1/7] mm: factor out generic PTE batch detection from swap_pte_batch() Shivank Garg
2026-08-13  9:57   ` David Hildenbrand (Arm)
2026-08-14  8:00     ` Garg, Shivank
2026-08-16  7:48       ` Garg, Shivank
2026-08-13  4:23 ` [PATCH v2 2/7] mm/migrate: factor out migration PTE construction Shivank Garg
2026-08-13  4:23 ` [PATCH v2 3/7] mm/migrate: split remove_migration_pte_hugetlb() out of remove_migration_pte() Shivank Garg
2026-08-19 11:24   ` Karim Manaouil
2026-08-19 17:49     ` Garg, Shivank
2026-08-13  4:23 ` [PATCH v2 4/7] mm/migrate: batch the restore-side migration rmap walk Shivank Garg
2026-08-13  4:23 ` [PATCH v2 5/7] mm/rmap: factor out migration PTE construction Shivank Garg
2026-08-13  4:23 ` [PATCH v2 6/7] mm/rmap: split try_to_migrate_hugetlb_one() out of try_to_migrate_one() Shivank Garg
2026-08-13  4:23 ` [PATCH v2 7/7] mm/rmap: batch the unmap of large folios in try_to_migrate_one() Shivank Garg
2026-08-17  9:14   ` Lance Yang
2026-08-18  8:55     ` Miaohe Lin
2026-08-18  9:20       ` Lance Yang
2026-08-19  9:05         ` Miaohe Lin
2026-08-19  9:42         ` Huang, Ying
2026-08-19  9:57           ` Lance Yang
2026-08-19 10:09           ` Garg, Shivank
2026-11-11  0:08 ` [PATCH v2 0/7] mm: batch rmap walks during large folio migration Joanne Koong
2026-11-11 19:37   ` Garg, Shivank [this message]

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=2ed65a57aaa676a59651abd671f18dc9b55f9195.camel@amd.com \
    --to=shivankg@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=bharata@amd.com \
    --cc=byungchul@sk.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=fvdl@google.com \
    --cc=gourry@gourry.net \
    --cc=harry@kernel.org \
    --cc=jannh@google.com \
    --cc=joannelkoong@gmail.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kinseyho@google.com \
    --cc=kmanaouil.dev@gmail.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=mhocko@suse.com \
    --cc=rakie.kim@sk.com \
    --cc=riel@surriel.com \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=ying.huang@linux.alibaba.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

all inboxes | Powered by JetHome®