netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roland Dreier <rdreier@cisco.com>
To: "Sean Hefty" <sean.hefty@intel.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	openib-general@openib.org
Subject: Re: [PATCH 5/6 v2] IB: IP address based RDMA connection manager
Date: Mon, 13 Mar 2006 07:43:28 -0800	[thread overview]
Message-ID: <adabqwafizj.fsf@cisco.com> (raw)
In-Reply-To: ORSMSX401FRaqbC8wSA0000000e@orsmsx401.amr.corp.intel.com

It seems that cma_detach_from_dev():

 > +static void cma_detach_from_dev(struct rdma_id_private *id_priv)
 > +{
 > +	list_del(&id_priv->list);
 > +	if (atomic_dec_and_test(&id_priv->cma_dev->refcount))
 > +		wake_up(&id_priv->cma_dev->wait);
 > +	id_priv->cma_dev = NULL;
 > +}

doesn't need to do atomic_dec_and_test(), because it is never dropping
the last reference to id_priv (and in fact if it was, the last line
would be a use-after-free bug).

Does it make sense to replace it with:

	static void cma_detach_from_dev(struct rdma_id_private *id_priv)
	{
		list_del(&id_priv->list);
		/*
		 * cma_detach_from_dev() will never be dropping the last
		 * reference to id_priv, so no need to test here.
		 */
		atomic_dec(&id_priv->cma_dev->refcount);
		id_priv->cma_dev = NULL;
	}

on my x86_64 build that's worth

	add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-40 (-40)
	function                                     old     new   delta
	cma_detach_from_dev                          106      66     -40

 - R.

       reply	other threads:[~2006-03-13 15:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ORSMSX401FRaqbC8wSA0000000e@orsmsx401.amr.corp.intel.com>
2006-03-13 15:43 ` Roland Dreier [this message]
2006-03-13 17:11   ` [PATCH 5/6 v2] IB: IP address based RDMA connection manager Sean Hefty
     [not found] <ORSMSX401FRaqbC8wSA0000001e@orsmsx401.amr.corp.intel.com>
2006-03-13 17:26 ` Roland Dreier

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=adabqwafizj.fsf@cisco.com \
    --to=rdreier@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=openib-general@openib.org \
    --cc=sean.hefty@intel.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).