From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Brendan Jackman <jackmanb@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Uladzislau Rezki <urezki@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/vmalloc: clarify why vmap_range_noflush() might sleep
Date: Mon, 8 Dec 2025 12:11:35 +0530 [thread overview]
Message-ID: <96aa9bf7-1f1d-4870-90d2-84d3d6d4254c@arm.com> (raw)
In-Reply-To: <20251208-b4-vmalloc-might_alloc-v1-1-94a9bb8ecb08@google.com>
On 08/12/25 10:49 AM, Brendan Jackman wrote:
> The only reason vmap_range_noflush() can sleep is because of pagetable
> allocations. This might_sleep() is accurate, but we have a more
> precise way to express this particular case, so help readers out by
> using that.
>
> Note that the actual GFP flags used to allocate here are arch-specific.
> But as long as GFP_PGTABLE_KERNEL includes blockable flags, it should
Currently GFP_PGTABLE_KERNEL does have a blocking flag via GFP_KERNEL.
#define GFP_PGTABLE_KERNEL (GFP_KERNEL | __GFP_ZERO)
#define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS)
#define __GFP_RECLAIM ((__force gfp_t)(___GFP_DIRECT_RECLAIM|___GFP_KSWAPD_RECLAIM))
> serve as a reasonable common-denominator here.
Agreed.
>
> This also ensures there is an fs_reclaim_acquire() even no pagetables
> are actually allocated, which could potentially do a better job at
> catching filesystem bugs.
Makes sense.
>
> ---
> Signed-off-by: Brendan Jackman <jackmanb@google.com>
> ---
> mm/vmalloc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index a53c7462671bdd896f95712af71398ffbe22fb80..ff1876588b94ec69168324e93399dbd117a6959a 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -305,7 +305,7 @@ static int vmap_range_noflush(unsigned long addr, unsigned long end,
> int err;
> pgtbl_mod_mask mask = 0;
>
> - might_sleep();
> + might_alloc(GFP_PGTABLE_KERNEL);
This will invariably add a might_sleep() and hence preserves the existing
behaviour besides adding fs_reclaim_acquire() which is an improvement.
> BUG_ON(addr >= end);
>
> start = addr;
>
> ---
> base-commit: ecc46e02e0abe025a6e840cba2d647f23fd1d721
> change-id: 20251208-b4-vmalloc-might_alloc-754a791e4e10
>
> Best regards,
Please add <asm-generic/pgalloc.h> in mm/vmalloc.c - otherwise it does not
get built as GFP_PGTABLE_KERNEL is not available. But otherwise LGTM.
After fixing the build.
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
next prev parent reply other threads:[~2025-12-08 6:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 5:19 Brendan Jackman
2025-12-08 6:41 ` Anshuman Khandual [this message]
2025-12-08 7:39 ` Brendan Jackman
2025-12-08 17:32 ` Uladzislau Rezki
2025-12-08 8:51 ` [syzbot ci] " syzbot ci
2025-12-09 2:56 ` Brendan Jackman
2025-12-09 1:10 ` [PATCH] " kernel test robot
2025-12-09 1:52 ` kernel test robot
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=96aa9bf7-1f1d-4870-90d2-84d3d6d4254c@arm.com \
--to=anshuman.khandual@arm.com \
--cc=akpm@linux-foundation.org \
--cc=jackmanb@google.com \
--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