From patchwork Fri Oct 8 01:22:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Peng X-Patchwork-Id: 12543971 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 236E9C433F5 for ; Fri, 8 Oct 2021 01:22:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D22461212 for ; Fri, 8 Oct 2021 01:22:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D22461212 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BC2E66B0071; Thu, 7 Oct 2021 21:22:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B73876B0072; Thu, 7 Oct 2021 21:22:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A87C6900002; Thu, 7 Oct 2021 21:22:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id 9DCAE6B0071 for ; Thu, 7 Oct 2021 21:22:32 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6079D8249980 for ; Fri, 8 Oct 2021 01:22:32 +0000 (UTC) X-FDA: 78671520144.07.BB9D0F6 Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com [209.85.217.45]) by imf25.hostedemail.com (Postfix) with ESMTP id 256BEB0017A2 for ; Fri, 8 Oct 2021 01:22:32 +0000 (UTC) Received: by mail-vs1-f45.google.com with SMTP id f2so8842832vsj.4 for ; Thu, 07 Oct 2021 18:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to:cc; bh=ei10kcGMvMcyDZ3ZmNsU37HKmYhFg9rDN1UeR3hZi3Y=; b=QJNryHgked3U3lS7vrOeYjDn7mugdqYz1ozfYMnrFwMzT4KEASOsbDEsHkFAY5Cu5S LP8oEMsVN2U8HLqmbiA6QM+P0ltu7uyGDH5sg6pWiQbAmVq7IWK818Lt66lgt+aYzAqB 4OchEVsCkSVmq43QefWF3VT3bilNLYjiM/tkgewi4Irj7tc0EJau+iFKjlUqjrCIIhCM tsQM4StzPwNTFjGbTte2rvn12K2onzLLjVSY82Q+pUaPXUrtsCBvzGoW/W2B1z+OzFrr +hiOMHm0Kph4Epu5I6WAgX7bz1sM5KCJPOC+RGtPR0LAbAbhbknAr0bX8n+OEUl7hSro CFRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=ei10kcGMvMcyDZ3ZmNsU37HKmYhFg9rDN1UeR3hZi3Y=; b=C7Fq0phfRFGQTOKfoFUv9hxXB79QJgdsghLfw51yHqKJYBxWVxBqZ5qKZb7Bw7s5nT ObXt1+98d2OAYhOY/PGk2kFIBswBufFGhCzbgbrVGv2ZW5El4ZD3BLTdfXXV7GmRV4kC kJwJTqNS2uHuz2m0lJX//U+ounE2c73J0AnlbB3e4hNrBrA0CUrzJiv1iTe7G7rfAZdJ RIvDLEKnVtIjvH6ExDt2ubqTHR3b4YWIiRsSOw139HZp9egI2hUWHxbUp8q5ZtCih2m7 2TpXIouY/DHUVKkB4LIEklwpuDazunCYMCpO1jx9HW26Bzh5ZhXwcjMtlKKI6eXB8gjj O3zQ== X-Gm-Message-State: AOAM531ba+a8TJs7OPUFY11/K5UUZZSdMG4+iwtBj/ZUSx998CFSdqLh dR2vlDN68Xc9hHJiEu5x0oY2KxopV2bHSAn5iS8= X-Google-Smtp-Source: ABdhPJzJeFEk1VqzAU5lnBpKsZ9oslsukJavpMhDy81w9Mi7oOFozy+K2CMbzTdB1IdHlFCAKoKAU2WO0ItPARskbyg= X-Received: by 2002:a05:6102:b06:: with SMTP id b6mr7981492vst.17.1633656151361; Thu, 07 Oct 2021 18:22:31 -0700 (PDT) MIME-Version: 1.0 From: Hao Peng Date: Fri, 8 Oct 2021 09:22:00 +0800 Message-ID: Subject: [PATCH v2] mm/huge_memory.c: disable THP with large THP size on small present memory To: David Hildenbrand , akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 256BEB0017A2 X-Stat-Signature: webtcxfxoubjhe3siunxrjwapci7i64f Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QJNryHgk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of flyingpenghao@gmail.com designates 209.85.217.45 as permitted sender) smtp.mailfrom=flyingpenghao@gmail.com X-HE-Tag: 1633656152-959798 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: From: Peng Hao After setting the page size to 64k on ARM64, the supported huge page size is 512M and 1TB. Therefore, if the thp is enabled, the size of the thp is 512M. But if THP is enabled, min_free_kbytes will be recalculated. At this time, min_free_kbytes is calculated based on the size of THP. On an arm64 server with 64G memory, the page size is 64k, with thp enabled. cat /proc/sys/vm/min_free_kbytes 3335104 Therefore, when judging whether to enable THP by default, consider the size of thp. V2: title suggested by David Hildenbrand Signed-off-by: Peng Hao --- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.27.0 diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 5e9ef0fc261e..03c7f571b3ae 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -437,7 +437,7 @@ static int __init hugepage_init(void) * where the extra memory used could hurt more than TLB overhead * is likely to save. The admin can still enable it through /sys. */ - if (totalram_pages() < (512 << (20 - PAGE_SHIFT))) { + if (totalram_pages() < (512 << (HPAGE_PMD_SHIFT - PAGE_SHIFT))) { transparent_hugepage_flags = 0; return 0; }