Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Eli Billauer <eli.billauer@gmail.com>, Mike Rapoport <rppt@kernel.org>
Cc: David Laight <david.laight.linux@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Brad Warrum <bwarrum@linux.ibm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michal Simek <michal.simek@amd.com>,
	Ritu Agarwal <rituagar@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/4] char: xillybus: replace __get_free_pages() with kmalloc()
Date: Thu, 3 Sep 2026 16:28:48 +0200	[thread overview]
Message-ID: <3c19c24f-5036-4bbe-b3af-e5eae102f34a@kernel.org> (raw)
In-Reply-To: <1d7f8806-f4a0-fda0-a361-a011460ef308@outbound.gmail.com>

On 9/3/26 14:30, Eli Billauer wrote:
> On 02/09/2026 14:09, Mike Rapoport wrote:
>>> So using vmalloc() may result in a malfunction in the data transport where
>>> the __get_free_pages() would have been successful. This outweighs the
>>> benefit of a somewhat higher probability of success in allocating very large
>>> buffers, and surely the improved aesthetics of the kernel code.
>> kmalloc() still works, just like __get_free_pages()
>>   
> 
> After these few days of discussion, this is what I make of this topic.
> 
> The memory allocation in fifo_init() is somewhat ugly, but this driver 
> has been out there for five years, and no complaints from users.
> 
> The vmalloc() option may be successful sometimes where the current 
> allocation will not. On the other hand, there is a possibility that it 
> will cause real trouble with page faults. Plus, a large allocation with 
> vmalloc() may be a weak spot on a platform to which the kernel is 
> partially or poorly ported.

vmalloc() has its limitations, yes...

> With __get_free_pages(), there is no doubt that usable memory is 
> allocated right away, and that it will work that way on every single 
> esoteric platform. vmalloc() leaves us with "we're pretty sure there is 
> probably no problem".
> 
> So I vote against vmalloc().
> 
> As for replacing __get_free_pages() with kmalloc(), it's a matter of 
> taste. I think that if you're after a buffer that has a power-of-two 
> number of pages, __get_free_pages() is the natural choice, and using it 
> makes it easier for the reader to understand what you're doing. 

If you are only after a buffer (that's physically contiguous and aligned)
and don't need the struct page itself, then kmalloc() is the natural choice.
This is where we are heading with the upcoming memdesc conversions etc.

> Replacing it with a kmalloc() is confusing in my opinion, and requires 
> that the reader is aware that kmalloc() falls back to __get_free_pages() 

Why? The reader has only to know that kmalloc() will provide such a buffer
(up to sizes that the page allocator would) and whether it falls back to the
page allocator or not is an implementation detail.
BTW, it's only at >2*PAGE_SIZE where it falls back. Which could change at
any point and nobody should care.

> in this case. So we actually want __get_free_pages(), but call kmalloc() 
> instead and let it fall back to __get_free_pages() so we don't have a 
> cast and don't need to save the order, and assume that everyone knows 
> that this is equivalent.

Oh right with __get_free_pages() you need to pass the order for freeing.
That's a real practical argument for kmalloc(). So I don't see why you'd
hold it against kmalloc().

> So I vote against the kmalloc() thing as well.
> 
> If this patch is part of a larger kernel cleanup, I suppose my votes 
> don't count for much. But for the record, this is my opinion.
> 
> Thanks and regards,
>     Eli



  reply	other threads:[~2026-09-03 14:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30  7:47 [PATCH 0/4] char/misc: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-08-30  7:47 ` [PATCH 1/4] char: xilinx_hwicap: " Mike Rapoport (Microsoft)
2026-08-30  7:47 ` [PATCH 2/4] char: xillybus: replace __get_free_pages() with kmalloc() Mike Rapoport (Microsoft)
2026-08-31 10:13   ` Eli Billauer
2026-08-31 11:32     ` Mike Rapoport
2026-09-01  8:42       ` Eli Billauer
2026-09-01 17:24         ` Mike Rapoport
2026-09-02 11:40           ` Eli Billauer
2026-09-03  9:15             ` Mike Rapoport
2026-08-31 11:39     ` David Laight
2026-09-01  7:59       ` Mike Rapoport
2026-09-01  8:37         ` David Laight
2026-09-01  8:44         ` Eli Billauer
2026-09-01 17:46           ` Mike Rapoport
2026-09-02 11:41             ` Eli Billauer
2026-09-02 12:09               ` Mike Rapoport
2026-09-03 12:30                 ` Eli Billauer
2026-09-03 14:28                   ` Vlastimil Babka (SUSE) [this message]
2026-09-03 14:56                     ` Mike Rapoport
2026-09-02 12:25               ` Pedro Falcato
2026-09-02 12:26               ` David Laight
2026-08-30  7:48 ` [PATCH 3/4] misc: ibmvmc: replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-08-30  7:48 ` [PATCH 4/4] platform: goldfish: pipe: replace __get_free_page() with kmalloc() 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=3c19c24f-5036-4bbe-b3af-e5eae102f34a@kernel.org \
    --to=vbabka@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bwarrum@linux.ibm.com \
    --cc=david.laight.linux@gmail.com \
    --cc=david@kernel.org \
    --cc=eli.billauer@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=michal.simek@amd.com \
    --cc=rituagar@linux.ibm.com \
    --cc=rppt@kernel.org \
    --cc=willy@infradead.org \
    /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