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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 68AB0C43603 for ; Mon, 9 Dec 2019 20:43:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A5022068E for ; Mon, 9 Dec 2019 20:43:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="s8JcQPtb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A5022068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BF0966B2897; Mon, 9 Dec 2019 15:43:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC7EA6B2898; Mon, 9 Dec 2019 15:43:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B04B16B2899; Mon, 9 Dec 2019 15:43:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id 9BD156B2897 for ; Mon, 9 Dec 2019 15:43:53 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 51AD8181AEF23 for ; Mon, 9 Dec 2019 20:43:53 +0000 (UTC) X-FDA: 76246779546.19.arch71_21d30fb68950f X-HE-Tag: arch71_21d30fb68950f X-Filterd-Recvd-Size: 6792 Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Dec 2019 20:43:52 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id i1so7637542oie.8 for ; Mon, 09 Dec 2019 12:43:52 -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=l/N3zYu2hShNrsn2UFuESmj5RasnmMJmSbm2uKixcCoXfv53ZiPg4vsBogHHbk0xyj PUaxBvI3FYjnUb2+PJUvOnaRU7VCSxOh/O8uubSftljv95bIw/N8f4Rpn0CHeCVBUWCs kj+fIWKdbtw/5sw0SXSBsnXu8ndR2Zn7sryp/rdqcQnNQrnKOXsn8l/2hQo9RTqhvbZB TDULecnTXyJjdWoia3sNF/2m/TdAv/oFalnTESt9d+C4BbM5WFlt3IC6kaMJEhBh7IBk dcKbZ1iz9HsJ3b0xL2naSqq8eq6qTomj9mLHGsE6A3T/8N3PpDsEDkDlhULz6kP5xiz/ 5u7A== X-Gm-Message-State: APjAAAUOljrU24HA2pTlaPWqm6hoxTjsHxkH/DDRLd+BYatX/ISc61A0 tngz0J5A+FexruBfd+2nQLG3uONyoRdG3oAQr2uMBQ== X-Google-Smtp-Source: APXvYqyeRHkHv/ywCxrBIm5A7egnQ5ryTQgyKvJL2kpqRDm3KyRgnulA7iNcBuX+BkZigYY9JneBtT9sFsmo5jtdPMY= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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'?