Skip to content

Add apply_to_page_range_batch() and use it

Jeremy Fitzhardinge linux-mm lkml xen-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9mm: remove unused "token" argument from apply_to_page_range callback.arch/x86/xen/grant-table.c arch/x86/xen/mmu.c include/linux/mm.h +2 more+6 -100 replies
2/9mm: add apply_to_page_range_batch()include/linux/mm.h mm/memory.c+47 -162 replies
3/9ioremap: use apply_to_page_range_batch() for ioremap_page_range()lib/ioremap.c+22 -630 replies
4/9vmalloc: use plain pte_clear() for unmapsmm/vmalloc.c+2 -10 replies
5/9vmalloc: use apply_to_page_range_batch() for vunmap_page_range()mm/vmalloc.c+9 -440 replies
6/9vmalloc: use apply_to_page_range_batch() for vmap_page_range_noflush()mm/vmalloc.c+28 -620 replies
7/9vmalloc: use apply_to_page_range_batch() in alloc_vm_area()mm/vmalloc.c+4 -40 replies
8/9xen/mmu: use apply_to_page_range_batch() in xen_remap_domain_mfn_range()arch/x86/xen/mmu.c+12 -70 replies
9/9xen/grant-table: use apply_to_page_range_batch()arch/x86/xen/grant-table.c+18 -100 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/9] Add apply_to_page_range_batch() and use it

From: Jeremy Fitzhardinge <[email protected]>

I'm proposing this series for 2.6.38.

We've had apply_to_page_range() for a while, which is a general way to apply a function to ptes across a range of addresses - including allocating any missing parts of the pagetable as needed. This logic is replicated in a number of places throughout the kernel, but it hasn't been widely replaced by this function, partly because of concerns about the overhead of calling the function once per pte.

This series adds apply_to_page_range_batch() (and reimplements apply_to_page_range() in terms of it), which calls the pte operation function once per pte page, moving the inner loop into the callback function.

apply_to_page_range(_batch) also calls its callback with lazy mmu updates enabled, which allows batching of the operations in environments where this is beneficial (=virtualization). The only caveat this introduces is callbacks can't expect to immediately see the effects of the pte updates in memory.

Since this is effectively identical to the code in lib/ioremap.c and mm/vmalloc.c (twice!), I replace their open-coded variants. I'm sure there are others places in the kernel which could do with this (I only stumbled over ioremap by accident).

I also add a minor optimisation to vunmap_page_range() to use a plain pte_clear() rather than the more expensive and unnecessary ptep_get_and_clear().

Thanks,
J

Jeremy Fitzhardinge (9):
mm: remove unused "token" argument from apply_to_page_range callback.
mm: add apply_to_page_range_batch()
ioremap: use apply_to_page_range_batch() for ioremap_page_range()
vmalloc: use plain pte_clear() for unmaps
vmalloc: use apply_to_page_range_batch() for vunmap_page_range()
vmalloc: use apply_to_page_range_batch() for
vmap_page_range_noflush()
vmalloc: use apply_to_page_range_batch() in alloc_vm_area() xen/mmu: use apply_to_page_range_batch() in
xen_remap_domain_mfn_range()
xen/grant-table: use apply_to_page_range_batch()

 arch/x86/xen/grant-table.c |   30 +++++----
 arch/x86/xen/mmu.c         |   18 +++--
 include/linux/mm.h         |    9 ++-
 lib/ioremap.c              |   85 +++++++------------------
 mm/memory.c                |   57 ++++++++++++-----
 mm/vmalloc.c               |  150 ++++++++++++--------------------------------
 6 files changed, 140 insertions(+), 209 deletions(-)
Signature · 1 line
1.7.3.3