Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4556812ybl; Mon, 9 Dec 2019 12:54:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwqKm0acR5INyF1/jHcR+RPehSMkrJAM/HR5I1BguLOnSv3a7SwHSSElimIhzOkeNnol8uq X-Received: by 2002:a05:6808:3bc:: with SMTP id n28mr955388oie.112.1575924842038; Mon, 09 Dec 2019 12:54:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575924842; cv=none; d=google.com; s=arc-20160816; b=GTTEiKasLT6F1Rws6pqnJeH90qQm/5356tqeZegw+XyZcv5DcPwSmn/ZlPKe4uBR42 ncXixZ/+fWbroXFwaSP259v1gIakb8SVXi3DGIrf+W+TwJPk4TwqQedeJmYavFdX6gfw 7GkscLsrNqbQ2b3In6GHjcBtichtl4tnGYh3Fy26BY9cWfGkib5sFRCWo/5IjQB/JO1T NKsqzguScIWnlSpE3vwB5IWUyICMFvMo0wiorbURHx9r5MK1QsbKkfjOhRIjKrvL98MN HDF5WJmtwXSEeLef1CTmho3/JZvp8SjmnWRCKaBGGecfawqWor0cIILjj2fMjE/yNlvd H6jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:to:in-reply-to :cc:references:message-id:date:subject:mime-version:from :dkim-signature; bh=LJBASH3qoTGdWSdB+LrXLR7p2EO5j8Zhq+6mo6vrhH0=; b=VVQg6Lso4kGI6ZWjpxoXRznGSKzgRDlEqTr5pqx2ZGbSGVLlaIAcgpFIU9ymnAimUL i+kfuxOHWv46skXCCklFUT7weAzIoM7lYGi5u3plFPSeMMYDzrgjQSDoIISANw099xhc rCDy0kBoSrX7q4qlO7xmCs4+TxtqbFX6MVRIDrL94hn+RE4UTgj427i1TfHFVRPBoisr kioQmgak7HXdgHrORttiTXvLZqSrsvL+1Ed4zl2C0cWMViH4i+BDQTxDj1GzXuIjWY41 jSkaF5l9kjLLxYvpwfEygkhYc2hBJxfL4oOYl70qnbtZpd6aC/svwobIXnUi2SqFaDah e4BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="YOc/pTpI"; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 10si646785ois.76.2019.12.09.12.53.49; Mon, 09 Dec 2019 12:54:02 -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=@redhat.com header.s=mimecast20190719 header.b="YOc/pTpI"; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbfLIUxC (ORCPT + 99 others); Mon, 9 Dec 2019 15:53:02 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47090 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726408AbfLIUxB (ORCPT ); Mon, 9 Dec 2019 15:53:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575924780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LJBASH3qoTGdWSdB+LrXLR7p2EO5j8Zhq+6mo6vrhH0=; b=YOc/pTpISDyGxrj+xe2wlK9aQ4q2aKjtT5OSkNHKYQpVataqJ5Nwg4B8O7oJ7pe06kunRi w6+uU+YWfjwFCwsomygSPvGJzCAz8lMwkSqbhEOaGYoMxEGqNGMvfdzm3/7hDvrsa41Z8/ ZqdXfBBDPo7ARaAjIo6ScBhzjyH17pk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319--6ZnxKI4M3mmFNravhecog-1; Mon, 09 Dec 2019 15:52:58 -0500 Received: by mail-wr1-f69.google.com with SMTP id u12so8015679wrt.15 for ; Mon, 09 Dec 2019 12:52:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=NGEL1NSYmJ/OoSlxzf6M70RXjEhwqgGKnWSMvOS+jtM=; b=oJKMxMsr22wQzdOq29EFmOJRt00h/E55qxkY/YndQxyBmBpev7nEQplXjNFkFihZ27 ZvVJGRLdzXbiEPjOJJd9F3+AGMZJgMzL0aSD9JZjlAGloHaoDVl4TmjBC3fAqcUsqYor /iBzWT6jw/LTKgYGn67ulYxmxx+JZghzLcUHLliGORnLXGIJlAImA0t7Aeql4raFGtjk eiJ/p2Ul2SbOpdf9cgjtlOaLyUb0m3u+B32gquGAFnmgPWw5ZP5iX7P2ciBvyzkZTYHC cJ5Tekwp2yBK3f2ifKhCbhLrJC5nweilgedSpZ2XXtwZXg5sgayLgeRCqyIBRF71GIfh gGDA== X-Gm-Message-State: APjAAAWLhZyvBq1Zr6u/0PE1Co/cPxT3GygAlp1FdTxxVOMLdkaZr0IF q/Tuqxt3agREhm0in3DUl3G+NM81/SdV5iIK/++FuYcIfYrILFK+F318sy79wAUZ3A9C9Da97Kv op8OMhDkpScsQbaWqxgtMQk08 X-Received: by 2002:a1c:4c10:: with SMTP id z16mr1076740wmf.136.1575924775716; Mon, 09 Dec 2019 12:52:55 -0800 (PST) X-Received: by 2002:a1c:4c10:: with SMTP id z16mr1076719wmf.136.1575924775493; Mon, 09 Dec 2019 12:52:55 -0800 (PST) Received: from [192.168.3.122] (p5B0C63FA.dip0.t-ipconnect.de. [91.12.99.250]) by smtp.gmail.com with ESMTPSA id d8sm726691wre.13.2019.12.09.12.52.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Dec 2019 12:52:54 -0800 (PST) From: David Hildenbrand Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 5/6] mm, memory_hotplug: Provide argument for the pgprot_t in arch_add_memory() Date: Mon, 9 Dec 2019 21:52:53 +0100 Message-Id: References: Cc: Logan Gunthorpe , 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 In-Reply-To: To: Dan Williams X-Mailer: iPhone Mail (17A878) X-MC-Unique: -6ZnxKI4M3mmFNravhecog-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Am 09.12.2019 um 21:43 schrieb Dan Williams : >=20 > =EF=BB=BFOn Mon, Dec 9, 2019 at 12:24 PM Logan Gunthorpe wrote: >>=20 >>=20 >>=20 >>> 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 crea= te >>>> struct page mappings for IO memory. At present, these mappings are cre= ated >>>> 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. >>>>=20 >>>> Other arches are not currently likely to function correctly seeing the= y >>>> don't have any MTRR registers to fall back on. >>>>=20 >>>> To solve this, add an argument to arch_add_memory() to explicitly >>>> set the pgprot value to a specific value. >>>>=20 >>>> 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 explicit= ly >>>> using _set_memory_prot() (seeing they are already mapped). For sh, rej= ect >>>> anything but PAGE_KERNEL settings -- this should be fine, for now, see= ing >>>> sh doesn't support ZONE_DEVICE anyway. >>>>=20 >>>> 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(-) >>>>=20 >>>> 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) >>>> } >>>>=20 >>>> #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) >>>=20 >>> Can we fiddle that into "struct mhp_restrictions" instead? >>=20 >> 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. >=20 > +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'? >=20 I=E2=80=98d prefer that over an arch_add_memory_protected() as suggested by= Michal. But if we can change it after adding the memory (as also suggested= by Michal), that would also be nice. Cheers!