From: David Laight <david.laight.linux@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: "Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Jan Kara <jack@suse.com>, Mark Fasheh <mark@fasheh.com>,
Joel Becker <jlbec@evilplan.org>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
Ryusuke Konishi <konishi.ryusuke@gmail.com>,
Viacheslav Dubeyko <slava@dubeyko.com>,
Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>,
Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Dave Kleikamp <shaggy@kernel.org>, Theodore Ts'o <tytso@mit.edu>,
Miklos Szeredi <miklos@szeredi.hu>,
Andreas Hindborg <a.hindborg@kernel.org>,
Breno Leitao <leitao@debian.org>, Kees Cook <kees@kernel.org>,
"Tigran A. Aivazian" <aivazian.tigran@gmail.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
ocfs2-devel@lists.linux.dev, linux-nilfs@vger.kernel.org,
linux-nfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net,
linux-ext4@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 10/17] jbd2: replace __get_free_pages() with kmalloc()
Date: Mon, 25 May 2026 18:21:34 +0100 [thread overview]
Message-ID: <20260525182134.04045610@pumpkin> (raw)
In-Reply-To: <2omm5gmnv2khshoxkrag5rusd3qzrsqyjgsef2syxgryrtg6vq@ao7oabqwebgo>
On Mon, 25 May 2026 18:17:04 +0200
Jan Kara <jack@suse.cz> wrote:
> On Sat 23-05-26 20:54:22, Mike Rapoport (Microsoft) wrote:
> > jbd2_alloc() falls back from kmem_cache_alloc() to __get_free_pages() for
> > allocations larger than PAGE_SIZE.
> > But kmalloc() can handle such cases with essentially the same fallback.
> >
> > Replace use of __get_free_pages() with kmalloc() and simplify
> > jbd2_free() as both kmem_cache_alloc() and kmalloc() allocations can be
> > freed with kfree().
> >
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
>
> Looks good. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
> I'll just note that we allocate here fs block size large buffer so the same
> kind of allocator as we use for folios would be even better. But that's a
> different cleanup I guess.
Would kvalloc() be more appropriate here?
Does __get_free_pages() return physically contiguous memory?
-- David
>
> Honza
>
> > ---
> > fs/jbd2/journal.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> > index 4f397fcdb13c..1137b471e490 100644
> > --- a/fs/jbd2/journal.c
> > +++ b/fs/jbd2/journal.c
> > @@ -2784,7 +2784,7 @@ void *jbd2_alloc(size_t size, gfp_t flags)
> > if (size < PAGE_SIZE)
> > ptr = kmem_cache_alloc(get_slab(size), flags);
> > else
> > - ptr = (void *)__get_free_pages(flags, get_order(size));
> > + ptr = kmalloc(size, flags);
> >
> > /* Check alignment; SLUB has gotten this wrong in the past,
> > * and this can lead to user data corruption! */
> > @@ -2795,10 +2795,7 @@ void *jbd2_alloc(size_t size, gfp_t flags)
> >
> > void jbd2_free(void *ptr, size_t size)
> > {
> > - if (size < PAGE_SIZE)
> > - kmem_cache_free(get_slab(size), ptr);
> > - else
> > - free_pages((unsigned long)ptr, get_order(size));
> > + kfree(ptr);
> > };
> >
> > /*
> >
> > --
> > 2.53.0
> >
next prev parent reply other threads:[~2026-05-25 17:21 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 17:54 [PATCH 00/17] fs: replace __get_free_pages() call with kmalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 01/17] quota: allocate dquot_hash " Mike Rapoport (Microsoft)
2026-05-25 16:10 ` Jan Kara
2026-05-23 17:54 ` [PATCH 02/17] proc: replace __get_free_page() " Mike Rapoport (Microsoft)
2026-05-25 16:11 ` Jan Kara
2026-05-23 17:54 ` [PATCH 03/17] ocfs2/dlm: " Mike Rapoport (Microsoft)
2026-05-25 2:50 ` Joseph Qi
2026-05-25 16:13 ` Jan Kara
2026-05-23 17:54 ` [PATCH 04/17] nilfs2: replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-05-25 17:07 ` Viacheslav Dubeyko
2026-05-23 17:54 ` [PATCH 05/17] NFS: replace __get_free_page() with kmalloc() in nfs_show_devname() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 06/17] NFS: remove unused page and page2 in nfs4_replace_transport() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 07/17] NFSD: replace __get_free_page() with kmalloc() in nfsd_buffered_readdir() Mike Rapoport (Microsoft)
2026-05-23 18:45 ` Jeff Layton
2026-05-23 17:54 ` [PATCH 08/17] libfs: simple_transaction_get(): replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 09/17] jfs: replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 10/17] jbd2: replace __get_free_pages() " Mike Rapoport (Microsoft)
2026-05-25 16:17 ` Jan Kara
2026-05-25 17:21 ` David Laight [this message]
2026-05-23 17:54 ` [PATCH 11/17] isofs: replace __get_free_page() " Mike Rapoport (Microsoft)
2026-05-25 16:17 ` Jan Kara
2026-05-23 17:54 ` [PATCH 12/17] fuse: " Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 13/17] fs/select: " Mike Rapoport (Microsoft)
2026-05-25 16:19 ` Jan Kara
2026-05-23 17:54 ` [PATCH 14/17] fs/namespace: use __getname() to allocate mntpath buffer Mike Rapoport (Microsoft)
2026-05-25 16:22 ` Jan Kara
2026-05-23 17:54 ` [PATCH 15/17] configfs: replace __get_free_pages() with kzalloc() Mike Rapoport (Microsoft)
2026-05-25 16:22 ` Jan Kara
2026-05-23 17:54 ` [PATCH 16/17] binfmt_misc: replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 17/17] bfs: replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
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=20260525182134.04045610@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=Dai.Ngo@oracle.com \
--cc=a.hindborg@kernel.org \
--cc=aivazian.tigran@gmail.com \
--cc=anna@kernel.org \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jack@suse.com \
--cc=jack@suse.cz \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=jlayton@kernel.org \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=kees@kernel.org \
--cc=konishi.ryusuke@gmail.com \
--cc=leitao@debian.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=miklos@szeredi.hu \
--cc=neil@brown.name \
--cc=ocfs2-devel@lists.linux.dev \
--cc=okorniev@redhat.com \
--cc=rppt@kernel.org \
--cc=shaggy@kernel.org \
--cc=slava@dubeyko.com \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/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