From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Michal Hocko <mhocko@suse.com>
Cc: Linux Memory Management List <linux-mm@kvack.org>,
lkml <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Question about vmalloc(GFP_NOFS)
Date: Tue, 19 Nov 2024 13:48:15 +0800 [thread overview]
Message-ID: <112f93f3-455a-4b89-94c9-d12844d972ef@virtuozzo.com> (raw)
Hello,
I see that in kernel code we have couple of places where kvmalloc is
used with GFP_NOFS flag:
git grep kvmalloc.*NOFS
fs/bcachefs/journal_io.c: new_buf = kvmalloc(new_size,
GFP_NOFS|__GFP_NOWARN);
fs/ext4/xattr.c: buffer = kvmalloc(value_size, GFP_NOFS);
fs/f2fs/compress.c: cc->private =
f2fs_kvmalloc(F2FS_I_SB(cc->inode), size, GFP_NOFS);
net/ceph/osdmap.c: state = kvmalloc(array_size(max,
sizeof(*state)), GFP_NOFS);
net/ceph/osdmap.c: weight = kvmalloc(array_size(max,
sizeof(*weight)), GFP_NOFS);
net/ceph/osdmap.c: addr = kvmalloc(array_size(max, sizeof(*addr)),
GFP_NOFS);
and with GFP_NOIO flag too:
git grep kvmalloc.*NOIO
drivers/md/dm-integrity.c: recalc_tags = kvmalloc(recalc_tags_size,
GFP_NOIO);
drivers/md/dm-ioctl.c: dmi = kvmalloc(param_kernel->data_size, GFP_NOIO
| __GFP_HIGH);
net/ceph/messenger_v2.c: buf = kvmalloc(len, GFP_NOIO);
net/ceph/osdmap.c: work = kvmalloc(work_size, GFP_NOIO);
And AFAIU documentation
https://docs.kernel.org/core-api/gfp_mask-from-fs-io.html#what-about-vmalloc-gfp-nofs
vmalloc allocation with GFP_NOFS may end up doing "GFP_KERNEL
allocations deep inside the allocator", which can potentially lead to
deadlock in IO/FS code paths.
Does it mean that we should rework all those paths to memalloc_noio_save
/ memalloc_noio_restore variant? Or is it already safe to use
kvmalloc(GFP_NOIO) in modern kernel?
Or maybe I misunderstand something, sorry in advance if that's the case.
--
Best regards, Tikhomirov Pavel
Senior Software Developer, Virtuozzo.
next reply other threads:[~2024-11-19 5:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 5:48 Pavel Tikhomirov [this message]
2024-11-19 7:24 ` Pavel Tikhomirov
2024-11-19 8:29 ` Michal Hocko
2024-11-19 9:41 ` Pavel Tikhomirov
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=112f93f3-455a-4b89-94c9-d12844d972ef@virtuozzo.com \
--to=ptikhomirov@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.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