Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1397746ybf; Thu, 27 Feb 2020 10:10:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwQApaBBKrqXkA20aHf2dhrQ76t9CL4fljToTJkKkoJ5XoeDHKXhNVcImBX4FRdoAhuDhJX X-Received: by 2002:a05:6808:9b4:: with SMTP id e20mr207849oig.37.1582827046555; Thu, 27 Feb 2020 10:10:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582827046; cv=none; d=google.com; s=arc-20160816; b=G/5A7RdJlznxAQnqKL4sRNgZSlof4N6bYP6xCpMbH2VU+XiJsL8rmNFga6HeWScp1G qnCPwo6+xLfBHDpjj+3K1D4r+pPV4rMnFZkx4exC4NqTOY7LAM7eimf9qSLcWhCCso/V SNI6SDIe9GOr180k+iXkxIe+HtZFSgLGt/mELXM16xP7eBzjfv1C7x5DpzxUGZaUXwDA ZY3KCo+f9bMkB+fcOn8DW4Fot96IpqUAX+ikxEn+RLlPMgSxgl6HtdFzMtWYt9Uie7lm 8MDAMlHKAsuW6znG/2x3vDn+S8PcChTYgI8QdBp5Mwk1I1+S8W6wrg015KsKusCjPViq kkwQ== 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 :in-reply-to:references:mime-version:dkim-signature; bh=4F3CkEYboenOdYfvgxaEFjzaB88Ias8AvgF6y2bsYJo=; b=nlKTdWuvxMDKwkDhBlDGJeW9FvvPKg3UW8akgQ+jjn8L9ITM3SS7U7YY3i79Y37LMj imeKhTN6hs8AKh8hDNqFyyVc7++7S6mKzEbTfyD1VfHa2hxZlJ6McCJu2UWQhiwtFOwa mp0bAA65Ds//F7mOUDBfaONQf/82tnJoVlbYXIS86bttTigZOQMBANmW68C5WXtcCH17 hIYPosJ0Z1K6f5cSUCKhMhHCOn3aGzqV2C7P8vJVvsWkhq72nfWiSBBOv8YBnIM2kvHZ fmqalahgyUkFUvMzvREPoRz7+YJgXqZgZzKvr2diMtpw1zC+cxBCAdaZa6Wwc8+xV4Qb ay8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="btVB1/kC"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6si279799oic.34.2020.02.27.10.10.34; Thu, 27 Feb 2020 10:10:46 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="btVB1/kC"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729891AbgB0SIV (ORCPT + 99 others); Thu, 27 Feb 2020 13:08:21 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:39764 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729427AbgB0SIV (ORCPT ); Thu, 27 Feb 2020 13:08:21 -0500 Received: by mail-ot1-f65.google.com with SMTP id x97so40486ota.6 for ; Thu, 27 Feb 2020 10:08:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4F3CkEYboenOdYfvgxaEFjzaB88Ias8AvgF6y2bsYJo=; b=btVB1/kCSyh3miQnMYs3e17lMek8QSVYBuP0FlHl1SN8jj8AK7ZcsZTrZLYZcDr8L0 NSJ9MeY7RriOXGf8mxUIHycStwVTMNeNi3yrQla6dMYLj551Rp9KWZnTu9g5AKGKvvYT 9WlFsCXT0V4ckXbqldT9RpXG/xwR6Da9kdRkEzPi8tdoEUk2abNALGro5ZLdP/rXl0tG /sptmzlpcqEIizzSfsWPT6ZSjga8U2PolwmP3cK/7EJmAplRWGpIpx3oVOIujglDOBPB U/jmRkYeKgZuoKDQ/uKn2xiCIfawYUF6S/k5E1dLzCZ3Me3N7Bit13cPq5fiueJNzJqi dLRw== 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=4F3CkEYboenOdYfvgxaEFjzaB88Ias8AvgF6y2bsYJo=; b=Fv4jJawRRfa2EFGDw9QTOM0KoUrC4aZYXMUYpyfocpsyK8tL8Hn8EYILD21wta2wLQ TYFjy48HYHsDyghu5ka/ZlYne9Ud+vcvbtvgBdKVB/4aKrcsnvzI87LQ6MtRfAAeT9rb 0KygkErZcwjMrlxWq/XkitBk5ymDz0OATZbpe0f1dMbRjPcmZtWSfMDytIi+wyv+CYCZ Vi9NWZineHZSpLzHILTICdXV15UkUuy0yzTYXgp7Xq4aFNhnXpEDWS236XQDidfkmKQw e6zdl0MvyeH7Rw8cl5//qz+9YKm5LVMPIXgKg+3dNJAAXcD4RO/EguGuN7CHY4t1bW05 h3+Q== X-Gm-Message-State: APjAAAUhEUDpRaSi9cWxvh7RZoKZ1SjU+rbcbGa92DdbpyQGVgceBH9e +VFKpCP9N5Atj4hc3Olz2ki/AhN6tJI7LdKFakWWxQ== X-Received: by 2002:a9d:6c9:: with SMTP id 67mr93279otx.363.1582826900650; Thu, 27 Feb 2020 10:08:20 -0800 (PST) MIME-Version: 1.0 References: <20200221182503.28317-1-logang@deltatee.com> <20200227171704.GK31668@ziepe.ca> <20200227174311.GL31668@ziepe.ca> <20200227180346.GM31668@ziepe.ca> In-Reply-To: <20200227180346.GM31668@ziepe.ca> From: Dan Williams Date: Thu, 27 Feb 2020 10:08:09 -0800 Message-ID: Subject: Re: [PATCH v3 0/7] Allow setting caching mode in arch_add_memory() for P2PDMA To: Jason Gunthorpe Cc: Logan Gunthorpe , Linux Kernel Mailing List , Linux ARM , linux-ia64@vger.kernel.org, linuxppc-dev , linux-s390 , Linux-sh , platform-driver-x86@vger.kernel.org, Linux MM , Michal Hocko , David Hildenbrand , Andrew Morton , Christoph Hellwig , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Eric Badger 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 Thu, Feb 27, 2020 at 10:03 AM Jason Gunthorpe wrote: > > 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. Ah, yes, agree.