Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp518652pxb; Wed, 29 Sep 2021 04:22:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSIK+qkklemMGMb8OJeN0Ripo7egFzJk3KAwNl7wJZ0GnAqPvQC3VCDvbQkJ4Z34+6WAJ+ X-Received: by 2002:a17:902:d345:b0:13e:27a5:58b5 with SMTP id l5-20020a170902d34500b0013e27a558b5mr9664745plk.79.1632914548974; Wed, 29 Sep 2021 04:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632914548; cv=none; d=google.com; s=arc-20160816; b=cC6LG5Mgi7gRLdJrOF5vbixQEtfRgWATXGW0JBWZF6imHr10yo36HJwXhxKaMQIxiF M0ScHfwZOCajqNC8UsOhD/oub8tCUc+PKQZFtzuIhIqPOWW2U64jL+7RBRI4xUNirSUM cL6/2mcChbJVPXR9nhml1BJe8HhS7TV8cKjKPp3fszRAJb8eHg/zf2F/0t9K6OEsiyNu kGgyrO6ECiz8353CG7jGxq/mkpcODExPSIAOw+OonB8wKQv7OssbDdZgf1UZb7S063d+ 91QxGQnJ8lGzd0NQsMEbAxFWY45mJ/Lc/X2WBhhcvLpNBbVGyZmCnz2in90blzpEd7vL 6J/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=lsH98wDMRbxWdVAgxSL3AZLCKIg/R8OFyaVgMxMrDhM=; b=fMMSU1FjQ+TatfjrP+pTKnxLxbA+JnMEIgs8Jniy+NMnT2WVwGR9mCQpWIh8GaFffe 73ETebhzsNh/EUr4jSWp216fg70NZIKuIIe7Vu7obx8rIRkvUhT/x3mPGNdC8VtWumQ8 ZXBE07BiioDr7zMFI9X2N5Yxk4oxfqV8U5QbM+IqbRVIIVFEYsjkU52dMC/Oh5jc6jAQ vXdvMiIIJxndjd9OWdqXGySd2jHDKOX6inqcK0pMl5JPYUNPhFzkbHVg4+QUpi1jYgz8 +QkCI2gZqoxdTPXvnrL2yxzctry0I7ySp35uU7I801f5CXBRODx+kuHXrgiJdk5POLrw xylg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BGcadR35; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si2261822pls.254.2021.09.29.04.22.16; Wed, 29 Sep 2021 04:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BGcadR35; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244678AbhI2LFZ (ORCPT + 99 others); Wed, 29 Sep 2021 07:05:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:35408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244363AbhI2LFZ (ORCPT ); Wed, 29 Sep 2021 07:05:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E3BF0613CE; Wed, 29 Sep 2021 11:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632913424; bh=XKEIYo+ZewR2Nn7R/NL3hozd8BvZN53o0z9on1e1NrM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BGcadR35ExfRhxZWQxX6/CNzbtNrPLnhvwUUpQJutBpAINi3cOtBW6U5I+zVPPD28 MK8n/paiq4Mk16D1zosa/JzieW4SXYixQtnTBqUTAANPhBOeOTLalLmqLoJslA1sP3 fsSZK+uuS8ZtpwUIcI6sHc/OiPeEqUbZvsNJ7rLHFhTBvLOYQ+XjOB9SSLYD8+kXZo nm5h6W1M2jHgFzVlMKVk+a5awfZZXEtD7C4XPRGy182X5kH+nRkrXhC5JL8a9wqYTz KY62+v0xingEOuZwgLze72IZynhJ4oj51P16OWVnPF8rZAIsH99oN3x93iBS9o0uBx U05dgfN+FdQ2w== Date: Wed, 29 Sep 2021 12:03:39 +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: <20210929110339.GA21510@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Will