public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Binoy Jayan <binoy.jayan@linaro.org>
Cc: Jack Wang <xjtuwjp@gmail.com>, Doug Ledford <dledford@redhat.com>,
	Sean Hefty <sean.hefty@intel.com>,
	Hal Rosenstock <hal.rosenstock@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion
Date: Tue, 25 Oct 2016 09:48:22 -0600	[thread overview]
Message-ID: <20161025154822.GA27240@obsidianresearch.com> (raw)
In-Reply-To: <CAHv-k_86z3MTYePPQcs5fWSqFeoGxt7UYG_b-SyZGQ7zVW-hSw@mail.gmail.com>

On Tue, Oct 25, 2016 at 08:38:21PM +0530, Binoy Jayan wrote:
> On 25 October 2016 at 18:13, Jack Wang <xjtuwjp@gmail.com> wrote:
> > Hi Binoy,
> >
> > snip
> >>
> >>         port->ib_dev   = device;
> >>         port->port_num = port_num;
> >> -       sema_init(&port->sm_sem, 1);
> >> +       init_completion(&port->sm_comp);
> >> +       complete(&port->sm_comp);
> >
> > Why complete here?
> >
> >>         mutex_init(&port->file_mutex);
> >>         INIT_LIST_HEAD(&port->file_list);
> >>
> > KR,
> > Jinpu
> 
> 
> Hi Jack,
> 
> ib_umad_sm_open() calls wait_for_completion_interruptible() which
> comes before ib_umad_sm_close() that calls complete(). In the
> initial open() there will not be anybody to signal the completion,
> so the complete is called to mark the initial state.  I am not sure
> if this is the right way to do it, though.

Using a completion to model exclusive ownership seems convoluted to
me - is that a thing now? What about an atomic?

open:

while (true) {
   wait_event_interruptible(priv->queue,test_bit(CLAIMED_BIT, &priv->flags));
   if (!test_and_set_bit(CLAIMED_BIT, &priv->flags))
        break;
}

close():

   clear_bit(CLAIMED_BIT, &priv->flags)
   wake_up(&priv->queue);

??

Jason

  parent reply	other threads:[~2016-10-25 15:48 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25 12:01 [PATCH v2 0/8] infiniband: Remove semaphores Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 1/8] IB/core: iwpm_nlmsg_request: Replace semaphore with completion Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 2/8] IB/core: Replace semaphore sm_sem " Binoy Jayan
2016-10-25 12:43   ` Jack Wang
2016-10-25 15:08     ` Binoy Jayan
2016-10-25 15:48       ` Jack Wang
2016-10-25 15:48       ` Jason Gunthorpe [this message]
2016-10-25 20:15         ` Arnd Bergmann
2016-10-25 12:01 ` [PATCH v2 3/8] IB/hns: Replace semaphore poll_sem with mutex Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 4/8] IB/mthca: " Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 5/8] IB/isert: Replace semaphore sem with completion Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 6/8] IB/hns: Replace counting semaphore event_sem with wait_event Binoy Jayan
2016-10-25 12:28   ` Arnd Bergmann
2016-10-25 12:59     ` Binoy Jayan
2016-10-25 13:21       ` Arnd Bergmann
2016-10-25 13:35         ` Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 7/8] IB/mthca: " Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 8/8] IB/mlx5: Add helper mlx5_ib_post_send_wait Binoy Jayan
2016-10-25 12:23   ` Arnd Bergmann
2016-10-25 12:46     ` Binoy Jayan
2016-10-25 12:26   ` Leon Romanovsky
2016-10-25 13:16     ` Binoy Jayan
2016-10-27  6:05       ` Leon Romanovsky
2016-10-27  6:23         ` Binoy Jayan

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=20161025154822.GA27240@obsidianresearch.com \
    --to=jgunthorpe@obsidianresearch.com \
    --cc=arnd@arndb.de \
    --cc=binoy.jayan@linaro.org \
    --cc=dledford@redhat.com \
    --cc=hal.rosenstock@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sean.hefty@intel.com \
    --cc=xjtuwjp@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