All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Kent Gibson <warthog618@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	brgl@bgdev.pl, linus.walleij@linaro.org
Subject: Re: [PATCH 2/4] gpiolib: cdev: allocate linereq using kvzalloc()
Date: Wed, 20 Dec 2023 16:58:34 +0200	[thread overview]
Message-ID: <ZYMBGrlY3mTWhKVv@smile.fi.intel.com> (raw)
In-Reply-To: <ZYL_077xycZ0ZVBy@rigel>

On Wed, Dec 20, 2023 at 10:53:07PM +0800, Kent Gibson wrote:
> 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?

I suggesting to make clear in the commit message that:
- there is no bug per se with the code logic (i.o.w.
  there is no issue to have allocations bigger than one page)
- this is very rarely case when it might be a problem

You can also put a reference to the documentation, if you wish.
This should be harmless and adding not more than a line into
the commit message (or even as a Link: tag to the HTML variant of it).

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-12-20 15:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20  1:51 [PATCH 0/4] gpiolib: cdev: guard tidying Kent Gibson
2023-12-20  1:51 ` [PATCH 1/4] gpiolib: cdev: include overflow.h Kent Gibson
2023-12-20  1:51 ` [PATCH 2/4] gpiolib: cdev: allocate linereq using kvzalloc() Kent Gibson
2023-12-20 14:30   ` Andy Shevchenko
2023-12-20 14:53     ` Kent Gibson
2023-12-20 14:58       ` Andy Shevchenko [this message]
2023-12-20  1:51 ` [PATCH 3/4] gpiolib: cdev: replace locking wrappers for config_mutex with guards Kent Gibson
2023-12-20  1:51 ` [PATCH 4/4] gpiolib: cdev: replace locking wrappers for gpio_device " Kent Gibson
2023-12-20 11:55   ` Linus Walleij
2023-12-20 12:05     ` Bartosz Golaszewski
2023-12-20 12:13       ` Kent Gibson
2023-12-20 12:16         ` Bartosz Golaszewski
2023-12-20 12:23           ` Kent Gibson
2023-12-20 12:30             ` Bartosz Golaszewski
2023-12-20 12:53               ` Kent Gibson
2023-12-20 13:19                 ` Bartosz Golaszewski
2023-12-20 13:28                   ` Kent Gibson
2023-12-20 13:47                     ` Bartosz Golaszewski
2023-12-20 13:53                       ` Kent Gibson

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=ZYMBGrlY3mTWhKVv@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=warthog618@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.