Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp712583pxb; Thu, 21 Jan 2021 19:02:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKlp2VetCUR/eOaZeqFLUosDY78TJguhOlN/VPorUEnp2JTZvVbsYhefPUaSRDm5pOVf5M X-Received: by 2002:a17:906:7215:: with SMTP id m21mr1577285ejk.248.1611284568604; Thu, 21 Jan 2021 19:02:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611284568; cv=none; d=google.com; s=arc-20160816; b=QSuvA24ajdYMmQ4NPlRlzbBNtmKmw01X/SY0BNCkfd9Z8yNFV3QjfpED+EVf5RfHBL n6YD06YQYIv35Q06/YEnQFSVuwdYZznPr38XxsfiL1HNzYeH75dV3MwkMhCIanhhVpdh IGLJ82MyVj21zXYsogTd7Se46yFNELQyTBhlsXNwn5DdRrZzlKXG4FCQgAhbwnXRpd9z 5Pl9hbJMmKmTRnjCveAaX1HgFOS3zkkX8wVNu9fcHj0YQxO58gEIu7NQ9BYF1U/9P2FS LPoNcBB+MiFjrNz1MYuFVktJNshpy+OZYxt3zBocFSuSJ3OsC2QIkYR+67acwbrXya4H dB5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=SQK0uzpr43GlNhkt5h8kQLdG0YG0FrudwsvRAw5lKYI=; b=BLQx8m49HJo01z6GZYIjMRZ74K7aG44NOhKq2xXCyJbAqmJxEXMaRyferx/CX+HIXP Z96RF3vt8bmHjdB2mfPJyyyPbqfgOJB/P4VMpLB8bd5BHAzFo1VzpWxZt7JPuETNPKqX w1D/VJysDt8ilQd9UMQ1gdTskfuqEOX0GryP+/2/Dmt211nLzkaMzSkdW3L98INV/Ydo kdCpRItCU8+xA0aZBmSEnKRfoECM0lBvrLYWm0pOBfgxB9oKixKBnVHn+nEeIlHmK0iW Dj9mEzEqvJFNB6+YDn/ENWwZhK3eIGUq5gbVHOLap7XWiKgFkQK4zHDEqHhutiLScW8C v9Kw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si2893187edr.176.2021.01.21.19.02.23; Thu, 21 Jan 2021 19:02:48 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbhAVC7U (ORCPT + 99 others); Thu, 21 Jan 2021 21:59:20 -0500 Received: from foss.arm.com ([217.140.110.172]:54052 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbhAVC7T (ORCPT ); Thu, 21 Jan 2021 21:59:19 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4E0A111D4; Thu, 21 Jan 2021 18:58:32 -0800 (PST) Received: from [192.168.0.130] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 008253F68F; Thu, 21 Jan 2021 18:58:27 -0800 (PST) Subject: Re: [PATCH 1/1] arm64/sparsemem: reduce SECTION_SIZE_BITS To: Will Deacon , Sudarshan Rajagopalan Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Catalin Marinas , David Hildenbrand , Mike Rapoport , Mark Rutland , Logan Gunthorpe , Andrew Morton , Steven Price , Suren Baghdasaryan References: <43843c5e092bfe3ec4c41e3c8c78a7ee35b69bb0.1611206601.git.sudaraja@codeaurora.org> <20210121133652.GA22341@willie-the-truck> From: Anshuman Khandual Message-ID: <38f15b8e-6cb8-e28b-fb32-15a5312aa8e3@arm.com> Date: Fri, 22 Jan 2021 08:28:03 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210121133652.GA22341@willie-the-truck> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/21/21 7:06 PM, Will Deacon wrote: > On Wed, Jan 20, 2021 at 09:29:13PM -0800, Sudarshan Rajagopalan wrote: >> memory_block_size_bytes() determines the memory hotplug granularity i.e the >> amount of memory which can be hot added or hot removed from the kernel. The >> generic value here being MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS) >> for memory_block_size_bytes() on platforms like arm64 that does not override. >> >> Current SECTION_SIZE_BITS is 30 i.e 1GB which is large and a reduction here >> increases memory hotplug granularity, thus improving its agility. A reduced >> section size also reduces memory wastage in vmemmmap mapping for sections >> with large memory holes. So we try to set the least section size as possible. >> >> A section size bits selection must follow: >> (MAX_ORDER - 1 + PAGE_SHIFT) <= SECTION_SIZE_BITS >> >> CONFIG_FORCE_MAX_ZONEORDER is always defined on arm64 and so just following it >> would help achieve the smallest section size. >> >> SECTION_SIZE_BITS = (CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT) >> >> SECTION_SIZE_BITS = 22 (11 - 1 + 12) i.e 4MB for 4K pages >> SECTION_SIZE_BITS = 24 (11 - 1 + 14) i.e 16MB for 16K pages without THP >> SECTION_SIZE_BITS = 25 (12 - 1 + 14) i.e 32MB for 16K pages with THP >> SECTION_SIZE_BITS = 26 (11 - 1 + 16) i.e 64MB for 64K pages without THP >> SECTION_SIZE_BITS = 29 (14 - 1 + 16) i.e 512MB for 64K pages with THP >> >> But there are other problems in reducing SECTION_SIZE_BIT. Reducing it by too >> much would over populate /sys/devices/system/memory/ and also consume too many >> page->flags bits in the !vmemmap case. Also section size needs to be multiple >> of 128MB to have PMD based vmemmap mapping with CONFIG_ARM64_4K_PAGES. >> >> Given these constraints, lets just reduce the section size to 128MB for 4K >> and 16K base page size configs, and to 512MB for 64K base page size config. >> >> Signed-off-by: Sudarshan Rajagopalan >> Suggested-by: Anshuman Khandual >> Suggested-by: David Hildenbrand >> Cc: Catalin Marinas >> Cc: Will Deacon >> Cc: Anshuman Khandual >> Cc: David Hildenbrand >> Cc: Mike Rapoport >> Cc: Mark Rutland >> Cc: Logan Gunthorpe >> Cc: Andrew Morton >> Cc: Steven Price >> Cc: Suren Baghdasaryan >> --- >> arch/arm64/include/asm/sparsemem.h | 23 +++++++++++++++++++++-- >> 1 file changed, 21 insertions(+), 2 deletions(-) > > Anshuman -- are you happy with this now? Yes. A small nit. There are couple of extra lines in the patch which can be dropped, probably while merging. Reviewed-by: Anshuman Khandual