Received: by 10.223.185.116 with SMTP id b49csp3651301wrg; Tue, 6 Mar 2018 02:42:10 -0800 (PST) X-Google-Smtp-Source: AG47ELuoClCp7UHZJPp2FQ81fYSXTL5/7tcqB21/fCP7t21VVwaS3KNgLEUWxUCOd2TkXl3J6JT1 X-Received: by 10.101.65.203 with SMTP id b11mr14849825pgq.118.1520332930449; Tue, 06 Mar 2018 02:42:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520332930; cv=none; d=google.com; s=arc-20160816; b=L24Lg1XY9XNMLBVXSXrnAi8NAPgTo9iVjPbEJ0n8Nfy9//fuy+ZjYO78zKYf78Bxga 0oH726kDms1LVYCysfLVjotI+wKdtWCIUM7CwbfDjka2wf3moURvp3nqKihNEPmFUznZ iRpivVEB1J4ADlmUpTc4SDBcZW4P27DDlid1D9vvA0XV8hu7SSjxhpv5Nbw2KhhHNat1 Xnl8Ijz2Kb30/GY8sAo/K+p93uHAW3V/brNy6oCGv4FXxKlz/ou7WkosyB5CKItcfqhO Ca4bMMRNcQ0mc50CcViWJqC5H24n+3sWJH5weF4hw/A75EV6dcWP593TIhVzVwx4fbuo tlvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=GO+aBTDtL+Ckuy+WJK0L4gtnC6AryW2/N4ADkAbIIn0=; b=otu3rLDBfLtk6v9RAUobexQQ/iFAwuf4R24vr9hegot4ijhmrngOWhqYmkmrPFJlrf 7mIdf/MpG6DdWO7npFzSbvgtkejnn3H/M2Hpmv1mwJDLE6srpBy3yhEinTeUo3r9VNCU NJrlBayqGuoOOV7t6y9Z0SJN3IfwvQKhV/7DkaXjqI0xTyGxeloObC+tKkH/Ap9O5Q3U vs3P+AxRB4fz/HR5zyrhr6wwv65QNd176EKkS52ZbG06GHCeGisiekQJCAvmtK7j77+L FNA3stl5IcgGJSjI0o1+i7H+btdSFaIw5L7QCgzZMoW+eq3cnYViEHo1bTr8Bzos4JLp 4kXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uUl439cx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x87si11833838pff.17.2018.03.06.02.41.55; Tue, 06 Mar 2018 02:42:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uUl439cx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753369AbeCFKkz (ORCPT + 99 others); Tue, 6 Mar 2018 05:40:55 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:46229 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750933AbeCFKkx (ORCPT ); Tue, 6 Mar 2018 05:40:53 -0500 Received: by mail-qt0-f196.google.com with SMTP id m13so23943479qtg.13; Tue, 06 Mar 2018 02:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GO+aBTDtL+Ckuy+WJK0L4gtnC6AryW2/N4ADkAbIIn0=; b=uUl439cxu/Xzlhx13mXwjZzAa1I5cXJELhI4/+UFr5mfdMRKXQsB7qI+7otP/aqzIl gzSry6urKYWbHVTLHZzQmzhiWm2BNZZ2O6TP0x1eYSlzWUCwlp96fxq5g03iVsVBPsQg rgT58fG/J1l5f+8x9qY+TNxInUFgaMRkRLZA7nTQhOfsmBKxt1kIPSCcaGyojFs1/Ntl P1vbn00urNCXJ93v0jwFRILdddbtNPyamy6lf62xsJWfbxxfBODDxVrZpXpH5l/UK6Lh 5tOwLQiFxzQziMZXfDlLOWYzkVA5n51qC7ADl6Jn9B+Kmo28uKCJg4QjLh5oRo32A98T 2/bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GO+aBTDtL+Ckuy+WJK0L4gtnC6AryW2/N4ADkAbIIn0=; b=eWZ5e+T201NTfOtzWDBsmngiWhC+gzhu8PlVO+rLlPDkWNStvxHYPRs28VsFGIus1k QY9KPzI4/e/+2zpanzwf7mEpN08UKJS23DXPnD9fRt037tvcWBHGKctM/aq4bQ0vl6QM q6KZiLJ2P705CnoC39lz/XiiuaAKs0VnbXF2hhGq80d+tWhaMszDJC/t7+/FHv3xbCdk af+j6RbkGM5oYGE4tvdTg0eVS9Qu4CH6QSrkiIpiedeu1fNdeqzE/zEjU1/NGYn0qrcu lL7LEmyc1mTb8eWuEgV0TyLvSz/UE/R1eYRKMzr/CpZum2+zAHibP7JDu+jT9UTgQEu/ kitg== X-Gm-Message-State: AElRT7Fg0twoziIEKS7hkTAXiSTRaX/ghEFqgw5WdOWF7hCVs3PHrwCr OTNetPm2Gaxt/BDtKAEFjZnNhtvCfhV3DSpyq1Q= X-Received: by 10.237.63.220 with SMTP id w28mr28795858qth.312.1520332852208; Tue, 06 Mar 2018 02:40:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.104.143 with HTTP; Tue, 6 Mar 2018 02:40:51 -0800 (PST) In-Reply-To: <416d8d27-200f-befb-1c30-14544fffcba0@deltatee.com> References: <20180228234006.21093-1-logang@deltatee.com> <20180228234006.21093-8-logang@deltatee.com> <20180305160004.GA30975@localhost.localdomain> <3f56c76d-6a5c-7c2f-5442-c9209749b598@deltatee.com> <416d8d27-200f-befb-1c30-14544fffcba0@deltatee.com> From: Oliver Date: Tue, 6 Mar 2018 21:40:51 +1100 Message-ID: Subject: Re: [PATCH v2 07/10] nvme-pci: Use PCI p2pmem subsystem to manage the CMB To: Logan Gunthorpe Cc: Keith Busch , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, "linux-nvdimm@lists.01.org" , linux-block@vger.kernel.org, Jens Axboe , Benjamin Herrenschmidt , Alex Williamson , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Bjorn Helgaas , Max Gurtovoy , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 6, 2018 at 12:14 PM, Logan Gunthorpe wrote: > > On 05/03/18 05:49 PM, Oliver wrote: >> >> It's in arch/powerpc/kernel/io.c as _memcpy_toio() and it has two full >> barriers! >> >> Awesome! >> >> Our io.h indicates that our iomem accessors are designed to provide x86ish >> strong ordering of accesses to MMIO space. The git log indicates >> arch/powerpc/kernel/io.c has barely been touched in the last decade so >> odds are most of that code was written in the elder days when people >> were less aware of ordering issues. It might just be overly conservative >> by today's standards, but maybe not (see below). > > > Yes, that seems overly conservative. > >> (I'm not going to suggest ditching the lwsync trick. mpe is not going >> to take that patch >> without a really good reason) > > > Well, that's pretty gross. Is this not exactly the situation mmiowb() is > meant to solve? See [1]. Yep, mmiowb() is supposed to be used in this situation. According to BenH, author of that io_sync hack, we implement the stronger semantics so that we don't break existing drivers that assume spin_unlock() does order i/o even though it's not supposed to. At a guess the x86 version of spin_unlock() happens to do that so the rest of us need to either live with it or fix all the bugs :) > Though, you're right in principle. Even if power was similar to other > systems in this way, it's still a risk that if these pages get passed > somewhere in the kernel that uses a spin lock like that without an mmiowb() > call, then it's going to have a bug. For now, the risk is pretty low as we > know exactly where all the p2pmem pages will be used but if it gets into > other places, all bets are off. Yeah this was my main concern with the whole approach. For ioremap()ed memory we have the __iomem annotation to help with tracking when we need to be careful, but we'd lose that entirely here. > I did do some work trying to make a safe > version of io-pages and also trying to change from pages to pfn_t in large > areas but neither approach seemed likely to get any traction in the > community, at least not in the near term. It's a tricky problem. HMM with DEVICE_PRIVATE might be more palatable than the pfn_t conversion since there would still be struct pages backing the device memory. That said, there are probably other issues with device private memory not being part of the linear mapping, but HMM provides some assistance there. Oliver