netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Ka-Cheong Poon <ka-cheong.poon@oracle.com>
Cc: netdev@vger.kernel.org, santosh.shilimkar@oracle.com,
	davem@davemloft.net, rds-devel@oss.oracle.com,
	sironhide0null@gmail.com
Subject: Re: [PATCH net 1/2] net/rds: Replace direct refcount_inc() by inline function
Date: Wed, 8 Apr 2020 09:44:51 +0300	[thread overview]
Message-ID: <20200408064451.GE3310@unreal> (raw)
In-Reply-To: <5f32ad26-5e3c-d5e2-6d04-6529fbe7fef0@oracle.com>

On Wed, Apr 08, 2020 at 12:15:51PM +0800, Ka-Cheong Poon wrote:
> On 4/8/20 2:48 AM, Leon Romanovsky wrote:
> > On Tue, Apr 07, 2020 at 09:08:01AM -0700, Ka-Cheong Poon wrote:
> > > Added rds_ib_dev_get() and rds_mr_get() to improve code readability.
> >
> > It is very hard to agree with this sentence.
> > Hiding basic kernel primitives is very rare will improve code readability.
> > It is definitely not the case here.
>
>
> This is to match the rds_ib_dev_put() and rds_mr_put() functions.
> Isn't it natural to have a pair of *_put()/*_get() functions?

Ohhh, thank you for pointing that. It is great example why hiding basic
primitives is really bad idea.

123 void rds_ib_dev_put(struct rds_ib_device *rds_ibdev)
124 {
125         BUG_ON(refcount_read(&rds_ibdev->refcount) == 0);
            ^^^^^^ no to this
126         if (refcount_dec_and_test(&rds_ibdev->refcount))
127                 queue_work(rds_wq, &rds_ibdev->free_work);
128 }

....

300         rds_ib_dev_put(rds_ibdev);
301         rds_ib_dev_put(rds_ibdev);

Double put -> you wrongly initialized/used refcount.

So instead of hiding refcount_inc(), I would say delete your *_put() variants,
fix reference counting and convert rds_mr_put() to be normal kref object
instead of current implementation. Which does exactly the same like your
custom *_put()/_get(), but better and with less errors.

Thanks

      reply	other threads:[~2020-04-08  6:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 16:08 [PATCH net 1/2] net/rds: Replace direct refcount_inc() by inline function Ka-Cheong Poon
2020-04-07 16:08 ` [PATCH net 2/2] net/rds: Fix MR reference counting problem Ka-Cheong Poon
2020-04-07 19:30   ` santosh.shilimkar
2020-04-08  2:25     ` zerons
2020-04-08  2:52       ` santosh.shilimkar
2020-04-07 18:48 ` [PATCH net 1/2] net/rds: Replace direct refcount_inc() by inline function Leon Romanovsky
2020-04-07 20:19   ` David Miller
2020-04-08  4:15   ` Ka-Cheong Poon
2020-04-08  6:44     ` Leon Romanovsky [this message]

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=20200408064451.GE3310@unreal \
    --to=leon@kernel.org \
    --cc=davem@davemloft.net \
    --cc=ka-cheong.poon@oracle.com \
    --cc=netdev@vger.kernel.org \
    --cc=rds-devel@oss.oracle.com \
    --cc=santosh.shilimkar@oracle.com \
    --cc=sironhide0null@gmail.com \
    /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).