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 A2D50C369D5 for ; Mon, 28 Apr 2025 14:55:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41C206B00A6; Mon, 28 Apr 2025 10:55:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CA366B00A8; Mon, 28 Apr 2025 10:55:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 243556B00A9; Mon, 28 Apr 2025 10:55:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0490A6B00A6 for ; Mon, 28 Apr 2025 10:55:18 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 188405BC24 for ; Mon, 28 Apr 2025 14:55:20 +0000 (UTC) X-FDA: 83383750800.08.953DB3A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id BB45940004 for ; Mon, 28 Apr 2025 14:55:17 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eF8s16W+; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745852118; a=rsa-sha256; cv=none; b=wt565vdX+bZKBJd/rKtIGF5YDghC8okXGn3F6xeZukPkbOBqP9dab0UVnsuhnHRXQt85L5 K0Kn3HYsyWy0z6mOLmF4uDygKG2poxYqjw0btgy7goKEGN2ewRlnIoA2Aalep7ZmcrkZK8 aQv1aqHSa1G+7MLneu7N10LuPWfbYSI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eF8s16W+; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745852118; 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=Y35svQEUNVinLjrbig+h/RI+A+7BGDLM2oykyzI/Jak=; b=j7X/5aH9TXnVFadTciCF+SYHhQqooiTXbU5PgOQblFUtNxx6VMinl8EBYP8lmiveaqTcd4 jBDjx8x+ulqMhi+ThviL0HlgpF3x+eoim8xEU45ZscUjH5+eo4piS4lpSFn/U6w4VVj9wP ylG0BKAKvQZ3fq2bmwEpg0Rje9aQK5Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745852117; h=from:from: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; bh=Y35svQEUNVinLjrbig+h/RI+A+7BGDLM2oykyzI/Jak=; b=eF8s16W+7kkbU6vl6cyCrGOz05oGWR8+U4DuiZegV7NvGKDYSVfYWJYYessmPKxOPERyaB uhDtj7Abj2ysEzyZ6j3qlpmZyqyOspdkcRVk4DDV2pcdSOydgB0g8921O/Z7YHbeggffR7 UWs6x/JCaaOiKrmgL+HH+0eyK+pl2wU= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-140-tKP5I3gRP02Wu7JrxL6g7w-1; Mon, 28 Apr 2025 10:55:15 -0400 X-MC-Unique: tKP5I3gRP02Wu7JrxL6g7w-1 X-Mimecast-MFC-AGG-ID: tKP5I3gRP02Wu7JrxL6g7w_1745852115 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-7080c0fe7b5so66291717b3.2 for ; Mon, 28 Apr 2025 07:55:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745852115; x=1746456915; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y35svQEUNVinLjrbig+h/RI+A+7BGDLM2oykyzI/Jak=; b=JD3pYSg2oAq2VnpvL9BSbl9134XXCjyC7qB+lDHKzmjHlpDM/IekNaRzA4Gbv0qWXE yzJAiaGON/AuVZa4bq17yCAZFc9M8rO/dtUSKILPoi4H8Gb/ZGxPEXLnXSAb9NzkFIdC A0aPBA36Br5rmpFI1q+Fc6ORr3Dv8UYlLS/Utfv0pT6LRea6kZtoV0GquP9hHoistD2h DqTl4AKDCWrbOJ7r4e0vsFG9so0dNcgyFDMLDcRsFSfx5COzaN7XmtpGzarZbWWdhBrZ uxq34h3+utNDzt4cHkeBwOx0Inc8uUtTLX7m11JhUFekZrqW1/aIGDxbGzgW6/v23u0v yNsw== X-Gm-Message-State: AOJu0YxeM7fxkTtv8ZPyzQuMniXIaOJlMyuXys2SdZLuN7g31fwpcZ6a zIMLRdDXW4YR+DClIRzq3bjBIt9ogDnDiSLetkkYgtdlBpvtQgky2nDWEhg/gJJHyf9M+A4SabV RqLeZaPnoEky2qe9t4uBW2AFqr5pU5gQ68cfrkztcUIyCpmkRWPAPibXOugkT8IWmgGjC05go6n ftXn341OG+uSNnp3e1TezuDM0= X-Gm-Gg: ASbGncucMDbL5EXZwdAsTN/05qOktZOkwPewVXID/V0z5+eUkg3Yr9fpEh7/VEdWx61 l1BuTyv1r/ujW3Ir50X6FIvTgL7wrD7y2rKRk5tpfkrSu733b+s7uWsScMgZ5af+h3ibQhyac5l azZQP3MJw= X-Received: by 2002:a05:690c:39b:b0:708:1d15:e013 with SMTP id 00721157ae682-7089963f2cemr325967b3.7.1745852115060; Mon, 28 Apr 2025 07:55:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmPzgoIcf2zjGWAfQJdt3FvqX6eeOCmgl+PxaPPQiwuCUtJ53kFcyZuTL8sqPiYecQmPEK1B0eYwqIXjEZnPg= X-Received: by 2002:a05:690c:39b:b0:708:1d15:e013 with SMTP id 00721157ae682-7089963f2cemr325477b3.7.1745852114651; Mon, 28 Apr 2025 07:55:14 -0700 (PDT) MIME-Version: 1.0 References: <20250417000238.74567-1-npache@redhat.com> <20250417000238.74567-13-npache@redhat.com> In-Reply-To: From: Nico Pache Date: Mon, 28 Apr 2025 08:54:47 -0600 X-Gm-Features: ATxdqUEM4Y4YSJdY2ZlnauGjTRYOP-E22W7On3YrDJ0KhY5tdri4FdTql7M6Xhs Message-ID: Subject: Re: [PATCH v4 12/12] Documentation: mm: update the admin guide for mTHP collapse To: Usama Arif Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, akpm@linux-foundation.org, corbet@lwn.net, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, david@redhat.com, baohua@kernel.org, baolin.wang@linux.alibaba.com, ryan.roberts@arm.com, willy@infradead.org, peterx@redhat.com, ziy@nvidia.com, wangkefeng.wang@huawei.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, dev.jain@arm.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, rdunlap@infradead.org X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: u5E-mjTOLnlL1qAGDAFrNvksisdLY7KuMHGrmdgr-SE_1745852115 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: BB45940004 X-Stat-Signature: ysxp1orgic4xmjg5iko738d7gw93b7x6 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1745852117-588235 X-HE-Meta: U2FsdGVkX18XyZeO1Pi5k3hWc6Spl500jVxdiWz3M5+PWOwhI416u1eljfCHN50CiYOnxYD6pWdhCHP9PmwjP5f+AzSv61ObgD61Sbes/V3EBMS8kxbny1w46wF/yiBR93eFL/KmC490qAV7IuiW2KYT2IzqkN2xo83riN1vya3BCACcwoKBAVJodjuM+d67BgqOmlRHy8Od49uKRMimJkh5ZXjMHlhE/rDubJJQ56ehip4ippio+9xZyNic+kEuHMrw4S+U5diK4YEHwURCOpoqDo7b0DrmIXyxiRu3ske9ZOmf7VAQj6PaCRSZOjEOezCdJgroFHIlhNayHb6r3TCyTZUhm766vmD+FZTQyqMBlDc5G1poyKqx381MH+mzJvAxQm6UcQ7BV88zd8CnhOmMrhjs496tXbT72GVqW6dMm/VhwGsoTdAQKT/RQDRdKZiSscHejtY/OcirWJeTWPirymmwahfOnlKbVKNyna+R0P2wdh9AzU3vUm1Vm+lySDdZ2HE0FtCLLV9o+/VNAwrQTkYk/YLDOOOX2H0RKN/jnlcPOwW7DvNh5mjHTZUyuwJ/CxDfDkG+gkzI5QFfVvjHajqGv/Te/De5tG0Cc+5mVvNwBnErJI5NUw6FSpZ38FEiOGSLjWpIz0oho+ELIG+7m6qfw7zSJLLLEezPoWxp6qJUzRfGox0EmX8UHq1QQDkFVla625ijhB7dWEUMN5ALQoK5U0nQ2XXG/PlDeLthsrgigwSsnA1oaWGqaMmj2WJG7X5b8kD/ebLmxWDAnxjP93GFpIHVwsb09fQTEvqzuiW4hPh0sSXb3fD8ke+OW3Yd+gG1111OeZzl7ZDJkBaRp8zfEjfuv/W0YFBeUB0xUGURiYTnjfrEQM5ni/sXA6OXZPk699vqd3F3FDEKi6FZE2UUKo/75x8ArgwugGrY1R/CUqFVNQbOKPJvagxZzTcR1kyq8L/ERHTDCjo l0DkQF8Q VLzxUqjALKcZ2VWB9/br4L1HIjObE6GtnCTFOtlena5zZbzhd8lZKFu+8lZAcXZR15e8BWYVcu5IQrvVkOB5ztWfHmMQjOfi6JEKy60ZNK88xyUcnlSOcinPQh6+rh+OPI3KDAQ9kRqy2QqADe7bCAQBn+2SzXsLlx0cs+Mms5K1gA1ArtHvGtVUK4PoBrJsQtwoIqBojz/6EnYuJlgjMkWsTEbXq7RxcAJjDrMiBnXRIFNcpveOKtgFPhM7fgsz5VT+RmEa+y1eQ5m95aAESd7J1iyV/KBWFFM7BTCgEBr9+3UtiU+N93D34OgPcpdKIB3gYP4sGkMYyhSLGLmEyRGBv0w2A7ITKPpLkhsdFM12XQnoCog0lQV8CNA== 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 Thu, Apr 24, 2025 at 9:04=E2=80=AFAM Usama Arif = wrote: > > > > On 17/04/2025 01:02, 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. > > > > Signed-off-by: Nico Pache > > --- > > Documentation/admin-guide/mm/transhuge.rst | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation= /admin-guide/mm/transhuge.rst > > index dff8d5985f0f..06814e05e1d5 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,14 @@ hugepage sizes have enabled=3D"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 w= ill > > +prevent undesired "creep" behavior that leads to continuously collapsi= ng to a > > +larger mTHP size. max_ptes_shared and max_ptes_swap have no effect whe= n > > +collapsing to a mTHP, and mTHP collapse will fail on shared or swapped= out > > +pages. > > + > > Hi Nico, > > Could you add a bit more explanation of the creep behaviour here in docum= entation. > I remember you explained in one of the earlier versions that if more than= half of the > collapsed mTHP is zero-filled, it for some reason becomes eligible for co= llapsing to > larger order, but if less than half is zero-filled its not eligible? I ca= nt exactly > remember what the reason was :) Would be good to have it documented more = if possible. Hi Usama, You can think of the creep as a byproduct of introducing N new non-zero pages to a N sized mTHP, essentially doubling the size. On a second pass of this mTHP the same condition would be eligible, leading to constant promotion to the next size. If we allow khugepaged to double the size of mTHP, by introducing non-zero pages, it will keep doubling. I'll see how I can incorporate this description into the admin guide. -- Nico > > Thanks > > > 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 regula= r >