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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F277C433EF for ; Wed, 6 Oct 2021 08:17:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 343E061052 for ; Wed, 6 Oct 2021 08:17:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 343E061052 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 8E3A06B006C; Wed, 6 Oct 2021 04:17:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 893E1900002; Wed, 6 Oct 2021 04:17:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 782476B0073; Wed, 6 Oct 2021 04:17:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 69DA96B006C for ; Wed, 6 Oct 2021 04:17:23 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0053839472 for ; Wed, 6 Oct 2021 08:17:22 +0000 (UTC) X-FDA: 78665307966.06.A1BAD65 Received: from mail-ua1-f54.google.com (mail-ua1-f54.google.com [209.85.222.54]) by imf28.hostedemail.com (Postfix) with ESMTP id A78389001358 for ; Wed, 6 Oct 2021 08:17:22 +0000 (UTC) Received: by mail-ua1-f54.google.com with SMTP id y3so1177669uar.5 for ; Wed, 06 Oct 2021 01:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lhXiigKtSAUxKtw77/Z+UYZhqiBVhp3v/PIDZEUz4LE=; b=nTUzCfmkBdWSQtd1FE4SByTmPCL5bsaXqJ+H9LCqmmgbtgrwfnXlcE/hjYU6dgmMk9 BHSg7oxwXa9qWpgJMmMAlBVIbXz4/GIYjQ2qrMFF1m43OICs79r8Mtw3a4UPmVIVpt/I 8Uw3SeWcjmqdxq07P4qtnxsaCYY6lhhFb2VIfkJKIUf4zJVFHjoPbBsQVHqjqJUeU6DI OsZRCqSY/ABsPab/QEb+Gr/JNUGVhCCa91aVr2+QBaLd5LTlm+CJ91hSYrXEMu5tSKaa j4DGSQqN3q0z0z1gQq8n5f1ZJRZHISyCSK2ymPrEojbwYR4v/MVOFEdtKLkB2NasvR0s oMBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lhXiigKtSAUxKtw77/Z+UYZhqiBVhp3v/PIDZEUz4LE=; b=yaK4paLs+i2qZpBBOE0gd3IGy9qmkSyO7NE4HxsP1Q6LkEF9IoHw/GjACaAyOiWlQp gEW9a1Zr25BE/SY97EDHMVeVBOZ899lB/hCR9kwlpXyl4VVBaEwCUF/TJO5XZwo6hINY k/UeZ3gd6RfCIM8WmucZp6SlOTRITn0jXmf8kUImqyE0YL3WIEFwZt+u7IEMkxqWTFwP tWQwN97wAgotRAP2C8z7MhfjstAqFXUfNTQbQaoiO1FwShg/MMimpj8bIrlV4Rkb//X3 M0fjCMs/fcpKxN6xOgLnHGSIObL6nG4nHyPhznF8hKh4yR8aJ3rQs+F3nLskoRd+Z0+o F/xg== X-Gm-Message-State: AOAM532029kRjqWtiadoU4Geec1LsJlt0ukPguWAqbA9EPVDICYyNBgh ZMQ3+nNqwxIseqTyUlz3VviPZZXBq4ojK7TowUg= X-Google-Smtp-Source: ABdhPJxLg8tWkAKRXDxcI63adUXT01siTkRMkz3SwGmrDKy3Io0YT4vrjUijhDroFNZMh7Uv3JjDRhzB/873UEBLnLA= X-Received: by 2002:ab0:22c5:: with SMTP id z5mr1215925uam.67.1633508242021; Wed, 06 Oct 2021 01:17:22 -0700 (PDT) MIME-Version: 1.0 References: <914a0b38-cb44-f4be-43aa-bc42bee1553b@redhat.com> In-Reply-To: <914a0b38-cb44-f4be-43aa-bc42bee1553b@redhat.com> From: Hao Peng Date: Wed, 6 Oct 2021 16:16:51 +0800 Message-ID: Subject: Re: [PATCH] mm/huge_memory: disable thp if thp page size is too large To: David Hildenbrand Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A78389001358 X-Stat-Signature: tqcr3e5ccsxrwg7bxp5yqn5pogxcpxg8 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nTUzCfmk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of flyingpenghao@gmail.com designates 209.85.222.54 as permitted sender) smtp.mailfrom=flyingpenghao@gmail.com X-HE-Tag: 1633508242-518639 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: On Thu, Sep 30, 2021 at 9:19 PM David Hildenbrand wrote: > > On 30.09.21 04:14, Hao Peng wrote: > > From: Peng Hao > > "disable thp if thp page size is too large" you disable thp if there is > not sufficient memory installed in the system (and for that, you use THP > size), something doesn't add up here. > In addition, if THP is enabled, min_free_kbytes will be recalculated. At this time, min_free_kbytes is calculated based on the size of THP. If the size of THP is too l arge, OOM will easily be triggered. > > > > After seting the page size to 64k on ARM64, the supported huge page > > s/seting/setting/ > > Fortunately, most distributions already switched to 4k, because 512MB > THP is pretty much useless, especially on any system that doesn't have > memory in the range of hundreds of megabytes or terrabytes. But the ARM64 Server distribution version I use, such as CentOS for ARM64, has a page size of 16KB or 64KB. Thanks. > > > size is 512M and 1TB. Therefore, if the thp is enabled, the size > > of the thp is 512M. In this case, min_free_kbytes will be too large. > > > > 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. > > > > Signed-off-by: Peng Hao > > --- > > mm/huge_memory.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > 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; > > } > > -- > > 2.27.0 > > > > > -- > Thanks, > > David / dhildenb >