From: Joe Perches <joe@perches.com>
To: Shannon Nelson <snelson@pensando.io>, Xu Wang <vulab@iscas.ac.cn>,
drivers@pensando.io, davem@davemloft.net, kuba@kernel.org,
netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ionic_lif: Use devm_kcalloc() in ionic_qcq_alloc()
Date: Sun, 09 Aug 2020 20:54:24 -0700 [thread overview]
Message-ID: <8cc2925b53845876475ccc4f098fbc88471d77bb.camel@perches.com> (raw)
In-Reply-To: <2623670b-09f0-2ab4-d618-e478d98c186a@pensando.io>
On Sun, 2020-08-09 at 20:50 -0700, Shannon Nelson wrote:
> On 8/9/20 8:20 PM, Joe Perches wrote:
> > On Mon, 2020-08-10 at 02:38 +0000, Xu Wang wrote:
> > > A multiplication for the size determination of a memory allocation
> > > indicated that an array data structure should be processed.
> > > Thus use the corresponding function "devm_kcalloc".
> > []
> > > diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> > []
> > > @@ -412,7 +412,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
> > >
> > > new->flags = flags;
> > >
> > > - new->q.info = devm_kzalloc(dev, sizeof(*new->q.info) * num_descs,
> > > + new->q.info = devm_kcalloc(dev, num_descs, sizeof(*new->q.info),
> > > GFP_KERNEL);
> > > if (!new->q.info) {
> > > netdev_err(lif->netdev, "Cannot allocate queue info\n");
> > You could also remove these unnecessary allocation error messages.
> > There is an existing dump_stack() on allocation failure.
> >
> Yes, the dump_stack() tells you which function had the allocation
> failure, but since there are multiple allocation operations in this same
> function, I find these helpful in knowing quickly which one of the
> allocations failed, without having to track down the symbols and source
> for whatever distro's kernel this might have happened in.
If you do chose the message, might as well add __GFP_NOWARN
to the allocation to avoid the dump_stack().
But honestly, if any allocation fails, you're OOM anyway.
next prev parent reply other threads:[~2020-08-10 3:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 2:38 [PATCH] ionic_lif: Use devm_kcalloc() in ionic_qcq_alloc() Xu Wang
2020-08-10 3:20 ` Joe Perches
2020-08-10 3:50 ` Shannon Nelson
2020-08-10 3:54 ` Joe Perches [this message]
2020-08-10 3:54 ` Shannon Nelson
2020-08-11 17:36 ` David Miller
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=8cc2925b53845876475ccc4f098fbc88471d77bb.camel@perches.com \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=drivers@pensando.io \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=snelson@pensando.io \
--cc=vulab@iscas.ac.cn \
/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;
as well as URLs for NNTP newsgroup(s).