Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1508387
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion |
| Date | 2016-10-25 17:50 +0200 |
| Message-ID | <swc9c-7vM-5@gated-at.bofh.it> (permalink) |
| References | <sw8Ih-5rG-3@gated-at.bofh.it> <sw8Ij-5rG-57@gated-at.bofh.it> <sw9kZ-5I1-21@gated-at.bofh.it> <swbwt-7hI-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion Binoy Jayan <binoy.jayan@linaro.org> - 2016-10-25 14:10 +0200
Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion Jack Wang <xjtuwjp@gmail.com> - 2016-10-25 14:50 +0200
Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion Binoy Jayan <binoy.jayan@linaro.org> - 2016-10-25 17:10 +0200
Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-10-25 17:50 +0200
Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion Arnd Bergmann <arnd@arndb.de> - 2016-10-25 22:20 +0200
Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion Jack Wang <xjtuwjp@gmail.com> - 2016-10-25 17:50 +0200
csiph-web