]> www.infradead.org Git - users/dwmw2/linux.git/commit
riscv: mm: Add memory hotplugging support
authorBjörn Töpel <bjorn@rivosinc.com>
Wed, 5 Jun 2024 11:40:49 +0000 (13:40 +0200)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 26 Jun 2024 15:42:42 +0000 (08:42 -0700)
commitc75a74f4ba19c904c0ae1e011ae2568449409ae4
tree336d96463b5d936968759a9406ab6b52643c5ac5
parent6e6c5e21b8cbe94b89d2e848afad4e6fe2a7abd8
riscv: mm: Add memory hotplugging support

For an architecture to support memory hotplugging, a couple of
callbacks needs to be implemented:

 arch_add_memory()
  This callback is responsible for adding the physical memory into the
  direct map, and call into the memory hotplugging generic code via
  __add_pages() that adds the corresponding struct page entries, and
  updates the vmemmap mapping.

 arch_remove_memory()
  This is the inverse of the callback above.

 vmemmap_free()
  This function tears down the vmemmap mappings (if
  CONFIG_SPARSEMEM_VMEMMAP is enabled), and also deallocates the
  backing vmemmap pages. Note that for persistent memory, an
  alternative allocator for the backing pages can be used; The
  vmem_altmap. This means that when the backing pages are cleared,
  extra care is needed so that the correct deallocation method is
  used.

 arch_get_mappable_range()
  This functions returns the PA range that the direct map can map.
  Used by the MHP internals for sanity checks.

The page table unmap/teardown functions are heavily based on code from
the x86 tree. The same remove_pgd_mapping() function is used in both
vmemmap_free() and arch_remove_memory(), but in the latter function
the backing pages are not removed.

Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20240605114100.315918-7-bjorn@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/mm/init.c