linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/13] x86/mm: Add multi-page clearing
@ 2025-06-16  5:22 Ankur Arora
  2025-06-16  5:22 ` [PATCH v4 01/13] perf bench mem: Remove repetition around time measurement Ankur Arora
                   ` (14 more replies)
  0 siblings, 15 replies; 32+ messages in thread
From: Ankur Arora @ 2025-06-16  5:22 UTC (permalink / raw)
  To: linux-kernel, linux-mm, x86
  Cc: akpm, bp, dave.hansen, hpa, mingo, mjguzik, luto, peterz, acme,
	namhyung, tglx, willy, jon.grimm, bharata, raghavendra.kt,
	boris.ostrovsky, konrad.wilk, ankur.a.arora

This series adds multi-page clearing for hugepages, improving on the
current page-at-a-time approach in two ways:

 - amortizes the per-page setup cost over a larger extent
 - when using string instructions, exposes the real region size to the
   processor. A processor could use that as a hint to optimize based
   on the full extent size. AMD Zen uarchs, as an example, elide
   allocation of cachelines for regions larger than L3-size.

Demand faulting a 64GB region shows good performance improvements:

 $ perf bench mem map -p $page-size -f demand -s 64GB -l 5

                 mm/folio_zero_user    x86/folio_zero_user       change
                  (GB/s  +- %stdev)     (GB/s  +- %stdev)

  pg-sz=2MB       11.82  +- 0.67%        16.48  +-  0.30%       + 39.4%
  pg-sz=1GB       17.51  +- 1.19%        40.03  +-  7.26% [#]   +129.9%

[#] Only with preempt=full|lazy because cooperatively preempted models
need regular invocations of cond_resched(). This limits the extent
sizes that can be cleared as a unit.

Raghavendra also tested on AMD Genoa and that shows similar
improvements [1].

Series structure:

Patches 1-5, 8,
  "perf bench mem: Remove repetition around time measurement"
  "perf bench mem: Defer type munging of size to float"
  "perf bench mem: Move mem op parameters into a structure"
  "perf bench mem: Pull out init/fini logic"
  "perf bench mem: Switch from zalloc() to mmap()"
  "perf bench mem: Refactor mem_options"

refactor, and patches 6-7, 9
  "perf bench mem: Allow mapping of hugepages"
  "perf bench mem: Allow chunking on a memory region"
  "perf bench mem: Add mmap() workload"

add a few new perf bench mem workloads (chunking and mapping performance).

Patches 10-11,
  "x86/mm: Simplify clear_page_*"
  "x86/clear_page: Introduce clear_pages()"

inlines the ERMS and REP_GOOD implementations used from clear_page()
and adds clear_pages() to handle page extents.

And finally patches 12-13, allow an arch override to folio_zero_user()
and provide the x86 implementation that can do the actual multi-page
clearing.

  "mm: memory: allow arch override for folio_zero_user()"
  "x86/folio_zero_user: Add multi-page clearing"

Changelog:

v4:
 - adds perf bench workloads to exercise mmap() populate/demand-fault (Ingo)
 - inline stosb etc (PeterZ)
 - handle cooperative preemption models (Ingo)
 - interface and other cleanups all over (Ingo)

v3:
 - get rid of preemption dependency (TIF_ALLOW_RESCHED); this version
   was limited to preempt=full|lazy.
 - override folio_zero_user() (Linus)
 (https://lore.kernel.org/lkml/20250414034607.762653-1-ankur.a.arora@oracle.com/)

v2:
 - addressed review comments from peterz, tglx.
 - Removed clear_user_pages(), and CONFIG_X86_32:clear_pages()
 - General code cleanup
 (https://lore.kernel.org/lkml/20230830184958.2333078-1-ankur.a.arora@oracle.com/)

Comments appreciated!

Also at:
  github.com/terminus/linux clear-pages.v4

[1] https://lore.kernel.org/lkml/0d6ba41c-0c90-4130-896a-26eabbd5bd24@amd.com/

Ankur Arora (13):
  perf bench mem: Remove repetition around time measurement
  perf bench mem: Defer type munging of size to float
  perf bench mem: Move mem op parameters into a structure
  perf bench mem: Pull out init/fini logic
  perf bench mem: Switch from zalloc() to mmap()
  perf bench mem: Allow mapping of hugepages
  perf bench mem: Allow chunking on a memory region
  perf bench mem: Refactor mem_options
  perf bench mem: Add mmap() workload
  x86/mm: Simplify clear_page_*
  x86/clear_page: Introduce clear_pages()
  mm: memory: allow arch override for folio_zero_user()
  x86/folio_zero_user: Add multi-page clearing

 arch/x86/include/asm/page_32.h               |  18 +-
 arch/x86/include/asm/page_64.h               |  38 +-
 arch/x86/lib/clear_page_64.S                 |  39 +-
 arch/x86/mm/Makefile                         |   1 +
 arch/x86/mm/memory.c                         |  97 +++++
 mm/memory.c                                  |   5 +-
 tools/perf/bench/bench.h                     |   1 +
 tools/perf/bench/mem-functions.c             | 391 ++++++++++++++-----
 tools/perf/bench/mem-memcpy-arch.h           |   2 +-
 tools/perf/bench/mem-memcpy-x86-64-asm-def.h |   4 +
 tools/perf/bench/mem-memset-arch.h           |   2 +-
 tools/perf/bench/mem-memset-x86-64-asm-def.h |   4 +
 tools/perf/builtin-bench.c                   |   1 +
 13 files changed, 452 insertions(+), 151 deletions(-)
 create mode 100644 arch/x86/mm/memory.c

--
2.43.5

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2025-07-07 21:05 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16  5:22 [PATCH v4 00/13] x86/mm: Add multi-page clearing Ankur Arora
2025-06-16  5:22 ` [PATCH v4 01/13] perf bench mem: Remove repetition around time measurement Ankur Arora
2025-06-16  5:22 ` [PATCH v4 02/13] perf bench mem: Defer type munging of size to float Ankur Arora
2025-06-16  5:22 ` [PATCH v4 03/13] perf bench mem: Move mem op parameters into a structure Ankur Arora
2025-06-16  5:22 ` [PATCH v4 04/13] perf bench mem: Pull out init/fini logic Ankur Arora
2025-06-16  5:22 ` [PATCH v4 05/13] perf bench mem: Switch from zalloc() to mmap() Ankur Arora
2025-06-16  5:22 ` [PATCH v4 06/13] perf bench mem: Allow mapping of hugepages Ankur Arora
2025-06-16  5:22 ` [PATCH v4 07/13] perf bench mem: Allow chunking on a memory region Ankur Arora
2025-06-16  5:22 ` [PATCH v4 08/13] perf bench mem: Refactor mem_options Ankur Arora
2025-06-16  5:22 ` [PATCH v4 09/13] perf bench mem: Add mmap() workloads Ankur Arora
2025-06-16  5:22 ` [PATCH v4 10/13] x86/mm: Simplify clear_page_* Ankur Arora
2025-06-16 14:35   ` Dave Hansen
2025-06-16 14:38     ` Peter Zijlstra
2025-06-16 18:18     ` Ankur Arora
2025-06-16 16:48   ` kernel test robot
2025-06-16  5:22 ` [PATCH v4 11/13] x86/clear_page: Introduce clear_pages() Ankur Arora
2025-06-16  5:22 ` [PATCH v4 12/13] mm: memory: allow arch override for folio_zero_user() Ankur Arora
2025-06-16  5:22 ` [PATCH v4 13/13] x86/folio_zero_user: Add multi-page clearing Ankur Arora
2025-06-16 11:39   ` kernel test robot
2025-06-16 14:44   ` Dave Hansen
2025-06-16 14:50     ` Peter Zijlstra
2025-06-16 15:03       ` Dave Hansen
2025-06-16 18:20       ` Ankur Arora
2025-06-16 14:58     ` Matthew Wilcox
2025-06-16 18:47     ` Ankur Arora
2025-06-19 23:51       ` Ankur Arora
2025-06-16 15:06 ` [PATCH v4 00/13] x86/mm: " Dave Hansen
2025-06-16 18:25   ` Ankur Arora
2025-06-16 18:30     ` Dave Hansen
2025-06-16 18:43       ` Ankur Arora
2025-07-04  8:15 ` Raghavendra K T
2025-07-07 21:02   ` Ankur Arora

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).