Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp321080pxb; Thu, 21 Jan 2021 07:56:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbXH1EX0xF69q8p6+ySItazY2/oWUMg98LwbyuakRUNA7ff2GzvJ35OFVp+u9/cfT7ZJx1 X-Received: by 2002:a50:b223:: with SMTP id o32mr11751683edd.79.1611244587141; Thu, 21 Jan 2021 07:56:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611244587; cv=none; d=google.com; s=arc-20160816; b=WK+OeUO4fzryDSlmFwHQwYGAip+4Q50R21ZIrfhS23xQGsEpRUvZwSXGy5viUYF/ey xcBTUkeRwGQVMXpGkXR9el1cW3yHF49lE7ciLzxQy1mNc5hwqmxpVBPVmn4UEfUUr3a+ RrBq/dEhFC2RxwGKMER3DrCd/8RfsD+jG+CNnbFxJyVQByU6Lq47yiTkGgYODVE9H+r6 L5+3awypPULgcvNYBlI04F5nACaEG7yaL8owOiC3BPYpFq2n4ml+VKPZbsJeQ5E7zqu5 CW5iIsTE+AVNlmD/y04fhnhoj3UrYUduE6YSPUYDlbFVvCw/SHboRnWwFQxCdaG2bFT3 VU8A== 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; bh=5hTwD0A98vYpOLUfmB/PCGnUN4kjyNJl9tyAvmab93E=; b=BVHItgwt/pXmr1pOC+sA1wxAxpPsfAkOjF/R9rQFXPWOJCq9NmKaorMe5RosehvjyX ttHGWSDk53fg0wI5E7UWovN0FhXuAxboeLwKl+UTbDo0X5xCb/c3pT0cm2Zbh+TBx6r1 mb5nGdbVtI1yEVuFahXm6POZrw0e1Ntfvqqs0FAHTw3Pp979yYA7eieJfokjakhXTR6G IzkEMa9chB1+AdA2lHU+aKOrP/to7axlho3SkKeJc8pQhf75QuMRZH0iKw0t6Ccu6q7c SeaBg9vDI0aiHtETJk2zkaVKFqMni8oJKTbpgm7Un9ByhhvtZtjPzZ4iZRyzDdN4z2SA KnfA== 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 r4si2441099edb.431.2021.01.21.07.56.03; Thu, 21 Jan 2021 07:56:27 -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 S1729117AbhAUPya (ORCPT + 99 others); Thu, 21 Jan 2021 10:54:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:52040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbhAUPwm (ORCPT ); Thu, 21 Jan 2021 10:52:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A3B822DFA; Thu, 21 Jan 2021 15:51:42 +0000 (UTC) Date: Thu, 21 Jan 2021 15:51:39 +0000 From: Catalin Marinas To: Sudarshan Rajagopalan Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Will Deacon , Anshuman Khandual , David Hildenbrand , Mike Rapoport , Mark Rutland , Logan Gunthorpe , Andrew Morton , Steven Price , Suren Baghdasaryan Subject: Re: [PATCH 1/1] arm64/sparsemem: reduce SECTION_SIZE_BITS Message-ID: <20210121155139.GG21811@gaia> References: <43843c5e092bfe3ec4c41e3c8c78a7ee35b69bb0.1611206601.git.sudaraja@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43843c5e092bfe3ec4c41e3c8c78a7ee35b69bb0.1611206601.git.sudaraja@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Catalin Marinas