Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp133678pxb; Wed, 6 Oct 2021 01:18:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrruTnI9UN9pL8O+o84ZxG5+1v21wNtVHrglbRuuT6btTvqHDcNsMfTBEFPpR5kq78yhNo X-Received: by 2002:a17:90a:5108:: with SMTP id t8mr9478203pjh.201.1633508335915; Wed, 06 Oct 2021 01:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633508335; cv=none; d=google.com; s=arc-20160816; b=ipba9zP+2YYWwi6XF+77tX3+ihv5o/xEzkxoIOdKxeTcZB2wB12+6KKtwPum+RFcWQ UD9nsaO6trf0e2OJR6tMroWVoTbl3QNDMVK8S7md+Nhl30mQPQuWLywpP6IB+66/Krqy ddRnui0ksHtIokFy2AstT77rXVBGHXjjEwDJDUQbDKXY4aZJhxjGE+rMWWMbF3gj/xVX 5LxKh3Rsy+zWEnXO6/jGOhXQW8GXV/dpj+G8Kjcq8gBQTF89cTbneJh/5gAAnjiloJOb KelYMEcRrG8wC3EaBv54Bu8A8eK4wl0DGcKjThsQAhx9do/zxQw+ZKqwaC98bRrc3SpR u4Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=lhXiigKtSAUxKtw77/Z+UYZhqiBVhp3v/PIDZEUz4LE=; b=AU1Jkfc9PsjIuhUZXM1HDgWNXoCLx+1ycA2ncLUE3Oe0WBPeZt/LT0kZyuVRF0K4bN AaMC0zIlSGWWhOY41DFazx7XZWPs7n/kyEloSZ2m4jxYq+ML0afBPTtCZ9lcK6Nw8QdJ FXn7ecaTpAfyapFg07qEJ40iD5njMfp4W2LgbVXIbXIsfpjdUlrdtFj+2HNUr1Ah4yi3 Mii4kl6ZTCmoJvell/X9WpUIyOoYk0na1bS0vb8NPakrs7UASYbKbKLyg8z3Dh1s4s0P MfACuZabkBD9asPcSD3/TAOYUz7Zs9mirvl2O1NPRkO3WfmI6GKSGp5Cvrr0fKukSrEi qKfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nTUzCfmk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si23310240pls.182.2021.10.06.01.18.38; Wed, 06 Oct 2021 01:18:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nTUzCfmk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237647AbhJFITP (ORCPT + 99 others); Wed, 6 Oct 2021 04:19:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237721AbhJFITO (ORCPT ); Wed, 6 Oct 2021 04:19:14 -0400 Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6B58C061749 for ; Wed, 6 Oct 2021 01:17:22 -0700 (PDT) Received: by mail-ua1-x933.google.com with SMTP id h4so1192676uaw.1 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=aptSf4xHQgKvT+5aJSa6OK8Iv+lrFzzRH4xX0A1AmtQyM/dY2HqXemXr13x3qEMdnF 1haieCxf03VHiZQ6WJxgRUlGEzzHIde2feXLNxiEiOrwdf+3wtURUFrJE6lEPbRLf4S+ j7AZacOMOuCe8+QU0qHqx52DL2YpHjtCOl8cahxpr0IzneGVaavICJSabTzZZFSEif9Z zYODFwmfvAUXUVM2xTbade90+1KQ9qF6VaHYHYmVIrMikN06RYvxzjTxq2itoCxk0WMI B+TkW9P8zCgkxY8wH3WHEDHDZUl6OgxJ98331DCbQfOfDxcAfpFhniMeIf1zmxDPt4BQ vYlg== X-Gm-Message-State: AOAM533ALZTzJfc2yEiy00mOJgVMNGDLKSoMyijPG22+kcy8c8ZVFMT8 HAACyjxjzCZabX2GkA0VF4U83IfzP1iFhNanjOU= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >