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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D3BCC54755 for ; Thu, 15 May 2025 04:41:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B0BA6B00DC; Thu, 15 May 2025 00:41:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 260BF6B00DD; Thu, 15 May 2025 00:41:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B3646B00DE; Thu, 15 May 2025 00:41:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D898A6B00DC for ; Thu, 15 May 2025 00:41:22 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C0FFC1414BE for ; Thu, 15 May 2025 04:41:23 +0000 (UTC) X-FDA: 83443893246.07.B9E6948 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf02.hostedemail.com (Postfix) with ESMTP id 5BD2380009 for ; Thu, 15 May 2025 04:41:21 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=c2XrBq4F; dmarc=none; spf=none (imf02.hostedemail.com: domain of rdunlap@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=rdunlap@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747284082; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bx2b5u0UIRHpVoa/cRaHEgW1QwNFD2w2QJQlPwvTLYw=; b=DFcVJYGcQU+JzhXYX0ZJZrWlraXRe78fc74OWWQ4LDKSaSS16Ns6heHVLtybPhHACX0rch EhbmrhmsdpzXfY7gfJX0l3+qkqzq1lwqasuxIfl+8Qgly/HparwF7FIPIjrXqkLSEpORbi TCNbThl0PzXqqnB/nhUaK7IPaIdj48w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747284082; a=rsa-sha256; cv=none; b=1nW4C3F09SK3huKYSivzJfnMaK6nE/dTAd6ACXERqfEEqLimH39cANLhaKdWIbKswXr0g6 HCZTk2JFUGKxl5sKPixkV4K2hE+Pj+ke6lA84lKyqoPSTYb4cvVQWwOyhNXtC4ADrs9I/f sJ1TpRYdNlEeQV3/K/5sQ842wigviV8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=c2XrBq4F; dmarc=none; spf=none (imf02.hostedemail.com: domain of rdunlap@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=rdunlap@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=bx2b5u0UIRHpVoa/cRaHEgW1QwNFD2w2QJQlPwvTLYw=; b=c2XrBq4FdmOhmUe9/Fim0tB23C Anh7n3crTKCIzBdlLLvXe85YGRb28OEArR6oV1dYk+lC5LgRE0+tFuu6YDHAP9W1OD7Ar5BQwTztx 5GHIKgEqFyp9OZ3GyXtL+K83o7UyKtW+15UiQ1mG8tE8STi1rd2BdQ/XBLn7ZnsAAqBH1M+hYU5YQ TRJQiVQqpxoTDzYY4eBgO4PLjv51kwv0I12tMOJC9E3p2egwQzmIeZq2rIO8TXXYmwfzmJPA184nv LdufpwDRvQBes8/EEU9q5MvVmYEZi4ThPsmoRB+6vFVKoLsg/S/a4p9/hAmetxPfSO1crQ4noP8mh dFqfjQWg==; Received: from [50.53.25.54] (helo=[192.168.254.17]) by desiato.infradead.org with esmtpsa (Exim 4.98.1 #2 (Red Hat Linux)) id 1uFQP4-0000000HL60-02cW; Thu, 15 May 2025 04:41:07 +0000 Message-ID: <86845229-d8b3-4dae-89d3-888dc4d73ea2@infradead.org> Date: Wed, 14 May 2025 21:40:57 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 12/12] Documentation: mm: update the admin guide for mTHP collapse To: Nico Pache , linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: david@redhat.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, ryan.roberts@arm.com, dev.jain@arm.com, corbet@lwn.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, akpm@linux-foundation.org, baohua@kernel.org, willy@infradead.org, peterx@redhat.com, wangkefeng.wang@huawei.com, usamaarif642@gmail.com, sunnanyong@huawei.com, vishal.moola@gmail.com, thomas.hellstrom@linux.intel.com, yang@os.amperecomputing.com, kirill.shutemov@linux.intel.com, aarcange@redhat.com, raquini@redhat.com, anshuman.khandual@arm.com, catalin.marinas@arm.com, tiwai@suse.de, will@kernel.org, dave.hansen@linux.intel.com, jack@suse.cz, cl@gentwo.org, jglisse@google.com, surenb@google.com, zokeefe@google.com, hannes@cmpxchg.org, rientjes@google.com, mhocko@suse.com, Bagas Sanjaya References: <20250515032226.128900-1-npache@redhat.com> <20250515032226.128900-13-npache@redhat.com> Content-Language: en-US From: Randy Dunlap In-Reply-To: <20250515032226.128900-13-npache@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: ac3xqz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5Nv4Q7JVmMMu pG/yJsQY cgOEw4+nNFef/uBQ3odIgJMO6B6a0RYMU2RCtcuIUEMrxvhoZQ5NWCCFZBws36VgNshUZWZgaFEvB28sFVB98PipXKkQ/EcSSnFRUUyjA8/ZkwUjSDxxh4da+37hP2JNMkndJDVXbeCj/6K8kMKWVde7eKk1ABGj3G65X7DFNDM/fVkRqdpvAroKox+XaEHwnDD3zLW1JkPz0p7XhjxoWt9yXE71MzpjfG3VaAiVmOqIxb+x1Ffsvcbdci8vuKB22zmVHDqLYt4asLnQiMoC0zXC9H7FrhPR8qkVRobIP03ZcaRdcYixxOO9iHtENazk/ZWNvkLr+6DV+UAMEFHdhB8Ty1kN2iiLAy3co6xHnqXhEgmLc1EQZAXGY0C0XtlvqidYsIms//EJRII0= 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: List-Subscribe: List-Unsubscribe: On 5/14/25 8:22 PM, Nico Pache wrote: > Now that we can collapse to mTHPs lets update the admin guide to > reflect these changes and provide proper guidence on how to utilize it. > > Reviewed-by: Bagas Sanjaya > Signed-off-by: Nico Pache > --- > Documentation/admin-guide/mm/transhuge.rst | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst > index dff8d5985f0f..5c63fe51b3ad 100644 > --- a/Documentation/admin-guide/mm/transhuge.rst > +++ b/Documentation/admin-guide/mm/transhuge.rst > @@ -63,7 +63,7 @@ often. > THP can be enabled system wide or restricted to certain tasks or even > memory ranges inside task's address space. Unless THP is completely > disabled, there is ``khugepaged`` daemon that scans memory and > -collapses sequences of basic pages into PMD-sized huge pages. > +collapses sequences of basic pages into huge pages. > > The THP behaviour is controlled via :ref:`sysfs ` > interface and using madvise(2) and prctl(2) system calls. > @@ -144,6 +144,18 @@ hugepage sizes have enabled="never". If enabling multiple hugepage > sizes, the kernel will select the most appropriate enabled size for a > given allocation. > > +khugepaged uses max_ptes_none scaled to the order of the enabled mTHP size > +to determine collapses. When using mTHPs it's recommended to set > +max_ptes_none low-- ideally less than HPAGE_PMD_NR / 2 (255 on 4k page > +size). This will prevent undesired "creep" behavior that leads to > +continuously collapsing to a larger mTHP size; When we collapse, we are either size. When or size; when > +bringing in new non-zero pages that will, on a subsequent scan, cause the > +max_ptes_none check of the +1 order to always be satisfied. By limiting > +this to less than half the current order, we make sure we don't cause this > +feedback loop. max_ptes_shared and max_ptes_swap have no effect when > +collapsing to a mTHP, and mTHP collapse will fail on shared or swapped out > +pages. > + > It's also possible to limit defrag efforts in the VM to generate > anonymous hugepages in case they're not immediately free to madvise > regions or to never try to defrag memory and simply fallback to regular -- ~Randy