Skip to contentSkip to conversation

mm/vmalloc: remove map_kernel_range

PATCH Nicholas Piggin 1 participant 2 messages Apr 1, 2021 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Excerpts from Nicholas Piggin's message of March 22, 2021 12:18 pm:

Quoted 5 lines

This is a shim around vmap_pages_range, get rid of it.

Move the main API comment from the _noflush variant to the normal variant, and make _noflush internal to mm/.

This requires a fix for nommu builds.
---

Fix "mm/vmalloc: remove map_kernel_range"

Fixes: "percpu.c:undefined reference to `vmap_pages_range_noflush'" on riscv nommu builds.

Previous code had a strange NOMMU implementation of map_kernel_range_noflush that came in with commit b554cb426a955 ("NOMMU: support SMP dynamic percpu_alloc") which would return success if the size was <= PAGE_SIZE, but that has no way of working on NOMMU because the page can not be mapped to the new start address even if there is only one of them. So change this code to always return failure.

NOMMU probably needs to take a closer look at what it does with percpu-vm.c and carve out a special case there if necessary rather than pretend vmap works.

---
 mm/internal.h | 9 +++++++++
 1 file changed, 9 insertions(+)
mm/internal.h +9 -0
index 6d3fd85ab866..ac5d1abfb739 100644
@@ -621,7 +621,16 @@ struct migration_target_control {
 /*
  * mm/vmalloc.c
  */
+#ifdef CONFIG_MMU
 int vmap_pages_range_noflush(unsigned long addr, unsigned long end,
                 pgprot_t prot, struct page **pages, unsigned int page_shift);
+#else
+static inline
+int vmap_pages_range_noflush(unsigned long addr, unsigned long end,
+                pgprot_t prot, struct page **pages, unsigned int page_shift)
+{
+	return -EINVAL;
+}
+#endif
 
 #endif	/* __MM_INTERNAL_H */
Signature · 1 line
2.23.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Re: [PATCH v2 4/5] mm/vmalloc: remove unmap_kernel_range

Excerpts from Nicholas Piggin's message of March 22, 2021 12:18 pm:

Quoted 4 lines

This is a shim around vunmap_range, get rid of it.

Move the main API comment from the _noflush variant to the normal variant, and make _noflush internal to mm/.

This requires a fix for nommu builds and a comment bug that sfr noticed.

---

Fix for "mm/vmalloc: remove unmap_kernel_range"

Fixes:

mm/vmalloc.c:425: warning: expecting prototype for vunmap_range_noflush(). Prototype was for vunmap_range() instead

percpu.c:undefined reference to vunmap_range_noflush on NOMMU builds

---
 mm/internal.h | 3 +++
 mm/vmalloc.c  | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
mm/internal.h +3 -0
index 8b20d5039b74..217fff7c7807 100644
@@ -632,6 +632,9 @@ int vmap_pages_range_noflush(unsigned long addr, unsigned long end,
 {
 	return -EINVAL;
 }
+static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
+{
+}
 #endif
 
 #endif	/* __MM_INTERNAL_H */
mm/vmalloc.c +1 -1
index 5423f6c1417f..f99c1bf714cd 100644
@@ -413,7 +413,7 @@ void vunmap_range_noflush(unsigned long start, unsigned long end)
 }
 
 /**
- * vunmap_range_noflush - unmap kernel virtual addresses
+ * vunmap_range - unmap kernel virtual addresses
  * @addr: start of the VM area to unmap
  * @end: end of the VM area to unmap (non-inclusive)
  *
Signature · 1 line
2.23.0