Re: [PATCH 10/17] jbd2: replace __get_free_pages() with kmalloc()
"Theodore Tso" <[email protected]> Wed, 3 Jun 2026 09:50:15 -0400
| Newsgroups | org.kernel.vger.linux-nilfs,dev.linux.lists.ocfs2-devel,org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-nfs,org.kvack.linux-mm |
|---|---|
| Message-ID | <yfzx3jgzwesernofl7mzixa2mhjfii5v3o7yapghtmozixrpfu@6bsh7iixyiov> |
On Sat, May 23, 2026 at 08:54:22PM +0300, 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) <[email protected]> So historically __get_free_pages() was more efficient than kmalloc since previously the kmalloc overhead meant that a single 4k allocation would take two pages instead of one. I'm guessing that has since changed? Can you explain to someone who hasn't been tracking the changes in kmalloc over time: * How does the efficiency of kmalloc compare to __get_free_page when order == 1? What is the overhead in terms of memory overhead? I'm a bit less concerned about CPU overhead, but it would be good to know that? * What does kmalloc() do when a size > PAGE_SIZE is passed? Will it return contiguous memory, or return an error or worse, BUG? And same question as above; what is the overhead of kmalloc() when size is 2*PAGE_SIZE? 8*PAGE_SIZE? Thanks, - Ted