Re: [PATCH] devres: update node debug info on in-place devm_krealloc()
From: Johan Hovold
Date: Fri Dec 04 2026 - 07:51:01 EST
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