From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] pinctrl: pinconf-generic: resize the pin config array directly
Date: Fri, 24 Nov 2023 13:24:58 +0200 [thread overview]
Message-ID: <ZWCIChQ3TKtxv2b-@smile.fi.intel.com> (raw)
In-Reply-To: <CACRpkdaMBrWUR8OYLPiQNNJ64mfenFyQa9f4iB+w5kZ44WjSeQ@mail.gmail.com>
On Fri, Nov 24, 2023 at 11:06:50AM +0100, Linus Walleij wrote:
> On Tue, Nov 21, 2023 at 11:21 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > On Tue, Nov 21, 2023 at 7:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > pinconf_generic_parse_dt_config() allocates memory that is large enough
> > > to contain all the config parameters. Then, kmemdup() copies the found
> > > configs to the memory with the exact size.
> > >
> > > There is no need to allocate memory twice; you can directly resize the
> > > initial memory using krealloc_array().
> > >
> > > I also changed kcalloc() to kmalloc_array() to keep the consistency with
> > > krealloc_array(). This change has no impact because you do not need to
> > > zero out the 'cfg' array.
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> >
> > Sorry, I retract this patch set.
> >
> > krealloc() does not save any memory
> > when the new_size is smaller than the current size.
>
> But the first part where you switch to kmalloc_array() is still a nice change.
>
> The fact that we use kmemdup to be able to also shrink the allocation is a
> bit of an oddity I guess, but let's run this patch by Andy Shevchenko, and
> ask what he thinks about simply introducing kmemdup_array() or if he
> has other ideas for this.
https://lore.kernel.org/all/20231017052322.2636-2-kkartik@nvidia.com/
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-11-24 11:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-20 22:28 [PATCH 0/2] pinctrl: pinconf-generic: clean up pinconf_parse_dt_config() Masahiro Yamada
2023-11-20 22:28 ` [PATCH 1/2] pinctrl: pinconf-generic: resize the pin config array directly Masahiro Yamada
2023-11-21 10:21 ` Masahiro Yamada
2023-11-24 10:06 ` Linus Walleij
2023-11-24 11:24 ` Andy Shevchenko [this message]
2023-11-25 18:03 ` Masahiro Yamada
2023-11-20 22:28 ` [PATCH 2/2] pinctrl: pinconf-generic: remove the special handling for no config case Masahiro Yamada
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=ZWCIChQ3TKtxv2b-@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@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