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.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 E389BC43603 for ; Mon, 9 Dec 2019 20:53:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 93A5B205C9 for ; Mon, 9 Dec 2019 20:53:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YOc/pTpI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93A5B205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3D2F06B289F; Mon, 9 Dec 2019 15:53:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 382AF6B28A0; Mon, 9 Dec 2019 15:53:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 298EB6B28A1; Mon, 9 Dec 2019 15:53:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id 112506B289F for ; Mon, 9 Dec 2019 15:53:02 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id A11DF45AA for ; Mon, 9 Dec 2019 20:53:01 +0000 (UTC) X-FDA: 76246802562.22.route90_719b94ded7c25 X-HE-Tag: route90_719b94ded7c25 X-Filterd-Recvd-Size: 7855 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Dec 2019 20:53:00 +0000 (UTC) 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-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-3mrlVHspMpqq-gBkd_IAFQ-1; Mon, 09 Dec 2019 15:52:58 -0500 Received: by mail-wm1-f69.google.com with SMTP id o205so236631wmo.5 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=clGQob6G78Zr0v3A84HStXeWVCv+AVogys/J+W06kdg4MNZUMVNQTeXir2Y9+u4R2g TC7kqf3iWGnBxH+9TrZscfzUc92oF880bR7vygvcIPYaux8DVBLy/9nb0HlQ3uv7Z/5J gXh7VxqWKUUr000EDlOahQ+4s7sdnL/N5wQD/aNCGQBydHfBPEGIP5N/GM0Co7vva21b gRH/z8Qs33hUH/Ybi0GxMN2pWGLa6TO8zS7Nwge+4yOkbBZAJ9TpYTM0SE3yRO9uwTly RslVMYT8wXFen6X2wJpGnNHMe4o6laelOKSilQRD74TsGGRXX3qiG9G69vZTSgjvR/Xf 7awg== X-Gm-Message-State: APjAAAV7/z3YuuC3E8+6dqqqqK773fVi1EKScSONRNdIxA8aEbxoeBBO tkd9oer/YgDtkMMxq1bT3TNSruheErbXGWXnHtrMj0hyz/bwG4y+Pl7PvOPSLtMfzKxd63g1Etb YJqlUnjMnaYg= X-Received: by 2002:a1c:4c10:: with SMTP id z16mr1076749wmf.136.1575924775717; Mon, 09 Dec 2019 12:52:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzZrY86SAs9HX0pRhK9obPbaChosiTAnQWyc7+/5zfbpOwHVpMjKo7v99fnszsIjFo82bF44w== 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: 3mrlVHspMpqq-gBkd_IAFQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: > 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!