public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Shivam Kalra <shivamkalra98@zohomail.in>
To: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Danilo Krummrich <dakr@kernel.org>
Subject: Re: [PATCH v7 2/6] mm/vmalloc: fix vrealloc() grow-in-place check
Date: Tue, 24 Mar 2026 16:47:04 +0530	[thread overview]
Message-ID: <9bf5d3f5-af3f-40ce-b7aa-35b105b8b772@zohomail.in> (raw)
In-Reply-To: <acJvIbXjeZdxBlH5@google.com>

On 24/03/26 16:31, Alice Ryhl wrote:
> On Tue, Mar 24, 2026 at 03:30:27PM +0530, Shivam Kalra via B4 Relay wrote:
>> From: Shivam Kalra <shivamkalra98@zohomail.in>
>>
>> Fix the grow-in-place check in vrealloc() to compare the requested size
>> against the actual physical page count (vm->nr_pages) rather than the
>> virtual area size (alloced_size, derived from get_vm_area_size()).
>>
>> The virtual reservation size (get_vm_area_size()) does not decrease when
>> pages are freed during a shrink operation. Consequently, without this fix,
>> a subsequent grow-in-place operation after a shrink would incorrectly
>> succeed and attempt to access freed pages. Correcting this check is a
>> prerequisite for the upcoming vrealloc() shrink functionality.
>>
>> Signed-off-by: Shivam Kalra <shivamkalra98@zohomail.in>
> 
> This commit is titled 'fix', but is it actually a fix for a bug that
> exists today? Or is it just a refactor to support the follow-up
> shrinking logic?
> 
> Alice
You're right, this is not a fix for a bug that exists today. Currently
get_vm_area_size() and vm->nr_pages << PAGE_SHIFT always return the same
value because no code frees tail pages from a live vmalloc allocation.

The two expressions only diverge once the shrink patch (patch 5/6) is
applied, which reduces nr_pages while keeping vm->size unchanged.

I'll retitle this to something like:

mm/vmalloc: base vrealloc() grow-in-place check on nr_pages

and rephrase the commit message to describe it as a preparatory change
rather than a fix.

Thanks for catching this.



  reply	other threads:[~2026-03-24 11:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 10:00 [PATCH v7 0/6] mm/vmalloc: free unused pages on vrealloc() shrink Shivam Kalra via B4 Relay
2026-03-24 10:00 ` [PATCH v7 1/6] mm/vmalloc: extract vm_area_free_pages() helper from vfree() Shivam Kalra via B4 Relay
2026-03-24 10:00 ` [PATCH v7 2/6] mm/vmalloc: fix vrealloc() grow-in-place check Shivam Kalra via B4 Relay
2026-03-24 11:01   ` Alice Ryhl
2026-03-24 11:17     ` Shivam Kalra [this message]
2026-03-24 10:00 ` [PATCH v7 3/6] mm/vmalloc: zero newly exposed memory on vrealloc() grow Shivam Kalra via B4 Relay
2026-03-24 10:00 ` [PATCH v7 4/6] mm/vmalloc: use READ_ONCE() for vmalloc nr_pages status readers Shivam Kalra via B4 Relay
2026-03-24 10:00 ` [PATCH v7 5/6] mm/vmalloc: free unused pages on vrealloc() shrink Shivam Kalra via B4 Relay
2026-03-24 10:00 ` [PATCH v7 6/6] lib/test_vmalloc: add vrealloc test case Shivam Kalra via B4 Relay
2026-03-25 14:45 ` [PATCH v7 0/6] mm/vmalloc: free unused pages on vrealloc() shrink Shivam Kalra

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=9bf5d3f5-af3f-40ce-b7aa-35b105b8b772@zohomail.in \
    --to=shivamkalra98@zohomail.in \
    --cc=akpm@linux-foundation.org \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=urezki@gmail.com \
    /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