Skip to content

Commit

Permalink
mlx5: Optimize post_send barriers
Browse files Browse the repository at this point in the history
In ARCH(s) that spinlock() serves also as SFENCE prevent
an another explicit SFENCE. (e.g. X86).

To prevent an extra 'if' to know whether lock is really taken and it's
not a single threaded application encapsulates the mlx5_single_threaded
flag as part of bf->need_lock.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
  • Loading branch information
yishaih committed Mar 14, 2017
1 parent 278687d commit 1e8a68e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion providers/mlx5/mlx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ static int get_num_low_lat_uuars(int tot_uuars)
*/
static int need_uuar_lock(struct mlx5_context *ctx, int uuarn)
{
if (uuarn == 0)
if (uuarn == 0 || mlx5_single_threaded)
return 0;

if (uuarn >= (ctx->tot_uuars - ctx->low_lat_uuars) * 2)
Expand Down
7 changes: 4 additions & 3 deletions providers/mlx5/qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,11 +930,11 @@ static inline int _mlx5_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,

/* Make sure that the doorbell write happens before the memcpy
* to WC memory below */
mmio_wc_start();

ctx = to_mctx(ibqp->context);
if (bf->need_lock)
mlx5_spin_lock(&bf->lock);
mmio_wc_spinlock(&bf->lock.lock);
else
mmio_wc_start();

if (!ctx->shut_up_bf && nreq == 1 && bf->uuarn &&
(inl || ctx->prefer_bf) && size > 1 &&
Expand All @@ -953,6 +953,7 @@ static inline int _mlx5_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
* writes doorbell 2, and it's write is flushed earlier. Since
* the mmio_flush_writes is CPU local, this will result in the HCA seeing
* doorbell 2, followed by doorbell 1.
* Flush before toggling bf_offset to be latency oriented.
*/
mmio_flush_writes();
bf->offset ^= bf->buf_size;
Expand Down

0 comments on commit 1e8a68e

Please sign in to comment.