* [PATCH] smb: client: use kvzalloc() for megabyte buffer in simple fallocate
@ 2026-07-12 2:54 Fredric Cover
2026-07-12 16:02 ` Steve French
0 siblings, 1 reply; 2+ messages in thread
From: Fredric Cover @ 2026-07-12 2:54 UTC (permalink / raw)
To: sfrench
Cc: pc, ronniesahlberg, sprasad, tom, bharathsm, linux-cifs,
linux-kernel, Fredric Cover, stable
From: Fredric Cover <fredric.cover.lkernel@gmail.com>
Currently in smb3_simple_fallocate_range(), a 1 MB buffer is allocated
using kzalloc(). Under heavy memory fragmentation, a contiguous 1 MB block
of physical memory (an order-8 allocation) may not be available,
causing the allocation to fail.
This failure was observed during xfstests generic/013 on a 4GB RAM
test machine running fsstress:
fsstress: page allocation failure: order:8,
mode:0x40dc0(GFP_KERNEL|__GFP_ZERO|__GFP_COMP),
nodemask=(null),cpuset=/,mems_allowed=0
Call Trace:
<TASK>
dump_stack_lvl+0x5d/0x80
warn_alloc+0x163/0x190
__alloc_pages_slowpath.constprop.0+0x71b/0x12f0
__alloc_frozen_pages_noprof+0x2f6/0x340
alloc_pages_mpol+0xb6/0x170
___kmalloc_large_node+0xb3/0xd0
__kmalloc_large_noprof+0x1e/0xc0
smb3_simple_falloc.isra.0+0x62b/0x960
cifs_fallocate+0xed/0x180
vfs_fallocate+0x165/0x3c0
__x64_sys_fallocate+0x48/0xa0
do_syscall_64+0xe1/0x640
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
Node 0 Normal: 3375*4kB ... 7*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB
Since this scratch buffer does not require physically contiguous memory,
switch the allocation to kvzalloc(). This retains the performance
benefits of kmalloc() under normal conditions, while gracefully falling
back to virtually contiguous memory when physical allocation fails.
Fixes: 966a3cb7c7db ("cifs: improve fallocate emulation")
Cc: stable@vger.kernel.org
Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
Tested-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
---
fs/smb/client/smb2ops.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index d4875f9532b4..55b53bb9e3fd 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -3595,7 +3595,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
if (rc)
goto out;
- buf = kzalloc(1024 * 1024, GFP_KERNEL);
+ buf = kvzalloc(1024 * 1024, GFP_KERNEL);
if (buf == NULL) {
rc = -ENOMEM;
goto out;
@@ -3652,7 +3652,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
out:
kfree(out_data);
- kfree(buf);
+ kvfree(buf);
return rc;
}
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] smb: client: use kvzalloc() for megabyte buffer in simple fallocate
2026-07-12 2:54 [PATCH] smb: client: use kvzalloc() for megabyte buffer in simple fallocate Fredric Cover
@ 2026-07-12 16:02 ` Steve French
0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2026-07-12 16:02 UTC (permalink / raw)
To: Fredric Cover
Cc: sfrench, pc, ronniesahlberg, sprasad, tom, bharathsm, linux-cifs,
linux-kernel, stable
merged into cifs-2.6.git for-next
On Sat, Jul 11, 2026 at 9:55 PM Fredric Cover
<fredric.cover.lkernel@gmail.com> wrote:
>
> From: Fredric Cover <fredric.cover.lkernel@gmail.com>
>
> Currently in smb3_simple_fallocate_range(), a 1 MB buffer is allocated
> using kzalloc(). Under heavy memory fragmentation, a contiguous 1 MB block
> of physical memory (an order-8 allocation) may not be available,
> causing the allocation to fail.
>
> This failure was observed during xfstests generic/013 on a 4GB RAM
> test machine running fsstress:
>
> fsstress: page allocation failure: order:8,
> mode:0x40dc0(GFP_KERNEL|__GFP_ZERO|__GFP_COMP),
> nodemask=(null),cpuset=/,mems_allowed=0
>
> Call Trace:
> <TASK>
> dump_stack_lvl+0x5d/0x80
> warn_alloc+0x163/0x190
> __alloc_pages_slowpath.constprop.0+0x71b/0x12f0
> __alloc_frozen_pages_noprof+0x2f6/0x340
> alloc_pages_mpol+0xb6/0x170
> ___kmalloc_large_node+0xb3/0xd0
> __kmalloc_large_noprof+0x1e/0xc0
> smb3_simple_falloc.isra.0+0x62b/0x960
> cifs_fallocate+0xed/0x180
> vfs_fallocate+0x165/0x3c0
> __x64_sys_fallocate+0x48/0xa0
> do_syscall_64+0xe1/0x640
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
> </TASK>
>
> Node 0 Normal: 3375*4kB ... 7*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB
>
> Since this scratch buffer does not require physically contiguous memory,
> switch the allocation to kvzalloc(). This retains the performance
> benefits of kmalloc() under normal conditions, while gracefully falling
> back to virtually contiguous memory when physical allocation fails.
>
> Fixes: 966a3cb7c7db ("cifs: improve fallocate emulation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
> Tested-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
> ---
> fs/smb/client/smb2ops.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> index d4875f9532b4..55b53bb9e3fd 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -3595,7 +3595,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
> if (rc)
> goto out;
>
> - buf = kzalloc(1024 * 1024, GFP_KERNEL);
> + buf = kvzalloc(1024 * 1024, GFP_KERNEL);
> if (buf == NULL) {
> rc = -ENOMEM;
> goto out;
> @@ -3652,7 +3652,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
>
> out:
> kfree(out_data);
> - kfree(buf);
> + kvfree(buf);
> return rc;
> }
>
> --
> 2.53.0
>
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-12 16:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-12 2:54 [PATCH] smb: client: use kvzalloc() for megabyte buffer in simple fallocate Fredric Cover
2026-07-12 16:02 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox