Re: [PATCH v10 0/4] mm/vmalloc: free unused pages on vrealloc() shrink

Uladzislau Rezki
2026-04-17T17:24:55Z

On Fri, Apr 17, 2026 at 07:05:09PM +0530, Shivam Kalra wrote:
> On 16/04/26 00:14, Uladzislau Rezki wrote:
> > Yep, the problem reported by Sashiko regarding area->size and vread_iter()
> > is correct. V10 does not address this.
> >
> > I am not sure that reducing vma size is a good approach here. It is
> > widely used and we might end up with fixing even more corner cases.
> >
> > vread_iter() and vm-size calculation there should be fixed.
> >
> > --
> > Uladzislau Rezki
> Proposed Change for v11:
>
> long vread_iter(struct iov_iter *iter, const char *addr, size_t count)
> {
> struct vmap_node *vn;
> struct vmap_area *va;
> struct vm_struct *vm;
> char *vaddr;
> <snip>
> vaddr = (char *) va->va_start;
> size = vm ? get_vm_area_size(vm) : va_size(va);
>
> if (vm && vm->nr_pages)
> size = min(size, (size_t)vm->nr_pages << PAGE_SHIFT);
>
> <snip>
>
I have some questions to clarify.

Why should we use min()?
Checking vm->nr_pages, can it be 0?

Can we just do:

if (vm)
/* Can not use get_vm_area_size() because of realloc(). */
size = vm->nr_pages << PAGE_SHIFT;
else
size = va_size(va);

or i am missing something?

Thanks!

--
Uladzislau Rezki