mm-vmalloc-implement-vrealloc.patch removed from -mm tree
The quilt patch titled
Subject: mm: vmalloc: implement vrealloc()
has been removed from the -mm tree. Its filename was
mm-vmalloc-implement-vrealloc.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Danilo Krummrich <[email protected]>
Subject: mm: vmalloc: implement vrealloc()
Date: Mon, 22 Jul 2024 18:29:23 +0200
Patch series "Align kvrealloc() with krealloc()", v2.
Besides the obvious (and desired) difference between krealloc() and kvrealloc(), there is some inconsistency in their function signatures and behavior:
- krealloc() frees the memory when the requested size is zero, whereas kvrealloc() simply returns a pointer to the existing allocation.
- krealloc() behaves like kmalloc() if a NULL pointer is passed, whereas kvrealloc() does not accept a NULL pointer at all and, if passed, would fault instead.
- krealloc() is self-contained, whereas kvrealloc() relies on the caller to provide the size of the previous allocation.
Inconsistent behavior throughout allocation APIs is error prone, hence make kvrealloc() behave like krealloc(), which seems superior in all mentioned aspects.
In order to be able to get rid of kvrealloc()'s oldsize parameter, introduce vrealloc() and make use of it in kvrealloc().
Making use of vrealloc() in kvrealloc() also provides oppertunities to grow (and shrink) allocations more efficiently. For instance, vrealloc() can be optimized to allocate and map additional pages to grow the allocation or unmap and free unused pages to shrink the allocation.
Besides the above, those functions are required by Rust's allocator abstractons
[1] (rework based on this series in [2]). With Vec or KVec respectively, potentially growing (and shrinking) data structures are rather common.
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=rust/mm
This patch (of 2):
Implement vrealloc() analogous to krealloc().
Currently, krealloc() requires the caller to pass the size of the previous memory allocation, which, instead, should be self-contained.
We attempt to fix this in a subsequent patch which, in order to do so, requires vrealloc().
Besides that, we need realloc() functions for kernel allocators in Rust too. With Vec or KVec respectively, potentially growing (and shrinking) data structures are rather common.
---
include/linux/vmalloc.h | 4 ++ mm/nommu.c | 5 ++ mm/vmalloc.c | 70 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+)
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-vmalloc-implement-vrealloc +4 -0
@@ -189,6 +189,10 @@ extern void *__vcalloc_noprof(size_t n,extern void *vcalloc_noprof (size_t n,size_t size)__alloc_size(1, 2) ;#define vcalloc (...) alloc_hooks(vcalloc_noprof(__VA_ARGS__)) +void *__must_check vrealloc_noprof (const void *p,size_t size,gfp_t flags) +__realloc_size (2 ); +#define vrealloc (...) alloc_hooks(vrealloc_noprof(__VA_ARGS__)) +extern void vfree (const void *addr);extern void vfree_atomic (const void *addr);
mm/nommu.c renamed from mm/nommu.c~mm-vmalloc-implement-vrealloc +5 -0
@@ -126,6 +126,11 @@ void *__vmalloc_noprof(unsigned long siz }EXPORT_SYMBOL (__vmalloc_noprof); +void *vrealloc_noprof (const void *p,size_t size,gfp_t flags) +{ +return krealloc_noprof (p, size, (flags | __GFP_COMP) & ~__GFP_HIGHMEM); +} + void *__vmalloc_node_range_noprof(unsigned long size, unsigned long align, unsigned long start, unsigned long end, gfp_t gfp_mask, pgprot_t prot, unsigned long vm_flags, int node,
mm/vmalloc.c renamed from mm/vmalloc.c~mm-vmalloc-implement-vrealloc +70 -0
76 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
mm-krealloc-consider-spare-memory-for-__gfp_zero.patch mm-krealloc-clarify-valid-usage-of-__gfp_zero.patch