mbox series

[v2,0/2] riscv: Enable percpu page first chunk allocator

Message ID 20231212213457.132605-1-alexghiti@rivosinc.com (mailing list archive)
Headers show
Series riscv: Enable percpu page first chunk allocator | expand

Message

Alexandre Ghiti Dec. 12, 2023, 9:34 p.m. UTC
While working with pcpu variables, I noticed that riscv did not support
first chunk allocation in the vmalloc area which may be needed as a fallback
in case of a sparse NUMA configuration.

patch 1 starts by introducing a new function flush_cache_vmap_early() which
is needed since a new vmalloc mapping is established and directly accessed:
on riscv, this would likely fail in case of a reordered access or if the
uarch caches invalid entries in TLB.
Note that most architectures do not include asm-generic/cacheflush.h so to
avoid build failures, this patch implements the new function on each of
those architectures. For all architectures except riscv, this new function
is implemented as a no-op to keep the existing behaviour but it likely
needs another implementation.

patch 2 simply enables the page percpu first chunk allocator in riscv.

Changes in v2:
- Rebase on top of 6.7
- Define flush_cache_vmap_early() for all architectures that do
  not include <asm-generic/cacheflush.h> to avoid build failures

Alexandre Ghiti (2):
  mm: Introduce flush_cache_vmap_early()
  riscv: Enable pcpu page first chunk allocator

 arch/arc/include/asm/cacheflush.h      | 1 +
 arch/arm/include/asm/cacheflush.h      | 2 ++
 arch/csky/abiv1/inc/abi/cacheflush.h   | 1 +
 arch/csky/abiv2/inc/abi/cacheflush.h   | 1 +
 arch/m68k/include/asm/cacheflush_mm.h  | 1 +
 arch/mips/include/asm/cacheflush.h     | 2 ++
 arch/nios2/include/asm/cacheflush.h    | 1 +
 arch/parisc/include/asm/cacheflush.h   | 1 +
 arch/riscv/Kconfig                     | 2 ++
 arch/riscv/include/asm/cacheflush.h    | 3 ++-
 arch/riscv/include/asm/tlbflush.h      | 1 +
 arch/riscv/mm/kasan_init.c             | 8 ++++++++
 arch/riscv/mm/tlbflush.c               | 5 +++++
 arch/sh/include/asm/cacheflush.h       | 1 +
 arch/sparc/include/asm/cacheflush_32.h | 1 +
 arch/sparc/include/asm/cacheflush_64.h | 1 +
 arch/xtensa/include/asm/cacheflush.h   | 6 ++++--
 include/asm-generic/cacheflush.h       | 6 ++++++
 mm/percpu.c                            | 8 +-------
 19 files changed, 42 insertions(+), 10 deletions(-)

Comments

Dennis Zhou Dec. 14, 2023, 8:40 a.m. UTC | #1
Hello,

On Tue, Dec 12, 2023 at 10:34:55PM +0100, Alexandre Ghiti wrote:
> While working with pcpu variables, I noticed that riscv did not support
> first chunk allocation in the vmalloc area which may be needed as a fallback
> in case of a sparse NUMA configuration.
> 
> patch 1 starts by introducing a new function flush_cache_vmap_early() which
> is needed since a new vmalloc mapping is established and directly accessed:
> on riscv, this would likely fail in case of a reordered access or if the
> uarch caches invalid entries in TLB.
> Note that most architectures do not include asm-generic/cacheflush.h so to
> avoid build failures, this patch implements the new function on each of
> those architectures. For all architectures except riscv, this new function
> is implemented as a no-op to keep the existing behaviour but it likely
> needs another implementation.
> 
> patch 2 simply enables the page percpu first chunk allocator in riscv.
> 
> Changes in v2:
> - Rebase on top of 6.7
> - Define flush_cache_vmap_early() for all architectures that do
>   not include <asm-generic/cacheflush.h> to avoid build failures
> 
> Alexandre Ghiti (2):
>   mm: Introduce flush_cache_vmap_early()
>   riscv: Enable pcpu page first chunk allocator
> 
>  arch/arc/include/asm/cacheflush.h      | 1 +
>  arch/arm/include/asm/cacheflush.h      | 2 ++
>  arch/csky/abiv1/inc/abi/cacheflush.h   | 1 +
>  arch/csky/abiv2/inc/abi/cacheflush.h   | 1 +
>  arch/m68k/include/asm/cacheflush_mm.h  | 1 +
>  arch/mips/include/asm/cacheflush.h     | 2 ++
>  arch/nios2/include/asm/cacheflush.h    | 1 +
>  arch/parisc/include/asm/cacheflush.h   | 1 +
>  arch/riscv/Kconfig                     | 2 ++
>  arch/riscv/include/asm/cacheflush.h    | 3 ++-
>  arch/riscv/include/asm/tlbflush.h      | 1 +
>  arch/riscv/mm/kasan_init.c             | 8 ++++++++
>  arch/riscv/mm/tlbflush.c               | 5 +++++
>  arch/sh/include/asm/cacheflush.h       | 1 +
>  arch/sparc/include/asm/cacheflush_32.h | 1 +
>  arch/sparc/include/asm/cacheflush_64.h | 1 +
>  arch/xtensa/include/asm/cacheflush.h   | 6 ++++--
>  include/asm-generic/cacheflush.h       | 6 ++++++
>  mm/percpu.c                            | 8 +-------
>  19 files changed, 42 insertions(+), 10 deletions(-)
> 
> -- 
> 2.39.2
> 

Thanks for the quick v2. Applied to percpu#for-6.8.

Thanks,
Dennis
patchwork-bot+linux-riscv@kernel.org Jan. 20, 2024, 9:09 p.m. UTC | #2
Hello:

This series was applied to riscv/linux.git (fixes)
by Dennis Zhou <dennis@kernel.org>:

On Tue, 12 Dec 2023 22:34:55 +0100 you wrote:
> While working with pcpu variables, I noticed that riscv did not support
> first chunk allocation in the vmalloc area which may be needed as a fallback
> in case of a sparse NUMA configuration.
> 
> patch 1 starts by introducing a new function flush_cache_vmap_early() which
> is needed since a new vmalloc mapping is established and directly accessed:
> on riscv, this would likely fail in case of a reordered access or if the
> uarch caches invalid entries in TLB.
> Note that most architectures do not include asm-generic/cacheflush.h so to
> avoid build failures, this patch implements the new function on each of
> those architectures. For all architectures except riscv, this new function
> is implemented as a no-op to keep the existing behaviour but it likely
> needs another implementation.
> 
> [...]

Here is the summary with links:
  - [v2,1/2] mm: Introduce flush_cache_vmap_early()
    https://git.kernel.org/riscv/c/7a92fc8b4d20
  - [v2,2/2] riscv: Enable pcpu page first chunk allocator
    https://git.kernel.org/riscv/c/6b9f29b81b15

You are awesome, thank you!