From: Jack Morgenstein <jackm@dev.mellanox.co.il>
To: Joe Perches <joe@perches.com>
Cc: Or Gerlitz <ogerlitz@mellanox.com>,
roland@kernel.org, linux-rdma@vger.kernel.org,
netdev@vger.kernel.org, davem@davemloft.net,
eli@dev.mellanox.co.il, moshel@mellanox.com,
Eli Cohen <eli@mellanox.com>
Subject: Re: [PATCH V2 7/9] IB/mlx5: Mellanox Connect-IB, IB driver part 3/5
Date: Thu, 4 Jul 2013 16:33:23 +0300 [thread overview]
Message-ID: <201307041633.24505.jackm@dev.mellanox.co.il> (raw)
In-Reply-To: <1372885804.1886.22.camel@joe-AO722>
On Thursday 04 July 2013 00:10, Joe Perches wrote:
> On Wed, 2013-07-03 at 20:13 +0300, Or Gerlitz wrote:
> > From: Eli Cohen <eli@mellanox.com>
>
> More trivia:
>
> > diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> []
> > +#define mlx5_ib_dbg(dev, format, arg...) \
> > +do { \
> > + pr_debug("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, \
> > + __func__, __LINE__, current->pid, ##arg); \
> > +} while (0)
>
> unnecessary do {} while (0)
In this case, you are correct. The pr_debug macro itself does this internally
where needed -- not surprising, since pr_debug must also be usable for code like:
if (foo)
pr_debug(...).
I'll remove the do-while in V3.
> > +static void clean_keys(struct mlx5_ib_dev *dev, int c)
> > +{
> > + struct device *ddev = dev->ib_dev.dma_device;
> > + struct mlx5_mr_cache *cache = &dev->cache;
> > + struct mlx5_cache_ent *ent = &cache->ent[c];
> > + struct mlx5_ib_mr *mr;
> > + int size;
> > + int err;
> > +
> > + while (1) {
> > + spin_lock(&ent->lock);
> > + if (list_empty(&ent->head)) {
> > + spin_unlock(&ent->lock);
> > + return;
> > + }
> > + mr = list_first_entry(&ent->head, struct mlx5_ib_mr, list);
> > + list_del(&mr->list);
> > + ent->cur--;
> > + ent->size--;
> > + spin_unlock(&ent->lock);
> > + err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr);
> > + if (err) {
> > + mlx5_ib_warn(dev, "failed destroy mkey\n");
>
> Are you leaking anything here by not freeing?
Actually, if the mkey-destroy fails, it is extremely risky to free
the memory resources it uses. A tiny memory leak (in such a rare case)
is far preferable to a kernel crash.
>
> > + } else {
> > + size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40);
> > + dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE);
> > + kfree(mr->pas);
> > + kfree(mr);
> > + }
> > + };
> > +}
>
> > +static struct mlx5_ib_mr *reg_create(struct ib_pd *pd, u64 virt_addr,
> > + u64 length, struct ib_umem *umem,
> > + int npages, int page_shift,
> > + int access_flags)
> > +{
> []
> > + mr = kzalloc(sizeof(*mr), GFP_KERNEL);
> > + if (!mr) {
> > + mlx5_ib_warn(dev, "allocation failed\n");
>
> Another unnecessary OOM
Will remove for V3
> > + mr = ERR_PTR(-ENOMEM);
> > + }
> > +
> > + inlen = sizeof(*in) + sizeof(*in->pas) * ((npages + 1) / 2) * 2;
> > + in = vzalloc(inlen);
> > + if (!in) {
> > + mlx5_ib_warn(dev, "alloc failed\n");
>
> here too.
Will remove for V3
> > + err = -ENOMEM;
> > + goto err_1;
> > + }
>
Thanks again for the review!
-Jack
next prev parent reply other threads:[~2013-07-04 13:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 17:13 [PATCH V2 0/9] Add Mellanox mlx5 driver for Connect-IB devices Or Gerlitz
2013-07-03 17:13 ` [PATCH V2 1/9] net/mlx5: Mellanox Connect-IB, core driver part 1/3 Or Gerlitz
[not found] ` <1372871592-32033-2-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-07-03 20:29 ` Joe Perches
2013-07-04 13:26 ` Jack Morgenstein
[not found] ` <201307041626.45125.jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2013-07-04 14:17 ` Joe Perches
2013-07-04 14:55 ` Jack Morgenstein
[not found] ` <1372871592-32033-1-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-07-03 17:13 ` [PATCH V2 2/9] net/mlx5: Mellanox Connect-IB, core driver part 2/3 Or Gerlitz
2013-07-03 17:13 ` [PATCH V2 3/9] net/mlx5: Mellanox Connect-IB, core driver part 3/3 Or Gerlitz
2013-07-03 17:13 ` [PATCH V2 6/9] IB/mlx5: Mellanox Connect-IB, IB driver part 2/5 Or Gerlitz
2013-07-03 17:13 ` [PATCH V2 7/9] IB/mlx5: Mellanox Connect-IB, IB driver part 3/5 Or Gerlitz
[not found] ` <1372871592-32033-8-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-07-03 21:10 ` Joe Perches
2013-07-04 13:33 ` Jack Morgenstein [this message]
2013-07-03 17:13 ` [PATCH V2 4/9] IB/core: Add reserved values to enums for low-level drivers use Or Gerlitz
2013-07-03 17:13 ` [PATCH V2 5/9] IB/mlx5: Mellanox Connect-IB, IB driver part 1/5 Or Gerlitz
[not found] ` <1372871592-32033-6-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-07-03 20:59 ` Joe Perches
2013-07-04 13:15 ` Jack Morgenstein
2013-07-04 14:03 ` Jack Morgenstein
2013-07-03 17:13 ` [PATCH V2 8/9] IB/mlx5: Mellanox Connect-IB, IB driver part 4/5 Or Gerlitz
2013-07-03 17:13 ` [PATCH V2 9/9] IB/mlx5: Mellanox Connect-IB, IB driver part 5/5 Or Gerlitz
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=201307041633.24505.jackm@dev.mellanox.co.il \
--to=jackm@dev.mellanox.co.il \
--cc=davem@davemloft.net \
--cc=eli@dev.mellanox.co.il \
--cc=eli@mellanox.com \
--cc=joe@perches.com \
--cc=linux-rdma@vger.kernel.org \
--cc=moshel@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=roland@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