Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Eric Yun Lin Chiang <ericyunlinchiang@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	driver-core@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] devres: update node debug info on in-place devm_krealloc()
Date: Fri, 4 Dec 2026 13:50:56 +0100	[thread overview]
Message-ID: <axK3MOd2_xpJeyMt@hovoldconsulting.com> (raw)
In-Reply-To: <axKhbvNS0lyuM6oN@ashevche-desk.local>

On Fri, Dec 04, 2026 at 01:18:06PM +0200, Andy Shevchenko wrote:
> On Fri, Dec 04, 2026 at 01:09:07PM +0200, Andy Shevchenko wrote:
> > On Fri, Dec 04, 2026 at 10:28:46AM +0100, Johan Hovold wrote:
> > > On Fri, Dec 04, 2026 at 11:13:28AM +0200, Andy Shevchenko wrote:

> > > > Doesn't matter. We should not lie to the users of the traces. If size was not
> > > > shrunk, it is not changed based on what the caller of krealloc() asked for.
> > > > If you want to add that to the trace, it should be an additional field or
> > > > so, not the lie. OTOH you can introduce memory shrinking support to krealloc()
> > > > but I have no idea what will be a perception of any of these approaches.
> > > 
> > > I believe krealloc() can shrink, unlike devm_krealloc().
> > 
> > Do we have a test case for that? Because as I read the __do_krealloc()
> > I see that *sometimes* (if some conditions happen)it might allocate a new
> > buffer with a smaller size.  kasan_krealloc() in all three cases returns
> > the same address back without any reallocation done.
> > 
> > Where am I wrong?
> 
> So, for krealloc() required alignment is hard coded to 1, so the only way to
> shrink is to use __GFP_THISNODE, but node is also hardcoded to NUMA_NO_NODE,
> so no, there is no way to shrink memory with krealloc().
> 
> Please, correct me, if I'm wrong.

You're right about reallocation, but it seems devm_krealloc() do fail to
honour __GFP_ZERO when shrinking.

Johan

  reply	other threads:[~2026-12-04 12:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  0:57 [PATCH] devres: update node debug info on in-place devm_krealloc() Eric Yun Lin Chiang
2026-12-03 11:42 ` Andy Shevchenko
2026-12-04  0:39   ` Eric Yun Lin Chiang
2026-12-04  9:13     ` Andy Shevchenko
2026-12-04  9:28       ` Johan Hovold
2026-12-04 11:09         ` Andy Shevchenko
2026-12-04 11:18           ` Andy Shevchenko
2026-12-04 12:50             ` Johan Hovold [this message]
2026-12-04 14:24               ` Andy Shevchenko

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=axK3MOd2_xpJeyMt@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@kernel.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=ericyunlinchiang@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.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