From owner-svn-src-all@freebsd.org Sat Aug 4 15:21:09 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6CC62106E88F; Sat, 4 Aug 2018 15:21:09 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E78047C015; Sat, 4 Aug 2018 15:21:08 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by mail-lj1-f174.google.com with SMTP id w16-v6so7226996ljh.12; Sat, 04 Aug 2018 08:21:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GW4lXYu0VS+VseO3KBrLpOYA65/d62U5pa3g6NnDvHg=; b=pgeIJPBGT0SB5cvGkv/hJ9o9qTEvG48L0onGxK6FsYEwBxfwlkuvBu4XC6PT3XdcHl vXw9jQhP4/oAn7Jnx+JU6IAGshw+A7zwmernPHgrWQlLVG79qcT7Xz8qazapibrlPE23 GCfC9gPwDWVg+KnYG2sxU2roR6n2s5KLdJDVUJOUGzLd1GGCNkzsv9oC7adoh/12YOxW i3T5pUbybYT42Vmow8jBs8BCts0zrU3JMjpjHG/OiNeqq2krd1DrwbDXuCDPuO1IWBpq hE2rr39i/WDBWolBJ7TGtV2fqu840oXSRThr7ohc8Amxbb0lO1ckY8U/zk36XaJTgpQw XFgA== X-Gm-Message-State: AOUpUlECetaouf4i/EULcK6DDVLotzs3nqE+66lmCyahWGL55HCLB9o+ gA4Olk57pWxnBty2XqA/riu9P0u/u8I2XOTl+N+B0LD1 X-Google-Smtp-Source: AAOMgpdix+OHZx9lQDw7u26JuEO5BIJjyefdBQ3LqjCRnmSk3fTVB/Ujjm5qOJT1kD/3aqrxz370Qdo1xmnH47ojXCs= X-Received: by 2002:a2e:91d6:: with SMTP id u22-v6mr8053219ljg.64.1533396060724; Sat, 04 Aug 2018 08:21:00 -0700 (PDT) MIME-Version: 1.0 References: <201808032004.w73K46XJ053249@repo.freebsd.org> <20180804080840.GI6049@kib.kiev.ua> <20180804130315.GK6049@kib.kiev.ua> <1533395475.9860.9.camel@freebsd.org> In-Reply-To: <1533395475.9860.9.camel@freebsd.org> From: Justin Hibbits Date: Sat, 4 Aug 2018 10:20:50 -0500 Message-ID: Subject: Re: svn commit: r337273 - head/sys/dev/nvme To: Ian Lepore Cc: Konstantin Belousov , John Baldwin , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Aug 2018 15:21:09 -0000 On Sat, Aug 4, 2018, 10:11 Ian Lepore wrote: > On Sat, 2018-08-04 at 08:29 -0500, Justin Hibbits wrote: > > On Sat, Aug 4, 2018, 08:03 Konstantin Belousov > wrote: > > > > > > > > On Sat, Aug 04, 2018 at 05:14:31AM -0700, John Baldwin wrote: > > > > > > > > On 8/4/18 1:08 AM, Konstantin Belousov wrote: > > > > > > > > > > On Fri, Aug 03, 2018 at 08:04:06PM +0000, Justin Hibbits wrote: > > > > > > > > > > > > Author: jhibbits > > > > > > Date: Fri Aug 3 20:04:06 2018 > > > > > > New Revision: 337273 > > > > > > URL: https://svnweb.freebsd.org/changeset/base/337273 > > > > > > > > > > > > Log: > > > > > > nvme(4): Add bus_dmamap_sync() at the end of the request path > > > > > > > > > > > > Summary: > > > > > > Some architectures, in this case powerpc64, need explicit > > > synchronization > > > > > > > > > > > > > > > > > > > > > barriers vs device accesses. > > > > > > > > > > > > Prior to this change, when running 'make buildworld -j72' on a > > > 18-core > > > > > > > > > > > > > > > > > > > > > (72-thread) POWER9, I would see controller resets often. With > this > > > change, I > > > > > > > > > > > > > > > > > > > > > don't see these resets messages, though another tester still > does, > > > for yet to be > > > > > > > > > > > > > > > > > > > > > determined reasons, so this may not be a complete fix. > > > Additionally, I see a > > > > > > > > > > > > > > > > > > > > > ~5-10% speed up in buildworld times, likely due to not needing > to > > > reset the > > > > > > > > > > > > > > > > > > > > > controller. > > > > > > > > > > > > Reviewed By: jimharris > > > > > > Differential Revision: https://reviews.freebsd.org/D16570 > > > > > > > > > > > > Modified: > > > > > > head/sys/dev/nvme/nvme_qpair.c > > > > > > > > > > > > Modified: head/sys/dev/nvme/nvme_qpair.c > > > > > > > > > > ============================================================================== > > > > > > > > > > > > > > > > > > > > > --- head/sys/dev/nvme/nvme_qpair.c Fri Aug 3 19:24:04 2018 > > > (r337272) > > > > > > > > > > > > > > > > > > > > > +++ head/sys/dev/nvme/nvme_qpair.c Fri Aug 3 20:04:06 2018 > > > (r337273) > > > > > > > > > > > > > > > > > > > > > @@ -401,9 +401,13 @@ nvme_qpair_complete_tracker(struct > nvme_qpair > > > *qpair, > > > > > > > > > > > > > > > > > > > > > req->retries++; > > > > > > nvme_qpair_submit_tracker(qpair, tr); > > > > > > } else { > > > > > > - if (req->type != NVME_REQUEST_NULL) > > > > > > + if (req->type != NVME_REQUEST_NULL) { > > > > > > + bus_dmamap_sync(qpair->dma_tag_payload, > > > > > > + tr->payload_dma_map, > > > > > > + BUS_DMASYNC_POSTREAD | > BUS_DMASYNC_POSTWRITE); > > > > > > bus_dmamap_unload(qpair->dma_tag_payload, > > > > > > tr->payload_dma_map); > > > > > > + } > > > > > > > > > > > > nvme_free_request(req); > > > > > > tr->req = NULL; > > > > > > @@ -487,6 +491,8 @@ nvme_qpair_process_completions(struct > nvme_qpair > > > *qpai > > > > > > > > > > > > > > > > > > > > > */ > > > > > > return (false); > > > > > > > > > > > > + bus_dmamap_sync(qpair->dma_tag, qpair->queuemem_map, > > > > > > + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); > > > > > > while (1) { > > > > > > cpl = qpair->cpl[qpair->cq_head]; > > > > > > > > > > > > @@ -828,7 +834,16 @@ nvme_qpair_submit_tracker(struct nvme_qpair > > > *qpair, st > > > > > > > > > > > > > > > > > > > > > if (++qpair->sq_tail == qpair->num_entries) > > > > > > qpair->sq_tail = 0; > > > > > > > > > > > > + bus_dmamap_sync(qpair->dma_tag, qpair->queuemem_map, > > > > > > + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); > > > > > > +#ifndef __powerpc__ > > > > > > + /* > > > > > > + * powerpc's bus_dmamap_sync() already includes a heavyweight > > > sync, but > > > > > > > > > > > > > > > > > > > > > + * no other archs do. > > > > > > + */ > > > > > > wmb(); > > > > > > +#endif > > > > > What is the purpose of this call ? It is useless without paired > read > > > > > barrier. So where is the reciprocal rmb() ? > > > > For DMA, the rmb is in the device controller. However, architectures > > > > that need this kind of ordering should do it in their bus_dmmap_sync > op, > > > > and this explicit one needs to be removed. (Alpha had a wmb in its > > > > bus_dmamap_sync op for this reason.) > > > Yes, if something special is needed, it should happen in > platform-specific > > > busdma code. > > > > > > Also, if wmb() is needed, then it is not a supposed semantic or > > > wmb(), but a specific side-effects of one of the instruction in the > > > implementation of wmb(). > > > > > > As I noted, on x86 it is not needed and detrimental to the performance. > > > > > According to Jim Harris it is needed for x86. I tried to remove it > thinking > > it was unnecessary with the sync in place now. The wmb() was added way > > back in r240616 by him, when only x86 was supported by the driver. > > bus_dmamap_sync() for all archs except powerpc lack a barrier, from what > I > > can see. See the review for more discussion that took place. If it isn't > > needed I will gladly remove it. > > > > The arm busdma sync routines definitely invoke the necessary barriers, > which on arm are spelled 'dsb' and 'isb' and are in the low-level > routines called from the busdma code, such as dcache_wb_pou(), > dcache_inv_poc(), etc. > > -- Ian > You're right, I missed that when I searched. X86 does not, it appears, even in the case of needing bounce buffers. The wmb() had been in since the beginning. Someone with x86 hardware should test before it's removed. I have none myself. - Justin >