Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4549065ybl; Mon, 9 Dec 2019 12:44:34 -0800 (PST) X-Google-Smtp-Source: APXvYqzGDwuTrSyMULdjN/ZbXneXzFNG/aFqtXw/9/JRIsVl7xI/dc0KeoccLSViTq2rwzc2Nmxc X-Received: by 2002:a9d:4f0e:: with SMTP id d14mr5039544otl.90.1575924274298; Mon, 09 Dec 2019 12:44:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575924274; cv=none; d=google.com; s=arc-20160816; b=m5eqzr016r6e+x5OGKjc2fdT/M/AP/UTu/+0EQqZLzNykGmjO4XERH4ITjreQpHBK0 GfpGZakp4rNapAJTKxGJ/xEicpCM7Ofksk/foXxuoYeTt73QXV3wid16YkMOFE9/QI8y Z4MojIvHX8pGkRzYfnTKmxKiXvQQQw7hYJxtUI2rP52O8DxFfOSa/k9Yj+MYOLr6NNDY KPO5hbNataomP5NmRKGx7trlokD8cF335b5pqVvq3arF0GVB6tlJa9gbrnSYqraRFVsu kX/WFDznsXKV+Yb2qaTkCWeCFe+41Acf39mqrKHTALoYTcuPdBgcCghNrAu6bgBVRsso FKrg== 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=plZMhK84PEv4yWmkyRgS9pvtlaQ95b7dai3GHtutF3U=; b=HR3Bfs87/rhrPl2l8gop/Bfqu0bo40EAg+8k2Hm65c2DeWXKhMo6cxjBhZUj6q7Va9 swSRqknLjARY5Ecn1TQG8+NWzNNoMsLTE+qG2sFDS+uIUrfka+5++3a77mx8/RNs8EuO TkCukI23FM5e4G4YuXhAWEgr8Tu5zFLVSANnTKIkMPtzljDnlCUaAupkqZw2Kelyp6hA obXgsLLMEsmD/CXeXL9hexzVDQP+F8wdJp8yXmEjmvKtxdtiuLf8TJ8U0eKc7Bx6DjLt f0R2VAAAB5l9hScqq5j1REvIYDdpMjadkOVbWGyAWMQJ4vZT48P8TO1oslFTqLSu9pJM Ij/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=s8JcQPtb; 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 x7si591805oia.165.2019.12.09.12.44.21; Mon, 09 Dec 2019 12:44:34 -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=s8JcQPtb; 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 S1726683AbfLIUny (ORCPT + 99 others); Mon, 9 Dec 2019 15:43:54 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:37095 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbfLIUnw (ORCPT ); Mon, 9 Dec 2019 15:43:52 -0500 Received: by mail-oi1-f195.google.com with SMTP id x195so7676206oix.4 for ; Mon, 09 Dec 2019 12:43:51 -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=plZMhK84PEv4yWmkyRgS9pvtlaQ95b7dai3GHtutF3U=; b=s8JcQPtbr+nVe651d3RxZBcB1lXgZKfKVFhn/ShuBpwGBroXkMdV+1srYkcwwzCfi/ 3AdkcPWeiO2eE4Vph0qmLnpLEA8qPwiUkiQSbuWv9LS1KxvGK3AP4uCAh+EMErUq8k74 L494AbumcLYt4cMYgyYMcdh6j0zlFuGJ8ZPSO2PxzpS4hTMg0sQG1PNOFwBWl5Zzp6eP Hwu+hbiTpbKnoLj6CsAujCqJSlm6zAkwyEntNz5bxfqTJjvUbj59ZsDept7jCzKEEbgY DvR3hVrw+BRWOH7VlzK3NLFoCEF6jALh7nekxLiYRnJ0XVoNr+Z9wuJ3vSGrSPuKoOPd 615w== 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=plZMhK84PEv4yWmkyRgS9pvtlaQ95b7dai3GHtutF3U=; b=fM6ZlfHqNyfut5m+3S3+0/o7vj7kxU7N4cmSp7yAFr4F+/7zgvbKToWDpsNosD9ooG 4OoOmtkB5bSm3+lKBZ2Kg/Oi08E53+CwCR3rpFoPq1XfpOkAf1p0yXOzpkt+MuxL1eA/ SpOrLm7ptLtEljjn3F2LBBWnkkeYG8W7JpfYzvpDVq+BHaeSNjleFGIH3UTD7a/9fZ2Z 9oQtEDl4rktC1Cn4Pw5YGaS2U7wPVx/KVfCwK0XoqrH/1ZIhw+pJKhrtdtBUxTyBUn2K negPU/dwwy9NqMFgMK58AZFzYXXaiNPsIhM0JjcV+9+hlXixEEz5IemRhkpdH0ZGSxbc dA8A== X-Gm-Message-State: APjAAAVjWoNVd1rpyLKEWDTBM9/LVvFEE0bmBWi7I58U4kaID1DW1aa4 vqkHvImimT1knwAjO0g0UbxeVkq7z19Hjq851RrdMQ== X-Received: by 2002:aca:4850:: with SMTP id v77mr913881oia.70.1575924231490; Mon, 09 Dec 2019 12:43:51 -0800 (PST) MIME-Version: 1.0 References: <20191209191346.5197-1-logang@deltatee.com> <20191209191346.5197-6-logang@deltatee.com> In-Reply-To: From: Dan Williams Date: Mon, 9 Dec 2019 12:43:40 -0800 Message-ID: Subject: Re: [PATCH 5/6] mm, memory_hotplug: Provide argument for the pgprot_t in arch_add_memory() To: Logan Gunthorpe Cc: David Hildenbrand , 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 , Christoph Hellwig , Andrew Morton , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Michal Hocko 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 Mon, Dec 9, 2019 at 12:24 PM Logan Gunthorpe wrote: > > > > On 2019-12-09 12:23 p.m., David Hildenbrand wrote: > > On 09.12.19 20:13, Logan Gunthorpe wrote: > >> devm_memremap_pages() is currently used by the PCI P2PDMA code to create > >> struct page mappings for IO memory. At present, these mappings are created > >> with PAGE_KERNEL which implies setting the PAT bits to be WB. However, on > >> x86, an mtrr register will typically override this and force the cache > >> type to be UC-. In the case firmware doesn't set this register it is > >> effectively WB and will typically result in a machine check exception > >> when it's accessed. > >> > >> Other arches are not currently likely to function correctly seeing they > >> don't have any MTRR registers to fall back on. > >> > >> To solve this, add an argument to arch_add_memory() to explicitly > >> set the pgprot value to a specific value. > >> > >> Of the arches that support MEMORY_HOTPLUG: x86_64, s390 and arm64 is a > >> simple change to pass the pgprot_t down to their respective functions > >> which set up the page tables. For x86_32, set the page tables explicitly > >> using _set_memory_prot() (seeing they are already mapped). For sh, reject > >> anything but PAGE_KERNEL settings -- this should be fine, for now, seeing > >> sh doesn't support ZONE_DEVICE anyway. > >> > >> Cc: Dan Williams > >> Cc: David Hildenbrand > >> Cc: Michal Hocko > >> Signed-off-by: Logan Gunthorpe > >> --- > >> arch/arm64/mm/mmu.c | 4 ++-- > >> arch/ia64/mm/init.c | 5 ++++- > >> arch/powerpc/mm/mem.c | 4 ++-- > >> arch/s390/mm/init.c | 4 ++-- > >> arch/sh/mm/init.c | 5 ++++- > >> arch/x86/mm/init_32.c | 7 ++++++- > >> arch/x86/mm/init_64.c | 4 ++-- > >> include/linux/memory_hotplug.h | 2 +- > >> mm/memory_hotplug.c | 2 +- > >> mm/memremap.c | 2 +- > >> 10 files changed, 25 insertions(+), 14 deletions(-) > >> > >> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > >> index 60c929f3683b..48b65272df15 100644 > >> --- a/arch/arm64/mm/mmu.c > >> +++ b/arch/arm64/mm/mmu.c > >> @@ -1050,7 +1050,7 @@ int p4d_free_pud_page(p4d_t *p4d, unsigned long addr) > >> } > >> > >> #ifdef CONFIG_MEMORY_HOTPLUG > >> -int arch_add_memory(int nid, u64 start, u64 size, > >> +int arch_add_memory(int nid, u64 start, u64 size, pgprot_t prot, > >> struct mhp_restrictions *restrictions) > > > > Can we fiddle that into "struct mhp_restrictions" instead? > > Yes, if that's what people want, it's pretty trivial to do. I chose not > to do it that way because it doesn't get passed down to add_pages() and > it's not really a "restriction". If I don't hear any objections, I will > do that for v2. +1 to storing this information alongside the altmap in that structure. However, I agree struct mhp_restrictions, with the MHP_MEMBLOCK_API flag now gone, has lost all of its "restrictions". How about dropping the 'flags' property and renaming the struct to 'struct mhp_modifiers'?