On 5/30/24 17:10, Josef Bacik wrote: > On Wed, May 29, 2024 at 08:00:41PM +0200, Bernd Schubert wrote: >> This is to have a numa aware vmalloc function for memory exposed to >> userspace. Fuse uring will allocate queue memory using this >> new function. >> >> Signed-off-by: Bernd Schubert <bschubert@xxxxxxx> >> cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> >> cc: linux-mm@xxxxxxxxx >> Acked-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> >> --- >> include/linux/vmalloc.h | 1 + >> mm/nommu.c | 6 ++++++ >> mm/vmalloc.c | 41 +++++++++++++++++++++++++++++++++++++---- >> 3 files changed, 44 insertions(+), 4 deletions(-) >> >> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h >> index 98ea90e90439..e7645702074e 100644 >> --- a/include/linux/vmalloc.h >> +++ b/include/linux/vmalloc.h >> @@ -141,6 +141,7 @@ static inline unsigned long vmalloc_nr_pages(void) { return 0; } >> extern void *vmalloc(unsigned long size) __alloc_size(1); >> extern void *vzalloc(unsigned long size) __alloc_size(1); >> extern void *vmalloc_user(unsigned long size) __alloc_size(1); >> +extern void *vmalloc_node_user(unsigned long size, int node) __alloc_size(1); >> extern void *vmalloc_node(unsigned long size, int node) __alloc_size(1); >> extern void *vzalloc_node(unsigned long size, int node) __alloc_size(1); >> extern void *vmalloc_32(unsigned long size) __alloc_size(1); >> diff --git a/mm/nommu.c b/mm/nommu.c >> index 5ec8f44e7ce9..207ddf639aa9 100644 >> --- a/mm/nommu.c >> +++ b/mm/nommu.c >> @@ -185,6 +185,12 @@ void *vmalloc_user(unsigned long size) >> } >> EXPORT_SYMBOL(vmalloc_user); >> >> +void *vmalloc_node_user(unsigned long size, int node) >> +{ >> + return __vmalloc_user_flags(size, GFP_KERNEL | __GFP_ZERO); >> +} >> +EXPORT_SYMBOL(vmalloc_node_user); >> + >> struct page *vmalloc_to_page(const void *addr) >> { >> return virt_to_page(addr); >> diff --git a/mm/vmalloc.c b/mm/vmalloc.c >> index 68fa001648cc..0ac2f44b2b1f 100644 >> --- a/mm/vmalloc.c >> +++ b/mm/vmalloc.c >> @@ -3958,6 +3958,25 @@ void *vzalloc(unsigned long size) >> } >> EXPORT_SYMBOL(vzalloc); >> >> +/** >> + * _vmalloc_node_user - allocate zeroed virtually contiguous memory for userspace >> + * on the given numa node >> + * @size: allocation size >> + * @node: numa node >> + * >> + * The resulting memory area is zeroed so it can be mapped to userspace >> + * without leaking data. >> + * >> + * Return: pointer to the allocated memory or %NULL on error >> + */ >> +static void *_vmalloc_node_user(unsigned long size, int node) >> +{ >> + return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END, >> + GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL, >> + VM_USERMAP, node, >> + __builtin_return_address(0)); >> +} >> + > > Looking at the rest of vmalloc it seems like adding an extra variant to do the > special thing is overkill, I think it would be fine to just have > > void *vmalloc_nod_user(unsigned long size, int node) > { > return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END, > GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL, > VM_USERMAP, node, > __builtin_return_address(0)); > } > > instead of creating a _vmalloc_node_user(). No issue with me either. I had done it like this as there are basically two caller wit the same flags - vmalloc_user(size, NUMA_NO_NODE) and the new vmalloc_node_user(size, node). > > Also as an aside, this is definitely being used by this series, but I think it > would be good to go ahead and send this by itself with just the explanation that > it's going to be used by the fuse iouring stuff later, that way you can get this > merged and continue working on the iouring part. Thanks for your advise, will submit it separately. If the for now used export is acceptable it would also help me, as we have back ports of these patches. > > This also goes for the other prep patches earlier this this series, but since > those are fuse related it's probably fine to just keep shipping them with this > series. Thanks, Thanks again for your help and reviews! Bernd