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 79821C433EF for ; Fri, 8 Oct 2021 09:51:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 22EC961037 for ; Fri, 8 Oct 2021 09:51:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 22EC961037 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A9E386B0071; Fri, 8 Oct 2021 05:51:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4E27900002; Fri, 8 Oct 2021 05:51:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 915EC6B0073; Fri, 8 Oct 2021 05:51:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 7E5AD6B0071 for ; Fri, 8 Oct 2021 05:51:26 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2A06A2FD96 for ; Fri, 8 Oct 2021 09:51:26 +0000 (UTC) X-FDA: 78672802572.35.4A0D6A0 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by imf25.hostedemail.com (Postfix) with ESMTP id E4B2FB0017BD for ; Fri, 8 Oct 2021 09:51:25 +0000 (UTC) Received: by mail-lf1-f52.google.com with SMTP id t9so35909294lfd.1 for ; Fri, 08 Oct 2021 02:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=We0TlgUShJQM6EjIHFWMHy/wENnjZ0TPxRk0At+mWjg=; b=s6ZV9WAhjM639Ryc3nDZkNN5ECnbRF6Z6+x/1eIos4fbPJRyA7Nq57+D0OWssmAlTw +lnhayBzlRQs5+om/hU3GanBO2ZxTMrDQdkUDY4E5BSRZsT2isQXTt3oK2SknBOtfjR6 oW77wZmkPD0zzw9IVMKGF8no3GyLYkmbAkgnKdCh6QSoafnY1Ep7ht0zzZJClmk421L7 KBOIhOLvniAohvsJXx8PGiSxIN3ygjfeVT/QXalOypwrMH3kTYj1mp7nE+o+p9wA82ZC jO0x25dJi01DF0KEb4ERNwiUVKQ+VY+YH0XSe52o5ShTAJOkNWCRzlBCBoUyiPf0ZT51 GFww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=We0TlgUShJQM6EjIHFWMHy/wENnjZ0TPxRk0At+mWjg=; b=1VnQU7Mb28LYfgT0FhnMIWmy61e4r/tbhhESgvTPpJ6VBA413wg0z4TnpvvFN094Uw N4bUTauGKCNQ0MwvZCfdnVZUeL6czJcigH274lfdD+uGiNYJzJJBAdcZQ/e9BWrrQrbY rZHfjukFmCqThHiNqeU7RL4SXhW7kOa4hth21zWpJrmJPXxIa7HW4nMztsrYztMhqbBD VgwQDrQnIXTMZJwVDrE0RX6zPTPup5xecTU9NJJ4dpgs8aOQwEUwFPDRaEPoDNhOsfEY TXBTJ1UjrQyYp9yCyCvclrVf3n7af4sU0yAqlJ2cPe6onrlctu1pqPsBqnw5ZGDUlqVt SOoQ== X-Gm-Message-State: AOAM532EdLxBNkKrVkMLwa3cASKzw/RZWIyvTpg6bbUxJngXGvTPcdG4 XLtnJSEOdjSP3e2J+wCysAEtKw== X-Google-Smtp-Source: ABdhPJwHd1mtH8H/TmsRUQMg7Qp41jHspbh9+6ZioBBxaKUYR6g6L1g1+8V72I+Q7k0I34P0OSetdA== X-Received: by 2002:a2e:2e07:: with SMTP id u7mr2386984lju.418.1633686684423; Fri, 08 Oct 2021 02:51:24 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id u3sm199461lfi.265.2021.10.08.02.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 02:51:23 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 487491030F5; Fri, 8 Oct 2021 12:51:23 +0300 (+03) Date: Fri, 8 Oct 2021 12:51:23 +0300 From: "Kirill A. Shutemov" To: Hao Peng Cc: David Hildenbrand , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm/huge_memory.c: disable THP with large THP size on small present memory Message-ID: <20211008095123.73b4bubwrpdj6tuz@box.shutemov.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E4B2FB0017BD X-Stat-Signature: xhnzzseae79febqdcj618u6xogtonpwf Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=s6ZV9WAh; spf=none (imf25.hostedemail.com: domain of kirill@shutemov.name has no SPF policy when checking 209.85.167.52) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-HE-Tag: 1633686685-438818 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 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) ? > transparent_hugepage_flags = 0; > return 0; > } > -- > 2.27.0 > -- Kirill A. Shutemov