Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1526921

Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait
Date 2016-11-21 18:00 +0100
Message-ID <sG06L-3IM-45@gated-at.bofh.it> (permalink)
References <sFPXI-5Q1-7@gated-at.bofh.it> <sFQ7o-5VC-33@gated-at.bofh.it> <sG06L-3IM-47@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Monday, November 21, 2016 7:57:53 AM CET Linus Torvalds wrote:
> Don't do this.
> 
> Never ever do your own locking primitives. You will get the memory ordering
> wrong. And even if you get it right, why do it?
> 
> If you want to get rid of semaphores, and replace them with a mutex, that's
> OK. But don't replace them with something more complex like an open coded
> waiting model.

I think a mutex would't work here, since fops->open() and fops->close()
are not called from the same context and lockdep will complain
about that.

Version of the series had replaced the semaphore with a completion
here, which worked correctly, but one reviewer suggested using
the wait_event() instead since it's confusing to have a completion
starting out in 'completed' state.

	Arnd

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 0/9] infiniband: Remove semaphores Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:10 +0100
  [PATCH v5 7/9] IB/mthca: Replace counting semaphore event_sem with wait_event Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:10 +0100
  [PATCH v5 6/9] IB/hns: Replace counting semaphore event_sem with wait_event Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:10 +0100
  [PATCH v5 3/9] IB/hns: Replace semaphore poll_sem with mutex Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:10 +0100
  [PATCH v5 8/9] IB/mlx5: Add helper mlx5_ib_post_send_wait Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:10 +0100
  [PATCH v5 1/9] IB/core: iwpm_nlmsg_request: Replace semaphore with completion Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:10 +0100
  [PATCH v5 9/9] IB/mlx5: Replace semaphore umr_common:sem with wait_event Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:20 +0100
  [PATCH v5 4/9] IB/mthca: Replace semaphore poll_sem with mutex Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:20 +0100
  [PATCH v5 5/9] IB/isert: Replace semaphore sem with completion Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:20 +0100
    Re: [PATCH v5 5/9] IB/isert: Replace semaphore sem with completion Sagi Grimberg <sagi@grimberg.me> - 2016-11-21 08:40 +0100
      Re: [PATCH v5 5/9] IB/isert: Replace semaphore sem with completion Arnd Bergmann <arnd@arndb.de> - 2016-11-21 11:30 +0100
        Re: [PATCH v5 5/9] IB/isert: Replace semaphore sem with completion Sagi Grimberg <sagi@grimberg.me> - 2016-11-21 13:40 +0100
          Re: [PATCH v5 5/9] IB/isert: Replace semaphore sem with completion Arnd Bergmann <arnd@arndb.de> - 2016-11-21 16:00 +0100
  [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait Binoy Jayan <binoy.jayan@linaro.org> - 2016-11-21 07:20 +0100
    Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic  wait Christoph Hellwig <hch@infradead.org> - 2016-11-21 18:00 +0100
    Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait Arnd Bergmann <arnd@arndb.de> - 2016-11-21 18:00 +0100
      Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait Linus Torvalds <torvalds@linux-foundation.org> - 2016-11-21 19:00 +0100
        Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait Arnd Bergmann <arnd@arndb.de> - 2016-11-22 00:00 +0100

csiph-web