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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7722C3DA6F for ; Fri, 25 Aug 2023 08:38:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 003FA28007F; Fri, 25 Aug 2023 04:38:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF66D8E0011; Fri, 25 Aug 2023 04:38:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE4E728007F; Fri, 25 Aug 2023 04:38:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CF2948E0011 for ; Fri, 25 Aug 2023 04:38:31 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9C641120573 for ; Fri, 25 Aug 2023 08:38:31 +0000 (UTC) X-FDA: 81161975622.06.F94593C Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by imf06.hostedemail.com (Postfix) with ESMTP id 75F0C18001B for ; Fri, 25 Aug 2023 08:38:28 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of liusong@linux.alibaba.com designates 115.124.30.101 as permitted sender) smtp.mailfrom=liusong@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692952709; a=rsa-sha256; cv=none; b=4ddCNIb/EGLz6jlJK2V77AjQWsWLDJTEuqakMw46ma4Z2IQo+6xpJ71w21pKhPsXTFQ2Dp +XIRByJegoZKd1FmS12pkPY+HOLe3LxkC9onQcOBQGPwfRFbiqHHkvSRCN657sjecznbo1 fsaUOqmgRz+veSel8//8mnGNQ8KZcIQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of liusong@linux.alibaba.com designates 115.124.30.101 as permitted sender) smtp.mailfrom=liusong@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692952709; h=from:from:sender: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=+iiRGBVsCY5Ie1pSr76uGg38P2+5pesxT62ti+aOTo4=; b=rFje7a15om/avY73Mjev6e9dHK5N9SJP8KefvMrgi8/DWQazlomEXmUCnoVWkyw/sey9IA QkkH6nu1c05pTm/AGOnUAv1BDg3wsgRQYxOQ2e21XBdBacs5ipShcHGLUr6LfdoTyXhtqv MPOKMuTHgojqDNZoGU89ZzDvD+7BfOQ= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R381e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=liusong@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VqWSqxp_1692952701; Received: from 30.178.80.74(mailfrom:liusong@linux.alibaba.com fp:SMTPD_---0VqWSqxp_1692952701) by smtp.aliyun-inc.com; Fri, 25 Aug 2023 16:38:23 +0800 Message-ID: Date: Fri, 25 Aug 2023 16:38:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] mm/khugepaged: increase transparent_hugepage_recommend_disable parameter to disable active modification of min_free_kbytes To: corbet@lwn.net, akpm@linux-foundation.org, paulmck@kernel.org, rdunlap@infradead.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, rostedt@goodmis.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230817035155.84230-1-liusong@linux.alibaba.com> From: Liu Song In-Reply-To: <20230817035155.84230-1-liusong@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 75F0C18001B X-Stat-Signature: q3rkpoz74fndypidx4whcd749gbuaio8 X-HE-Tag: 1692952708-964527 X-HE-Meta: U2FsdGVkX1825xp/rOa+I4uU8Z4APCOF/vLpQcx5JUiLULIrn2vkjneJfMrMr425uBnW1zeTfejbZDNkm12Bi29iHdZAegg4+XeseusoIJ9L0if6LGimV8CbKyWqDUgFDDKdVP4DvHKUmbSYuN5KkHjufzdWnfNE6OuRJKUI1RQ2y14Fw4b8m7ZzsT2o+JusZVRsMZjegKRvyvcMkw22Bl28xNmDtc59uWL/1nJPLK+rqLtaNy4CrSL83ZS6lBZHH7LE6Tmb9BJaPcrVk40USBKl9eb/TWtOmuLynN6Q46vuZNUW6QA23eNYQXw+ykeVxllMjVcQNvhgtt3CDj0CzDfvs6KfuO0935tAWsG4ekylFvC5Bd1eHGV1d8og1z1mWHjiIp5lBg5OADnklAFEELrobkpqcgRR9aiNgKRaYn+cV3UWMCXQZ4aurOvY7gnXX9ht4KuGUYH+FoCyn0uQA87RitXsuI7lSZb0hmyUf5T41YpYCusCRsgGH7jPCf0ZebfB1e6py0JM/GfdWHcv1w9Rf1hM+w22eqpkZKZd5NvDbkyInQXp2LjjuA/G4tjrRDkFXh8ArzOJs6922Nh/fYlPI8+8NKZu0txhRRHmWSO4/+3tPZTCFQ7gVC0OrkFuuYnYr1Rz+cefMJd+sGWJPpYkeZnXG0Isttcqji0Oso7VDy3/eY+rKT/R7VEphny93sd5meFhRjGR4jA0KHpn/CHG7E1mUBUv7vyOt3Qn6V85w3fgHV3+aAc/WnW6mEnmoSeHr/EugCnC+gqDABkDCQ5TupRfF7w05E5pimS7YC5/66c800qMt8d/MZgQwJMTXhUHU5Xchpv3kYefenMBvAEjrd4AsXEgdoS0REflvNOcSKn+6ognftrFCrVyjhq//Y6B9BEY/Ye/LUvAvQUwJCPgTHCYyFgoIs+HbrTn7SMmHYP25AfHOs+G9+A2aTZxVJjb/MfjWp5NqxIRl1/ 8aJHwKXg m/HV4Okq1pevle9zeR8xIXU13ksFhp3XUnjJ2GNAqjYDFtRhIPp0Kd7MJtjze/w3tT809YZ4fXe9C8wofqArBsBBPnjq74oeHbExPp4eZuyD5q8DHUt9da3mo7hGmMxPwbtEsJ+LuMl7/Wm0iensfFrekWw== 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: Hi Any suggestions for this patch? Indeed, too much memory is being reserved for the 64K PAGESIZE scenario. Looking forward to everyone's suggestions. Thanks 在 2023/8/17 11:51, Liu Song 写道: > In the arm64 environment, when PAGESIZE is 4K, the "pageblock_nr_pages" > value is 512, and the recommended min_free_kbytes in > "set_recommended_min_free_kbytes" usually does not exceed 44MB. > > However, when PAGESIZE is 64K, the "pageblock_nr_pages" value is 8192, > and the recommended min_free_kbytes in "set_recommended_min_free_kbytes" > is 8192 * 2 * (2 + 9) * 64K, which directly increases to 11GB. > > According to this calculation method, due to the modification of min_free_kbytes, > the reserved memory in my 128GB memory environment reaches 10GB, and MemAvailable > is correspondingly reduced by 10GB. > > In the case of PAGESIZE 64K, transparent hugepages are 512MB, and we only > need them to be used on demand. If transparent hugepages cannot be allocated, > falling back to regular 64K pages is completely acceptable. > > Therefore, we added the transparent_hugepage_recommend_disable parameter > to disable active modification of min_free_kbytes, thereby meeting our > requirements for transparent hugepages in the 64K scenario, and it will > not excessively reduce the available memory. > > Signed-off-by: Liu Song > --- > .../admin-guide/kernel-parameters.txt | 5 +++++ > mm/khugepaged.c | 20 ++++++++++++++++++- > 2 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 654d0d921101..612bdf601cce 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -6553,6 +6553,11 @@ > See Documentation/admin-guide/mm/transhuge.rst > for more details. > > + transparent_hugepage_recommend_disable > + [KNL,THP] > + Can be used to disable transparent hugepage to actively modify > + /proc/sys/vm/min_free_kbytes during enablement process. > + > trusted.source= [KEYS] > Format: > This parameter identifies the trust source as a backend > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > index 78fc1a24a1cc..ac40c618f4f6 100644 > --- a/mm/khugepaged.c > +++ b/mm/khugepaged.c > @@ -88,6 +88,9 @@ static unsigned int khugepaged_max_ptes_none __read_mostly; > static unsigned int khugepaged_max_ptes_swap __read_mostly; > static unsigned int khugepaged_max_ptes_shared __read_mostly; > > +/* default enable recommended */ > +static unsigned int transparent_hugepage_recommend __read_mostly = 1; > + > #define MM_SLOTS_HASH_BITS 10 > static DEFINE_READ_MOSTLY_HASHTABLE(mm_slots_hash, MM_SLOTS_HASH_BITS); > > @@ -2561,6 +2564,11 @@ static void set_recommended_min_free_kbytes(void) > goto update_wmarks; > } > > + if (!transparent_hugepage_recommend) { > + pr_info("do not allow to recommend modify min_free_kbytes\n"); > + return; > + } > + > for_each_populated_zone(zone) { > /* > * We don't need to worry about fragmentation of > @@ -2591,7 +2599,10 @@ static void set_recommended_min_free_kbytes(void) > > if (recommended_min > min_free_kbytes) { > if (user_min_free_kbytes >= 0) > - pr_info("raising min_free_kbytes from %d to %lu to help transparent hugepage allocations\n", > + pr_info("raising user specified min_free_kbytes from %d to %lu to help transparent hugepage allocations\n", > + min_free_kbytes, recommended_min); > + else > + pr_info("raising default min_free_kbytes from %d to %lu to help transparent hugepage allocations\n", > min_free_kbytes, recommended_min); > > min_free_kbytes = recommended_min; > @@ -2601,6 +2612,13 @@ static void set_recommended_min_free_kbytes(void) > setup_per_zone_wmarks(); > } > > +static int __init setup_transparent_hugepage_recommend_disable(char *str) > +{ > + transparent_hugepage_recommend = 0; > + return 1; > +} > +__setup("transparent_hugepage_recommend_disable", setup_transparent_hugepage_recommend_disable); > + > int start_stop_khugepaged(void) > { > int err = 0;