From patchwork Thu Mar 9 15:42:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 9613593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C6DF560414 for ; Thu, 9 Mar 2017 15:42:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8A512867E for ; Thu, 9 Mar 2017 15:42:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C06928680; Thu, 9 Mar 2017 15:42:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06E522867E for ; Thu, 9 Mar 2017 15:42:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932164AbdCIPmh (ORCPT ); Thu, 9 Mar 2017 10:42:37 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36662 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932275AbdCIPmX (ORCPT ); Thu, 9 Mar 2017 10:42:23 -0500 Received: by mail-wm0-f65.google.com with SMTP id v190so11551451wme.3 for ; Thu, 09 Mar 2017 07:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=ZJzHEvjFPKvxizce/9IFGXirWZFwlYcjNP4Zx9kdeAM=; b=Yxge2lfEUyCO80EShSgicvOIV1Kgq3l/yr1Uhz2O5uOjCeV3CltRQ9b0TdtkXg2wtp Ei49VXIYe3nP3TJ60VP7ZXsEn3mYOwBvWUVirsQwF6Y+NpjqK94HHbRKaEISGNLKjy7I C26OoxmnKNvb58bq8zr6ryvjzCspuDRD9bT/xhRYbzvCgL+z1ixLPPC/H0j/fvZ+Meo0 cbOt9woblPDL+CmBh6PIlgYD0dcvyEDTtzakaSmE17m8VVLdMuHN9k8HD0n2z39WXNe4 g7zIBfZVygXT+DxhwpNJzkruJVhqV3d2nQ3MV5HXaQI/UlKAkRHDH3x+spqyktaJI+v6 zV4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ZJzHEvjFPKvxizce/9IFGXirWZFwlYcjNP4Zx9kdeAM=; b=ik04M0t/3WvYCAHxQXt8KMG1irEyvAXAIFX/heDOUuw/6Hki8UHoIr6va/KGQk1VDh 8hkEt72nrNCx9zY13+YIj4bup6dXub4C1R3aOM1zEysCvGt/G4str+zT69ff5BERMCqh sSRx1e6UnV/wmXcT40ohQbF63mSWexmGnT0dVbKtf+UG28PdmASzdjXxRjQaNK9F224G ggQDZNWXjpVTHCT39idKgoncXOY/p5gzPKGbe3MmcyGRYn2Lr8b77DhHIB4jZ3AzMy2F ePWMSyAJ0SvNoIeNlRECzS5kGK3r/Q8B3X+01m2+TTuYpUffnnFmhN96rDD4BjYrje+v oh/Q== X-Gm-Message-State: AMke39lR4mZxSg2fHdYRL7Wf0V/UDOl7lo3K3T17o9YKyG74Pm01HmCUpSrEJB27IzLP3A== X-Received: by 10.28.107.14 with SMTP id g14mr30080220wmc.106.1489074141716; Thu, 09 Mar 2017 07:42:21 -0800 (PST) Received: from [10.8.0.220] ([193.47.165.251]) by smtp.googlemail.com with ESMTPSA id w4sm22977660wmg.25.2017.03.09.07.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 07:42:20 -0800 (PST) Subject: Re: [PATCH rdma-core 07/14] mlx4: Update to use new udma write barriers To: Jason Gunthorpe References: <1487272989-8215-1-git-send-email-jgunthorpe@obsidianresearch.com> <1487272989-8215-8-git-send-email-jgunthorpe@obsidianresearch.com> <206559e5-0488-f6d5-c4ec-bf560e0c3ba6@dev.mellanox.co.il> <20170221181407.GA13138@obsidianresearch.com> <45d2b7da-9ad6-6b37-d0b2-00f7807966b4@dev.mellanox.co.il> <20170306173139.GA11805@obsidianresearch.com> <55bcc87e-b059-65df-8079-100120865ffb@dev.mellanox.co.il> <20170307191824.GD2228@obsidianresearch.com> <6571cf34-63b9-7b83-ddb0-9279e7e20fa9@dev.mellanox.co.il> <20170308215609.GB4109@obsidianresearch.com> Cc: linux-rdma@vger.kernel.org, Yishai Hadas , Matan Barak , Majd Dibbiny , Doug Ledford From: Yishai Hadas Message-ID: <4dcf0cea-3652-0df2-9d98-74e258e6170a@dev.mellanox.co.il> Date: Thu, 9 Mar 2017 17:42:19 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20170308215609.GB4109@obsidianresearch.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 3/8/2017 11:56 PM, Jason Gunthorpe wrote: > On Wed, Mar 08, 2017 at 11:27:51PM +0200, Yishai Hadas wrote: > >> As of that any command that needs the lock must be done before the >> flush and delays the hardware from see the BF data immediately. > > The counter point is that the unlock macro can combine the WC flushing > barrier with the spinlock atomics, reducing the amount of global > fencing. If you remove the macro your remove that optimization. The optimization is done as part of mmio_wc_spinlock() for X86, this macro is still used. > > Why not do this: > > - mlx4_bf_copy(ctx->bf_page + ctx->bf_offset, (unsigned long *) ctrl, > - align(size * 16, 64)); > - > + tmp_bf_offset = ctx->bf_offset; > ctx->bf_offset ^= ctx->bf_buf_size; The above 2 commands are still delaying the writing to the NIC comparing the original code where it was done in one command after mlx4_bf_copy(). > + mlx4_bf_copy(ctx->bf_page + tmp_bf_offset, (unsigned long *) ctrl, > + align(size * 16, 64)); > The candidate mlx4 code will be as follows, similar logic will be in mlx5. @@ -477,22 +474,18 @@ out: ctrl->owner_opcode |= htonl((qp->sq.head & 0xffff) << 8); ctrl->bf_qpn |= qp->doorbell_qpn; + ++qp->sq.head; /* * Make sure that descriptor is written to memory * before writing to BlueFlame page. */ - mmio_wc_start(); - - ++qp->sq.head; - - pthread_spin_lock(&ctx->bf_lock); + mmio_wc_spinlock(&ctx->bf_lock); mlx4_bf_copy(ctx->bf_page + ctx->bf_offset, (unsigned long *) ctrl, align(size * 16, 64)); mmio_flush_writes(); ctx->bf_offset ^= ctx->bf_buf_size; pthread_spin_unlock(&ctx->bf_lock); } else if (nreq) { qp->sq.head += nreq; operations. If you @@ -222,4 +224,17 @@ */ #define mmio_ordered_writes_hack() mmio_flush_writes() +/* Higher Level primitives */ + +/* Do mmio_wc_start and grab a spinlock */ +static inline void mmio_wc_spinlock(pthread_spinlock_t *lock) +{ + pthread_spin_lock(lock); +#if !defined(__i386__) && !defined(__x86_64__) + /* For x86 the serialization within the spin lock is enough to + * strongly order WC and other memory types. */ + mmio_wc_start(); +#endif +} + --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/util/udma_barrier.h b/util/udma_barrier.h index 9e73148..ec14dd3 100644 --- a/util/udma_barrier.h +++ b/util/udma_barrier.h @@ -33,6 +33,8 @@ #ifndef __UTIL_UDMA_BARRIER_H #define __UTIL_UDMA_BARRIER_H +#include + /* Barriers for DMA. These barriers are explicitly only for use with user DMA