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 4B2A0C433EF for ; Sat, 9 Oct 2021 01:29:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CECE960F9C for ; Sat, 9 Oct 2021 01:29:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CECE960F9C 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 6C5FA6B0071; Fri, 8 Oct 2021 21:29:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 675AA6B0072; Fri, 8 Oct 2021 21:29:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 563FB6B0073; Fri, 8 Oct 2021 21:29:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 473AE6B0071 for ; Fri, 8 Oct 2021 21:29:28 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 02D5339BBC for ; Sat, 9 Oct 2021 01:29:28 +0000 (UTC) X-FDA: 78675166416.03.E508842 Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) by imf12.hostedemail.com (Postfix) with ESMTP id B6D6A100219B for ; Sat, 9 Oct 2021 01:29:27 +0000 (UTC) Received: by mail-vs1-f44.google.com with SMTP id p18so12350495vsu.7 for ; Fri, 08 Oct 2021 18:29:27 -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=zhpGrSlXA1wygmc3CulYlorWz1ODlaz9GQXVN48Dydk=; b=pFaczzzB4KLTBena7k9TQdpEz6xyBWwvM7JVNoKYrSK7KYMSxO1eVpm724lEzjyuSN ioi9CxpoHoJ6VaqAzSiX/G8nySLixq9asvU09Hc5dLEPBoGbb7M8/nbIo5Q4x9Rz8hYW JQacbfEkceUngBU16qyU2i+xdOtautp8B2kNoJhBmnuWgA2zKFHpTHmoLzxKis6ah0Fp 4lOEuGczo2n2g2ypodAb4tsOE9iywhqL7DPtiGbL0MYLg6PjrpGU2/NuQN2sokezS+Og F+qif+E/v9WyTb+W3Ac2rTtaOzP8wrvM/DyR6hbb15KY2+rCLkrZSANi9VYJ+sGxDv/y NWVQ== 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=zhpGrSlXA1wygmc3CulYlorWz1ODlaz9GQXVN48Dydk=; b=6qN2MUo7HufnVfAyUdzONhJklpYnjEKA1lzKZ/m0hGID+b/OLdUcCqT92FKVZwP7VW VFj4M/Iw8tjo8jilOzPt9MbvEm6RVwKg8rQO3pYKadI0IGaMBL9tPMNNhWvUXtWfJkWM Px+u9hJLzFlQEM8hREYwTAt7gDTnjno+z119HpBPSjdn8KNNs/e6gK6SwwKrKZCKw/8S lzrZk8UMJ3cItPa7XZsW6UCwXWx0C4f+4vJCQkMPdAvssnTT95F1ailhiQJZVq5rXUZE /GSl1g3As5ldgdHa57eP4UCrwvgU9EebgBsBqtV7NsLm7xSKWtJlBAwzxSpVR7jvSSRq Gjlw== X-Gm-Message-State: AOAM532pDhUwcqwn5qy55P6qqKVMU8QC++63ZLXFZJcoYBCrJ3P37hV0 V3f/zCBhnfawWcoE/T/I+Zx661Vm5MuAJGDQdBo= X-Google-Smtp-Source: ABdhPJwtt0d3id77E1FYy7Ij0m5SJIklxXhHR6JAMnCXKAuBIizjvfyVelSS8GMzUpq2STHoVXe69oaHlJZ7nPKCq3g= X-Received: by 2002:a05:6102:cd2:: with SMTP id g18mr3932425vst.25.1633742967037; Fri, 08 Oct 2021 18:29:27 -0700 (PDT) MIME-Version: 1.0 References: <20211008095123.73b4bubwrpdj6tuz@box.shutemov.name> In-Reply-To: <20211008095123.73b4bubwrpdj6tuz@box.shutemov.name> From: Hao Peng Date: Sat, 9 Oct 2021 09:28:56 +0800 Message-ID: Subject: Re: [PATCH v2] mm/huge_memory.c: disable THP with large THP size on small present memory To: "Kirill A. Shutemov" Cc: David Hildenbrand , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B6D6A100219B X-Stat-Signature: mnfpdbcn9p5hwogyhud5cppg9qiiwf7d Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=pFaczzzB; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of flyingpenghao@gmail.com designates 209.85.217.44 as permitted sender) smtp.mailfrom=flyingpenghao@gmail.com X-HE-Tag: 1633742967-179692 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 Fri, Oct 8, 2021 at 5:51 PM Kirill A. Shutemov wrote: > > On Fri, Oct 08, 2021 at 09:22:00AM +0800, Hao Peng wrote: > > 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(-) > > > > 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))) { > > On x86-64 HPAGE_PMD_SHIFT is 21, so you double the amount of memory > required to enabled THP by default. It doesn't seem to be the intent of > the patch. > > What about something like > > if (totalram_pages() < 256 * HPAGE_PMD_NR) > > ? > I think that setting the threshold to 512M here is also a rough estimate. If it is 512M of memory and 2M of THP is used, there are only 256 pages in total. This is actually too small. In addition, THP is disabled by default, but you can also enable THP dynamically. Thanks. > > transparent_hugepage_flags = 0; > > return 0; > > } > > -- > > 2.27.0 > > > > -- > Kirill A. Shutemov