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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 83B75C433DB for ; Thu, 21 Jan 2021 13:43:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 295DD23444 for ; Thu, 21 Jan 2021 13:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbhAUNmW (ORCPT ); Thu, 21 Jan 2021 08:42:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:42846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727031AbhAUNh5 (ORCPT ); Thu, 21 Jan 2021 08:37:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 45A0023877; Thu, 21 Jan 2021 13:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611236218; bh=2s+lWo7KDrJYr75WaZovApC/psdJ+hHVFHC0BqGesDQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YCbc/X5axhrDjjnt7f7J2xL/lmC2QSuqSPKWdv8BS9xiKmGccNikKBxjewEqdcdDR Gxaww/ztz6vqEBALb00zrL0v/4Illfj868zga21Y6XltJuGm84IuvgXiPShuBzT/2w v0IadtCgzIm6IsYnRBBLhYBJ1qXVu3DxEH58/RqqhK5iRc/JUnm14Kq0S3tS5YlwSv qWS7X0pKkMgyyLl8fOCrnu/dKRO5Z7TfhQEvsbiFfqG7TuhnwR8xZlgAdgFotvtuRv coKwcVbHv09axDK2ZTfQLLh8F4pw+lWrJCnALJXbl8Bp1qxi817EMAUM2w+KyH+xDS YiqE37tGEJXYQ== Date: Thu, 21 Jan 2021 13:36:52 +0000 From: Will Deacon To: Sudarshan Rajagopalan Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Catalin Marinas , 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: <20210121133652.GA22341@willie-the-truck> 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 > --- > arch/arm64/include/asm/sparsemem.h | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) Anshuman -- are you happy with this now? Will 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.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 B4C6FC433E0 for ; Thu, 21 Jan 2021 13:38:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DE1923877 for ; Thu, 21 Jan 2021 13:38:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DE1923877 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZWL8cyLPLyP7F+YEWP0pLh3WcCPkjeOTG/ZP33O4iu8=; b=m1SvOJTclHu0/uAoeCBpLLjQz xaUCflQyV+og9YA5YBJ0JFaRS0UKVbQs81UIavuZ9DJp6Bzd/S4RKErVi86yFAYAYyjhAvwK9UNFq tREO8z8F6XArNWOOE+B+Pt7EnnCqyu7trsMn8PrRLtxjMs0whtxSJ/xvLnhTLKhN21rNsrg47dxod rPOzsUuq8Rmb234denxsp/3FGc1XAP1GOQbpMDdK1iQmsRKSK5AE97yLvnj990wk/CzCNwCwv7K/8 Kpx+do/CcVguI/WGNK0lZX8GzQ38ol21PdK+CS25bOYwkANzF/a6EqjfXJcLXDb/dz6kEPMnN9GJ4 JePRdXImg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2a90-0008QD-5z; Thu, 21 Jan 2021 13:37:02 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2a8x-0008Ph-GS for linux-arm-kernel@lists.infradead.org; Thu, 21 Jan 2021 13:37:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 45A0023877; Thu, 21 Jan 2021 13:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611236218; bh=2s+lWo7KDrJYr75WaZovApC/psdJ+hHVFHC0BqGesDQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YCbc/X5axhrDjjnt7f7J2xL/lmC2QSuqSPKWdv8BS9xiKmGccNikKBxjewEqdcdDR Gxaww/ztz6vqEBALb00zrL0v/4Illfj868zga21Y6XltJuGm84IuvgXiPShuBzT/2w v0IadtCgzIm6IsYnRBBLhYBJ1qXVu3DxEH58/RqqhK5iRc/JUnm14Kq0S3tS5YlwSv qWS7X0pKkMgyyLl8fOCrnu/dKRO5Z7TfhQEvsbiFfqG7TuhnwR8xZlgAdgFotvtuRv coKwcVbHv09axDK2ZTfQLLh8F4pw+lWrJCnALJXbl8Bp1qxi817EMAUM2w+KyH+xDS YiqE37tGEJXYQ== Date: Thu, 21 Jan 2021 13:36:52 +0000 From: Will Deacon To: Sudarshan Rajagopalan Subject: Re: [PATCH 1/1] arm64/sparsemem: reduce SECTION_SIZE_BITS Message-ID: <20210121133652.GA22341@willie-the-truck> References: <43843c5e092bfe3ec4c41e3c8c78a7ee35b69bb0.1611206601.git.sudaraja@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <43843c5e092bfe3ec4c41e3c8c78a7ee35b69bb0.1611206601.git.sudaraja@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210121_083659_710882_3FB61283 X-CRM114-Status: GOOD ( 19.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Anshuman Khandual , Catalin Marinas , David Hildenbrand , linux-kernel@vger.kernel.org, Mike Rapoport , Suren Baghdasaryan , linux-mm@kvack.org, Andrew Morton , Steven Price , Logan Gunthorpe , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > --- > arch/arm64/include/asm/sparsemem.h | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) Anshuman -- are you happy with this now? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel