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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AD25C433FE for ; Wed, 29 Sep 2021 12:09:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E4472610A2 for ; Wed, 29 Sep 2021 12:09:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E4472610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 613E094001D; Wed, 29 Sep 2021 08:09:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C3D26B0092; Wed, 29 Sep 2021 08:09:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43D4294001D; Wed, 29 Sep 2021 08:09:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 34F256B008C for ; Wed, 29 Sep 2021 08:09:43 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E385482499A8 for ; Wed, 29 Sep 2021 12:09:42 +0000 (UTC) X-FDA: 78640491804.03.CB9CC1F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 7988C801AB06 for ; Wed, 29 Sep 2021 12:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632917382; 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=m4DcsmdERvwEayP8lS8c/q6o204OALA6BwCBR3wwYSU=; b=QpOMs2mhdYCLKunhDD3lAWfw1FPBCz7lHMBswTWlmS9aQ20dYSCIDBhE+RxacNsxzzTg30 tCdstCbJkPWXlSiiNQKwFgWdMQLjVD5Flcy7hXTVZzTnnxTnIr12lNjhfGRNjJ6ph/Dsi7 kr8wYeuBfjTMaqCZf72DC0IMp9avCss= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-wSwVFqWVO5Or5YLSIz4L4g-1; Wed, 29 Sep 2021 08:09:38 -0400 X-MC-Unique: wSwVFqWVO5Or5YLSIz4L4g-1 Received: by mail-wr1-f72.google.com with SMTP id r15-20020adfce8f000000b0015df1098ccbso531764wrn.4 for ; Wed, 29 Sep 2021 05:09:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=m4DcsmdERvwEayP8lS8c/q6o204OALA6BwCBR3wwYSU=; b=g9wcXhwGGgQmcem4rmFMfxmEkGfY33CGJcljscCpNU8n2Cb8znutPOZDv0enM9bdxO azwUVi2TntljkHZcMaw/Q//xUXCE3l5/sPHNZOTEs1cakY/muZdTYn7ea+eUDFnkGCKb M/9XsPY5NQuck4h2462SDbxVyvsJMsGMh2ZCoZQlNXNtVxZHmQht3GZVJnGu6f8/1pz6 l5kkkEHTXgdM4hCmNyj5zsW4STsed3I2f4BtbwOvjO5jn1ez0qA/VDRSr/EN+2BEMZiq zOnd6r0STGxoRLB6h5q8DnfLoS5SsCXBsxnLMUPPEXGMPAxBIjGb92Gk0WT16Y3O+a27 ghqA== X-Gm-Message-State: AOAM5326+0gskgLWkw+flzTKsd/1Df5nyTSwaI7Rk5k7lwVp6Zie4i1Z wpZFRBAxABQVFMz7Id0vP7CE3dvffGR8F5lUoHkh6p4NZWOSMrszs1d9MSV4pyxluHLsdO4TCon DY8cvHnfr/qk= X-Received: by 2002:a7b:c1d6:: with SMTP id a22mr9983258wmj.146.1632917377447; Wed, 29 Sep 2021 05:09:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEQO6IjIjiX7wFN2+HDTboYoYk/OTp98F2ya3lRO8pW+OuQGAUAEkqR2bTjtD2aDDY3KEI+g== X-Received: by 2002:a7b:c1d6:: with SMTP id a22mr9983226wmj.146.1632917377186; Wed, 29 Sep 2021 05:09:37 -0700 (PDT) Received: from [192.168.3.132] (p4ff23c3b.dip0.t-ipconnect.de. [79.242.60.59]) by smtp.gmail.com with ESMTPSA id u1sm1391208wmc.29.2021.09.29.05.09.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Sep 2021 05:09:36 -0700 (PDT) To: Will Deacon Cc: Chris Goldsworthy , Catalin Marinas , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sudarshan Rajagopalan References: <595d09279824faf1f54961cef52b745609b05d97.1632437225.git.quic_cgoldswo@quicinc.com> <20210929101028.GB21057@willie-the-truck> <13f56b37-afc7-bf6f-d544-8d6433588bf9@redhat.com> <20210929104241.GA21395@willie-the-truck> <20210929110339.GA21510@willie-the-truck> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC] arm64: mm: update max_pfn after memory hotplug Message-ID: <130a50d7-92fd-31fa-261e-f73dadcb4fcf@redhat.com> Date: Wed, 29 Sep 2021 14:09:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210929110339.GA21510@willie-the-truck> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7988C801AB06 X-Stat-Signature: diwn56feu6fw1tf3cf7z6c3gyyuys7jw Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QpOMs2mh; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf06.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1632917382-543967 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: On 29.09.21 13:03, Will Deacon wrote: > On Wed, Sep 29, 2021 at 12:49:58PM +0200, David Hildenbrand wrote: >> On 29.09.21 12:42, Will Deacon wrote: >>> On Wed, Sep 29, 2021 at 12:29:32PM +0200, David Hildenbrand wrote: >>>> On 29.09.21 12:10, Will Deacon wrote: >>>>> On Thu, Sep 23, 2021 at 03:54:48PM -0700, Chris Goldsworthy wrote: >>>>>> From: Sudarshan Rajagopalan >>>>>> >>>>>> After new memory blocks have been hotplugged, max_pfn and max_low_= pfn >>>>>> needs updating to reflect on new PFNs being hot added to system. >>>>>> >>>>>> Signed-off-by: Sudarshan Rajagopalan >>>>>> Signed-off-by: Chris Goldsworthy >>>>>> --- >>>>>> arch/arm64/mm/mmu.c | 5 +++++ >>>>>> 1 file changed, 5 insertions(+) >>>>>> >>>>>> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c >>>>>> index cfd9deb..fd85b51 100644 >>>>>> --- a/arch/arm64/mm/mmu.c >>>>>> +++ b/arch/arm64/mm/mmu.c >>>>>> @@ -1499,6 +1499,11 @@ int arch_add_memory(int nid, u64 start, u64= size, >>>>>> if (ret) >>>>>> __remove_pgd_mapping(swapper_pg_dir, >>>>>> __phys_to_virt(start), size); >>>>>> + else { >>>>>> + max_pfn =3D PFN_UP(start + size); >>>>>> + max_low_pfn =3D max_pfn; >>>>>> + } >>>>> >>>>> We use 'max_pfn' as part of the argument to set_max_mapnr(). Does t= hat need >>>>> updating as well? >>>>> >>>>> Do we have sufficient locking to ensure nobody is looking at max_pf= n or >>>>> max_low_pfn while we update them? >>>> >>>> Only the write side is protected by memory hotplug locking. The read= side is >>>> lockless -- just like all of the other pfn_to_online_page() machiner= y. >>> >>> Hmm. So the readers can see one of the variables updated but the othe= r one >>> stale? >> >> Yes, just like it has been on x86-64 for a long time: >> >> arch/x86/mm/init_64.c:update_end_of_memory_vars() >> >> Not sure if anyone really cares about slightly delayed updates while m= emory >> is getting hotplugged. The users that I am aware of don't care. >=20 > Thanks, I'd missed that x86 also updates max_low_pfn. So at least we're= not > worse off in that respect. >=20 > Looking at set_max_mapnr(), I'm wondering why we need to call that at a= ll > on arm64 as 'max_mapnr' only seems to be used for nommu. I think max_mapnr is only helpful without SPARSE, I can spot the most=20 prominent consumer being simplistic pfn_valid() implementation. MEMORY_HOTPLUG on arm64 implies SPARSE. ... and I recall that FLATMEM is=20 no longer possible on arm64. So most probably the arm64 call of=20 set_max_mapnr() can just be dropped. --=20 Thanks, David / dhildenb