public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Bernard Metzler <bmt@zurich.ibm.com>,
	Doug Ledford <dledford@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rdma/siw: avoid smp_store_mb() on a u64
Date: Thu, 25 Jul 2019 14:23:01 -0300	[thread overview]
Message-ID: <20190725172301.GA6225@ziepe.ca> (raw)
In-Reply-To: <20190712085212.3901785-1-arnd@arndb.de>

On Fri, Jul 12, 2019 at 10:51:23AM +0200, Arnd Bergmann wrote:
> The new siw driver fails to build on i386 with
> 
> drivers/infiniband/sw/siw/siw_qp.c:1025:3: error: invalid output size for constraint '+q'
>                 smp_store_mb(*cq->notify, SIW_NOTIFY_NOT);
>                 ^
> include/asm-generic/barrier.h:141:35: note: expanded from macro 'smp_store_mb'
>  #define smp_store_mb(var, value)  __smp_store_mb(var, value)
>                                   ^
> arch/x86/include/asm/barrier.h:65:47: note: expanded from macro '__smp_store_mb'
>  #define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
>                                               ^
> include/asm-generic/atomic-instrumented.h:1648:2: note: expanded from macro 'xchg'
>         arch_xchg(__ai_ptr, __VA_ARGS__);                               \
>         ^
> arch/x86/include/asm/cmpxchg.h:78:27: note: expanded from macro 'arch_xchg'
>  #define arch_xchg(ptr, v)       __xchg_op((ptr), (v), xchg, "")
>                                 ^
> arch/x86/include/asm/cmpxchg.h:48:19: note: expanded from macro '__xchg_op'
>                                       : "+q" (__ret), "+m" (*(ptr))     \
>                                               ^
> drivers/infiniband/sw/siw/siw_qp.o: In function `siw_sqe_complete':
> siw_qp.c:(.text+0x1450): undefined reference to `__xchg_wrong_size'
> drivers/infiniband/sw/siw/siw_qp.o: In function `siw_rqe_complete':
> siw_qp.c:(.text+0x15b0): undefined reference to `__xchg_wrong_size'
> drivers/infiniband/sw/siw/siw_verbs.o: In function `siw_req_notify_cq':
> siw_verbs.c:(.text+0x18ff): undefined reference to `__xchg_wrong_size'
> 
> Since smp_store_mb() has to be an atomic store, but the architecture
> can only do this on 32-bit quantities or smaller, but 'cq->notify'
> is a 64-bit word.
> 
> Apparently the smp_store_mb() is paired with a READ_ONCE() here, which
> seems like an odd choice because there is only a barrier on the writer
> side and not the reader, and READ_ONCE() is already not atomic on
> quantities larger than a CPU register.
> 
> I suspect it is sufficient to use the (possibly nonatomic) WRITE_ONCE()
> and an SMP memory barrier here. If it does need to be atomic as well
> as 64-bit quantities, using an atomic64_set_release()/atomic64_read_acquire()
> may be a better choice.
> 
> Fixes: 303ae1cdfdf7 ("rdma/siw: application interface")
> Fixes: f29dd55b0236 ("rdma/siw: queue pair methods")
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/infiniband/sw/siw/siw_qp.c    | 4 +++-
>  drivers/infiniband/sw/siw/siw_verbs.c | 5 +++--
>  2 files changed, 6 insertions(+), 3 deletions(-)

Bernard, please send at patch for whatever solution we settled on
against 5.3-rc1

Thanks,
Jason

      parent reply	other threads:[~2019-07-25 17:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12  8:51 [PATCH] rdma/siw: avoid smp_store_mb() on a u64 Arnd Bergmann
2019-07-12 11:33 ` Bernard Metzler
2019-07-12 11:47   ` Peter Zijlstra
2019-07-12 12:03   ` Jason Gunthorpe
2019-07-12 12:27     ` Bernard Metzler
2019-07-12 13:05     ` Bernard Metzler
2019-07-12 13:19       ` Peter Zijlstra
2019-07-12 13:35         ` Bernard Metzler
2019-07-12 13:22       ` Arnd Bergmann
2019-07-12 15:14         ` Jason Gunthorpe
2019-07-12 20:24           ` Arnd Bergmann
2019-07-12 13:53       ` Jason Gunthorpe
2019-07-12 14:35         ` Bernard Metzler
2019-07-12 14:42           ` Jason Gunthorpe
2019-07-12 15:24             ` Bernard Metzler
2019-07-12 15:32               ` Jason Gunthorpe
2019-07-12 17:40                 ` Bernard Metzler
2019-07-12 17:45                   ` Jason Gunthorpe
2019-07-12 18:06                     ` Bernard Metzler
2019-07-12 16:12               ` Peter Zijlstra
2019-07-25 17:23 ` Jason Gunthorpe [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=20190725172301.GA6225@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=arnd@arndb.de \
    --cc=bmt@zurich.ibm.com \
    --cc=dledford@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=peterz@infradead.org \
    /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