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 15019C433EF for ; Wed, 29 Sep 2021 12:51:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B95E161440 for ; Wed, 29 Sep 2021 12:51:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B95E161440 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3731C940027; Wed, 29 Sep 2021 08:51:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 32318940020; Wed, 29 Sep 2021 08:51:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21124940027; Wed, 29 Sep 2021 08:51:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id 12E00940020 for ; Wed, 29 Sep 2021 08:51:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B8E5330C92 for ; Wed, 29 Sep 2021 12:51:10 +0000 (UTC) X-FDA: 78640596300.18.3AFA746 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf21.hostedemail.com (Postfix) with ESMTP id 61608D02FF34 for ; Wed, 29 Sep 2021 12:51:10 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 245C861390; Wed, 29 Sep 2021 12:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632919866; bh=A6xpSVQ3SjT9BXr/QonzyAOgdAvBS4ykRD6s3eWNyyQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MoezbwGRQfn9hXWtFc3sAoxTK+ANl5fHvRV2CGsEy2xq9pbd52cOJq0PNnTvkDzEl UyqXuOQGM+Pj1J2t1//T+dYG7kkpzLpv1Zv5iKwHvnQryxFBq3Jw9eDrXZvrRjsVOT MFndZYMUdT9It+peccvN8JDgZKKVRDkz4Fi//HI/i0GPRt6lhYhV7Hqs5+3vsR6m5G lH8ZIhKDwds+gED3KUplFOXCg2XouRda9HUAGm6CZn3CLTvUULfs0C2iOdZXsGRN6u 5mbVEcBq4y51wx+DlJwq4opYwIT2ZI9wovap3oGne1epUw+IDnq6tyj/9jMC70UDKA e+rcV8FN8orCw== Date: Wed, 29 Sep 2021 13:51:02 +0100 From: Will Deacon To: David Hildenbrand Cc: Chris Goldsworthy , Catalin Marinas , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sudarshan Rajagopalan Subject: Re: [RFC] arm64: mm: update max_pfn after memory hotplug Message-ID: <20210929125101.GF21631@willie-the-truck> 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> <130a50d7-92fd-31fa-261e-f73dadcb4fcf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <130a50d7-92fd-31fa-261e-f73dadcb4fcf@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MoezbwGR; spf=pass (imf21.hostedemail.com: domain of will@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 61608D02FF34 X-Stat-Signature: emiypfx76jwhso7yah58bbwuytiwuoj5 X-HE-Tag: 1632919870-680160 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 Wed, Sep 29, 2021 at 02:09:35PM +0200, David Hildenbrand wrote: > 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 = PFN_UP(start + size); > > > > > > > + max_low_pfn = max_pfn; > > > > > > > + } > > > > > > > > > > > > We use 'max_pfn' as part of the argument to set_max_mapnr(). Does that need > > > > > > updating as well? > > > > > > > > > > > > Do we have sufficient locking to ensure nobody is looking at max_pfn 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() machinery. > > > > > > > > Hmm. So the readers can see one of the variables updated but the other 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 memory > > > is getting hotplugged. The users that I am aware of don't care. > > > > Thanks, I'd missed that x86 also updates max_low_pfn. So at least we're not > > worse off in that respect. > > > > Looking at set_max_mapnr(), I'm wondering why we need to call that at all > > 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 > prominent consumer being simplistic pfn_valid() implementation. Yeah, and that's only used #ifndef CONFIG_MMU (there's a #error otherwise at the top of the file). > MEMORY_HOTPLUG on arm64 implies SPARSE. ... and I recall that FLATMEM is no > longer possible on arm64. So most probably the arm64 call of set_max_mapnr() > can just be dropped. I'll do that and see if anything catches fire. Will