[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZYL_077xycZ0ZVBy@rigel>
Date: Wed, 20 Dec 2023 22:53:07 +0800
From: Kent Gibson <warthog618@...il.com>
To: Andy Shevchenko <andy@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org, brgl@...ev.pl,
linus.walleij@...aro.org
Subject: Re: [PATCH 2/4] gpiolib: cdev: allocate linereq using kvzalloc()
On Wed, Dec 20, 2023 at 04:30:24PM +0200, Andy Shevchenko wrote:
> On Wed, Dec 20, 2023 at 09:51:04AM +0800, Kent Gibson wrote:
> > The size of struct linereq may exceed a page, so allocate space for
> > it using kvzalloc() instead of kzalloc().
>
> It might be this needs a bit of elaboration. The kmalloc() tries to allocate
> a contiguous (in physical address space) chunk of memory and with fragmented
> memory it might be not possible. So the above issue might (rarely) happen.
> In most cases the call to kmalloc() will succeed.
>
For sure, the kzalloc() generally works - or we wouldn't've gotten this
far as tests with MAX_LINES would've been failing.
We are targetting a very niche failure mode here.
The size allocated can only be determined at runtime, may be more or
less than a page, and we don't care whether the physical memory allocated
is contiguous.
As such kvzalloc() is the appropriate allocator.
Are you suggesting repeating the relevant sections of the
kmalloc/vmalloc() documentation or Memory Allocation Guide as part of the
checkin comment?
Cheers,
Kent.
Powered by blists - more mailing lists