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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 24ADDC433ED for ; Wed, 14 Apr 2021 15:12:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BF1B7613B3 for ; Wed, 14 Apr 2021 15:12:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF1B7613B3 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 466EC6B0070; Wed, 14 Apr 2021 11:12:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 416A76B0071; Wed, 14 Apr 2021 11:12:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2698F6B0072; Wed, 14 Apr 2021 11:12:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 0BD056B0070 for ; Wed, 14 Apr 2021 11:12:17 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B64A4181DA094 for ; Wed, 14 Apr 2021 15:12:16 +0000 (UTC) X-FDA: 78031313472.32.7876E5E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf27.hostedemail.com (Postfix) with ESMTP id D2C8180192DA for ; Wed, 14 Apr 2021 15:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618413135; 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=OvGZLtj/JZR18KhKppCpw2o1u6Vet6Jv6a+C3P66ArY=; b=El444DlzJ2wF5qGmEGgDoC9Lmsgumi5oC76vvmLt+Z1oIwgHL1H/6KXa7k3ygChh634d6v jDCCJiUjNu7PCzHwNK7R+fTtWvrHi282md0uAVrap1JZ0nRSyhxdvQ0zp4Xt+GA7YLFEP3 7lPMGL0f5FqHhUKID361FdNF3Byg6XI= 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-187-PmfW8Y7aPrGouZ7XJ8m6yw-1; Wed, 14 Apr 2021 11:12:14 -0400 X-MC-Unique: PmfW8Y7aPrGouZ7XJ8m6yw-1 Received: by mail-wr1-f72.google.com with SMTP id s9-20020a5d51090000b02901028ea30da6so1206978wrt.7 for ; Wed, 14 Apr 2021 08:12:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=OvGZLtj/JZR18KhKppCpw2o1u6Vet6Jv6a+C3P66ArY=; b=uNFwa0ltrWubo1gvTunLa5zyqh9iZjf3caBi9N+lTvol8PC6Wf0vIldegu9+eJjxpo JB5FBQPOCBYEWUKqdvwfNsJZLXNjPV6PxSAALPF1RFBTitUhUJbf5tsaK2JbOUYUsueo XtRcef5eYacPvks0UfN548jsUYKV8nDXLIaIAOyfyUWlI8qkgm4lHRnefXk7wq7Z8Qw/ rMB7Z4Rg9a5nY3LoBgSZHNGHeh2nHhZwK2ePuF8ewDkOpA3kvLgRovJ/hjn4ssOp6Kf7 /FCDoJWxawxvZQcJjWpHdXfh1maw/KmnV0+3wvppX+cJol1GHkTlMazWV9VWI454khKW LDYA== X-Gm-Message-State: AOAM530ghgNySVY9Zm1w2o3+RhOqIsntTfplFX3/hnNm98FdBz29ApMS n1bo8Vd+y61NbR/i+URHsPn8UacFY4l1tHrLXdvn8SkySDhH8YcBuIR3+yiNmQuGVj6IqkdJleK AohvcqbFEQVyGA2nxzMIxF99UHXtHXS+FYcDv+aaMAYcnKCBO4Sf/dwet4Wc= X-Received: by 2002:a1c:f614:: with SMTP id w20mr3490024wmc.70.1618413133069; Wed, 14 Apr 2021 08:12:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwpIn8nv9v5Y/Dtcv6mOc3r8te/FMqBM0g0pALidkDsp7h2aVJV3ZZM5WuTLB2ksnnlanbKw== X-Received: by 2002:a1c:f614:: with SMTP id w20mr3489987wmc.70.1618413132740; Wed, 14 Apr 2021 08:12:12 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6470.dip0.t-ipconnect.de. [91.12.100.112]) by smtp.gmail.com with ESMTPSA id z14sm334347wrt.54.2021.04.14.08.12.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Apr 2021 08:12:12 -0700 (PDT) To: Mike Rapoport , linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , Marc Zyngier , Mark Rutland , Mike Rapoport , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20210407172607.8812-1-rppt@kernel.org> <20210407172607.8812-2-rppt@kernel.org> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC/RFT PATCH 1/3] memblock: update initialization of reserved pages Message-ID: <0c48f98c-7454-1458-15a5-cc5a7e1fb7cd@redhat.com> Date: Wed, 14 Apr 2021 17:12:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210407172607.8812-2-rppt@kernel.org> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com 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: rspam05 X-Rspamd-Queue-Id: D2C8180192DA X-Stat-Signature: ifo74h4u3nqukkcysrji1n59kw5wcw76 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf27; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618413124-976817 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 07.04.21 19:26, Mike Rapoport wrote: > From: Mike Rapoport >=20 > The struct pages representing a reserved memory region are initialized > using reserve_bootmem_range() function. This function is called for eac= h > reserved region just before the memory is freed from memblock to the bu= ddy > page allocator. >=20 > The struct pages for MEMBLOCK_NOMAP regions are kept with the default > values set by the memory map initialization which makes it necessary to > have a special treatment for such pages in pfn_valid() and > pfn_valid_within(). I assume these pages are never given to the buddy, because we don't have=20 a direct mapping. So to the kernel, it's essentially just like a memory=20 hole with benefits. I can spot that we want to export such memory like any special memory=20 thingy/hole in /proc/iomem -- "reserved", which makes sense. I would assume that MEMBLOCK_NOMAP is a special type of *reserved*=20 memory. IOW, that for_each_reserved_mem_range() should already succeed=20 on these as well -- we should mark anything that is MEMBLOCK_NOMAP=20 implicitly as reserved. Or are there valid reasons not to do so? What=20 can anyone do with that memory? I assume they are pretty much useless for the kernel, right? Like other=20 reserved memory ranges. >=20 > Split out initialization of the reserved pages to a function with a > meaningful name and treat the MEMBLOCK_NOMAP regions the same way as th= e > reserved regions and mark struct pages for the NOMAP regions as > PageReserved. >=20 > Signed-off-by: Mike Rapoport > --- > mm/memblock.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) >=20 > diff --git a/mm/memblock.c b/mm/memblock.c > index afaefa8fc6ab..6b7ea9d86310 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2002,6 +2002,26 @@ static unsigned long __init __free_memory_core(p= hys_addr_t start, > return end_pfn - start_pfn; > } > =20 > +static void __init memmap_init_reserved_pages(void) > +{ > + struct memblock_region *region; > + phys_addr_t start, end; > + u64 i; > + > + /* initialize struct pages for the reserved regions */ > + for_each_reserved_mem_range(i, &start, &end) > + reserve_bootmem_region(start, end); > + > + /* and also treat struct pages for the NOMAP regions as PageReserved = */ > + for_each_mem_region(region) { > + if (memblock_is_nomap(region)) { > + start =3D region->base; > + end =3D start + region->size; > + reserve_bootmem_region(start, end); > + } > + } > +} > + > static unsigned long __init free_low_memory_core_early(void) > { > unsigned long count =3D 0; > @@ -2010,8 +2030,7 @@ static unsigned long __init free_low_memory_core_= early(void) > =20 > memblock_clear_hotplug(0, -1); > =20 > - for_each_reserved_mem_range(i, &start, &end) > - reserve_bootmem_region(start, end); > + memmap_init_reserved_pages(); > =20 > /* > * We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id >=20 --=20 Thanks, David / dhildenb