From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C874AC11D3D for ; Thu, 27 Feb 2020 18:06:22 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BC112469F for ; Thu, 27 Feb 2020 18:06:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="RAltTZst" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BC112469F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48T0wW0tZzzDqrN for ; Fri, 28 Feb 2020 05:06:19 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ziepe.ca (client-ip=2607:f8b0:4864:20::743; helo=mail-qk1-x743.google.com; envelope-from=jgg@ziepe.ca; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256 header.s=google header.b=RAltTZst; dkim-atps=neutral Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48T0sf48THzDqqW for ; Fri, 28 Feb 2020 05:03:49 +1100 (AEDT) Received: by mail-qk1-x743.google.com with SMTP id f3so259459qkh.3 for ; Thu, 27 Feb 2020 10:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YVEntATD8Di4X+bfE0q+dQjUPZodyWiwMumJsgAjImQ=; b=RAltTZstLeabLiJ0d66x7j4b8d0dFG+sPOHfpbO/cFKDi0l5MP5SaBmzQZcj23Dj9O F/bYYNBZZSSfyS9/dujI6RC7S6GQGiGhjfoRC4Je5Ph5T17ppPj/nNg6eK7g8v4ebWzu Qxmk3XbPh4QJMBWSZz4NrK//VIcI+eMAy0MaVJAPx5AhdQtsNg6OJfWlFI3uTppHsXSP NLDKJ/17oMjJmVhx6/pQNGEX+CmviRc1utdWSmUNrTHklbQUwh86mk+awHvAFbaKoddd 0oAlTI+2vm+ko8Vd1wYitYFGuU7IYpDc+5ksP1iJZ4Sf+eRw2yMQhLqeo1YoqRFOoTVh Z2sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YVEntATD8Di4X+bfE0q+dQjUPZodyWiwMumJsgAjImQ=; b=H2LWPDaCYm7gzPkjN77F5lxKHxzFiNORoA8n2ZIDhvruOPHxPAJXXXkI9IwoDE0hwg fhP+sNK0unlsvuKN1yRWqq9ApifVhV9EzDQ2JduIzHzSZ709GEdzn4hCrjAle1iv1VkE 10eijdBtiNaVwZBamLASGXd2FP8R0KrulLK2f550ZvYJAjSGJLvcwyBJH1/hZmSoZ5nH I89d4FgS95tIf9ebuj6WmaPb4ENhGltGK9g08QukjJnrdml7LWsTaLCrdceiPltXH1lQ rD51tU6a1joporbdAYLd5wb5m5tDkRhAeRPds0O6lV8iFq5SARqmvUkUxUPlpqD6CzUT kgpQ== X-Gm-Message-State: APjAAAXOkyXcfos6pzbFssxC5HAn8LmmHSN/Oa4Mm4spjVLJdwdNXjF2 8R0/qLRLsF2vCz8DyJt2kjfgUg== X-Google-Smtp-Source: APXvYqy6UDThfoJk2c6gSaNxuGupf3hgdusGohKCaZ7APtBt0Z8E4pxTDMcVw55YbgzfmGfI1mrhOg== X-Received: by 2002:a37:4e53:: with SMTP id c80mr533140qkb.58.1582826627303; Thu, 27 Feb 2020 10:03:47 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id e64sm3551886qtd.45.2020.02.27.10.03.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Feb 2020 10:03:46 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1j7NVi-0008Pb-Fb; Thu, 27 Feb 2020 14:03:46 -0400 Date: Thu, 27 Feb 2020 14:03:46 -0400 From: Jason Gunthorpe To: Dan Williams Subject: Re: [PATCH v3 0/7] Allow setting caching mode in arch_add_memory() for P2PDMA Message-ID: <20200227180346.GM31668@ziepe.ca> References: <20200221182503.28317-1-logang@deltatee.com> <20200227171704.GK31668@ziepe.ca> <20200227174311.GL31668@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ia64@vger.kernel.org, Linux-sh , Peter Zijlstra , Dave Hansen , platform-driver-x86@vger.kernel.org, Linux MM , Will Deacon , Christoph Hellwig , linux-s390 , David Hildenbrand , Ingo Molnar , Catalin Marinas , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , Michal Hocko , Linux ARM , linuxppc-dev , Eric Badger , Linux Kernel Mailing List , Andrew Morton , Logan Gunthorpe Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu, Feb 27, 2020 at 09:55:04AM -0800, Dan Williams wrote: > On Thu, Feb 27, 2020 at 9:43 AM Jason Gunthorpe wrote: > > > > On Thu, Feb 27, 2020 at 10:21:50AM -0700, Logan Gunthorpe wrote: > > > > > > > > > On 2020-02-27 10:17 a.m., Jason Gunthorpe wrote: > > > >> Instead of this, this series proposes a change to arch_add_memory() > > > >> to take the pgprot required by the mapping which allows us to > > > >> explicitly set pagetable entries for P2PDMA memory to WC. > > > > > > > > Is there a particular reason why WC was selected here? I thought for > > > > the p2pdma cases there was no kernel user that touched the memory? > > > > > > Yes, that's correct. I choose WC here because the existing users are > > > registering memory blocks without side effects which fit the WC > > > semantics well. > > > > Hm, AFAIK WC memory is not compatible with the spinlocks/mutexs/etc in > > Linux, so while it is true the memory has no side effects, there would > > be surprising concurrency risks if anything in the kernel tried to > > write to it. > > > > Not compatible means the locks don't contain stores to WC memory the > > way you would expect. AFAIK on many CPUs extra barriers are required > > to keep WC stores ordered, the same way ARM already has extra barriers > > to keep UC stores ordered with locking.. > > > > The spinlocks are defined to contain UC stores though. > > How are spinlocks and mutexes getting into p2pdma ranges in the first > instance? Even with UC, the system has bigger problems if it's trying > to send bus locks targeting PCI, see the flurry of activity of trying > to trigger faults on split locks [1]. This is not what I was trying to explain. Consider static spinlock lock; // CPU DRAM static idx = 0; u64 *wc_memory = [..]; spin_lock(&lock); wc_memory[0] = idx++; spin_unlock(&lock); You'd expect that the PCI device will observe stores where idx is strictly increasing, but this is not guarenteed. idx may decrease, idx may skip. It just won't duplicate. Or perhaps wc_memory[0] = foo; writel(doorbell) foo is not guarenteed observable by the device before doorbell reaches the device. All of these are things that do not happen with UC or NC memory, and are surprising violations of our programming model. Generic kernel code should never touch WC memory unless the code is specifically designed to handle it. Jason