The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Uladzislau Rezki <urezki@gmail.com>
To: Shivam Kalra <shivamkalra98@zohomail.in>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Shivam Kalra via B4 Relay
	<devnull+shivamkalra98.zohomail.in@kernel.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Alice Ryhl <aliceryhl@google.com>,
	Danilo Krummrich <dakr@kernel.org>
Subject: Re: [PATCH v13 0/5] mm/vmalloc: free unused pages on vrealloc() shrink
Date: Mon, 18 May 2026 20:10:37 +0200	[thread overview]
Message-ID: <agtWHSdOiJ0hwsdE@milan> (raw)
In-Reply-To: <8d678cb6-9f96-47b8-a25a-b3a969976630@zohomail.in>

On Mon, May 18, 2026 at 04:29:11AM +0530, Shivam Kalra wrote:
> On 13/05/26 03:31, Andrew Morton wrote:
> > On Mon, 11 May 2026 13:47:28 +0530 Shivam Kalra via B4 Relay <devnull+shivamkalra98.zohomail.in@kernel.org> wrote:
> > 
> >> This series implements the TODO in vrealloc() to unmap and free unused
> >> pages when shrinking across a page boundary.
> > 
> > Thanks.  AI review asked a few questions.  Does anything here look
> > legitimate?
> > 
> > 	https://sashiko.dev/#/patchset/20260511-vmalloc-shrink-v13-0-643b7ec277a9@zohomail.in
> 
> Thanks for flagging this. I went through the Sashiko review, and,
> one of the findings is legitimate and needs a fix.
> 
> 1) Patch 3 - vmap() mappings with nr_pages == 0 (LEGITIMATE)
> This is correct. For vmap() areas created without VM_MAP_PUT_PAGES,
> nr_pages is never set and stays 0 (vm_struct is kzalloc'd). With the
> current patch, vread_iter() would compute size = 0 for these areas,
> skip them entirely, and zero-fill the region in /proc/kcore.
> 
> Ulad, this is the approach you suggested during v10 review [1]; we
> both checked whether nr_pages could be 0 and concluded it couldn't,
> but we only considered the VM_ALLOC (vmalloc) path. vmap() areas also
> have vm != NULL but never set nr_pages unless VM_MAP_PUT_PAGES is
> passed, which most callers don't use.
> 
> Since vrealloc() only operates on VM_ALLOC areas, I think we can
> scope the nr_pages path to just that:
> 	if (vm)
> 		/*
> 		 * For VM_ALLOC areas, use nr_pages rather than
> 		 * get_vm_area_size() because vrealloc() may shrink
> 		 * the mapping without updating area->size. Other
> 		 * mapping types (vmap, ioremap) don't set nr_pages.
> 		 */
> 		size = (vm->flags & VM_ALLOC) ?
> 			(vm->nr_pages << PAGE_SHIFT) :
> 			get_vm_area_size(vm);
> 	else
> 		size = va_size(va);
> Ulad, does this approach look right to you, or would you prefer to
> initialize nr_pages unconditionally in vmap() instead?
> 
> [1] https://lore.kernel.org/lkml/aeYBYqPSEJRC8mjh@milan/
>
Indeed, we missed that point regarding vmap() code. Checking VM_ALLOC
sounds correct to me.

--
Uladzislau Rezki

      reply	other threads:[~2026-05-18 18:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11  8:17 [PATCH v13 0/5] mm/vmalloc: free unused pages on vrealloc() shrink Shivam Kalra via B4 Relay
2026-05-11  8:17 ` [PATCH v13 1/5] mm/vmalloc: extract vm_area_free_pages() helper from vfree() Shivam Kalra via B4 Relay
2026-05-11  8:17 ` [PATCH v13 2/5] mm/vmalloc: use physical page count for vrealloc() grow-in-place check Shivam Kalra via B4 Relay
2026-05-11  8:17 ` [PATCH v13 3/5] mm/vmalloc: use physical page count in vread_iter() Shivam Kalra via B4 Relay
2026-05-11  8:17 ` [PATCH v13 4/5] mm/vmalloc: free unused pages on vrealloc() shrink Shivam Kalra via B4 Relay
2026-05-11  8:17 ` [PATCH v13 5/5] lib/test_vmalloc: add vrealloc test case Shivam Kalra via B4 Relay
2026-05-12 22:01 ` [PATCH v13 0/5] mm/vmalloc: free unused pages on vrealloc() shrink Andrew Morton
2026-05-17 22:59   ` Shivam Kalra
2026-05-18 18:10     ` Uladzislau Rezki [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=agtWHSdOiJ0hwsdE@milan \
    --to=urezki@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=devnull+shivamkalra98.zohomail.in@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shivamkalra98@zohomail.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox