From: Uladzislau Rezki <urezki@gmail.com>
To: Shivam Kalra <shivamkalra98@zohomail.in>
Cc: Uladzislau Rezki <urezki@gmail.com>,
Alice Ryhl <aliceryhl@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Danilo Krummrich <dakr@kernel.org>
Subject: Re: [PATCH v10 0/4] mm/vmalloc: free unused pages on vrealloc() shrink
Date: Mon, 20 Apr 2026 12:35:14 +0200 [thread overview]
Message-ID: <aeYBYqPSEJRC8mjh@milan> (raw)
In-Reply-To: <20d2e9f5-9b4a-477d-b3a0-5a268364d70f@zohomail.in>
On Fri, Apr 17, 2026 at 11:04:21PM +0530, Shivam Kalra wrote:
> On 17/04/26 22:54, Uladzislau Rezki wrote:
> > 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
> I honestly don't know much about the usage
> of this function, so wanted to be cautious.
>
> 1. We can skip the usage of min though.
> 2. Do need (size_t) for overflow issue
>
> I can include this simple version with size_t,
> let me know your thoughts.
>
<snip>
if (vm)
/*
* Use the actual number of mapped pages, since realloc()
* may shrink the mapping and area->size may be outdated.
*/
size = vm->nr_pages << PAGE_SHIFT;
else
size = va_size(va);
<snip>
As for the cast to size_t, i think it is unnecessary. An overflow
can occur in either case. So let's keep it simple :)
--
Uladzislau Rezki
prev parent reply other threads:[~2026-04-20 10:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 8:36 [PATCH v10 0/4] mm/vmalloc: free unused pages on vrealloc() shrink Shivam Kalra
2026-04-04 8:36 ` Shivam Kalra via B4 Relay
2026-04-04 8:36 ` [PATCH v10 1/4] mm/vmalloc: extract vm_area_free_pages() helper from vfree() Shivam Kalra
2026-04-04 8:36 ` Shivam Kalra via B4 Relay
2026-04-04 8:36 ` [PATCH v10 2/4] mm/vmalloc: use physical page count for vrealloc() grow-in-place check Shivam Kalra
2026-04-04 8:36 ` Shivam Kalra via B4 Relay
2026-04-04 8:36 ` [PATCH v10 3/4] mm/vmalloc: free unused pages on vrealloc() shrink Shivam Kalra
2026-04-04 8:36 ` Shivam Kalra via B4 Relay
2026-04-04 8:37 ` [PATCH v10 4/4] lib/test_vmalloc: add vrealloc test case Shivam Kalra
2026-04-04 8:37 ` Shivam Kalra via B4 Relay
2026-04-14 8:39 ` [PATCH v10 0/4] mm/vmalloc: free unused pages on vrealloc() shrink Shivam Kalra
2026-04-14 16:57 ` Alice Ryhl
2026-04-15 18:44 ` Uladzislau Rezki
2026-04-16 7:38 ` Shivam Kalra
2026-04-17 13:35 ` Shivam Kalra
2026-04-17 17:24 ` Uladzislau Rezki
2026-04-17 17:34 ` Shivam Kalra
2026-04-20 10:35 ` 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=aeYBYqPSEJRC8mjh@milan \
--to=urezki@gmail.com \
--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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.