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 27A04C54FB3 for ; Thu, 29 May 2025 04:26:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3579F6B00DF; Thu, 29 May 2025 00:26:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 308316B00E0; Thu, 29 May 2025 00:26:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F7B26B00E1; Thu, 29 May 2025 00:26:59 -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 EC7586B00DF for ; Thu, 29 May 2025 00:26:58 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7661A8037D for ; Thu, 29 May 2025 04:26:58 +0000 (UTC) X-FDA: 83494660116.19.3CD8596 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 417668000D for ; Thu, 29 May 2025 04:26:56 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CcbW3Ysc; spf=pass (imf30.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748492816; 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=Ex3pdBmkOUDRqy601U9SQqEbyhPUzX43nDu/KUjEDkA=; b=hCUwFUJjRlLq/hyNFuerh8hjKvILsvPI5n8lNVihp4eMIP+aQXYJr/mdWdcY6RUlP+7JxD k24Ck2JgDRDTQRExe1fLoWzLiaOsceA6Rl1uSMXtObHoi46OrGSuCoKoj0k+pXLCRQhK4e PCdvHxmd0vEVqhYHCmXZg8fxB4eBxWo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CcbW3Ysc; spf=pass (imf30.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748492816; a=rsa-sha256; cv=none; b=sFXRJV/F+Z1+hPyDcZy/WiO7h2xxlR8v3qU1TklVNafJZL2jd3mmLa9WgYX2z7Dg/Muf37 A8DIDbKntY5/8FLuTpucqGsDCy+akGJ8+ljif94VBkKQdihq62NIn0OJQO1WjVjnKWHz9+ 2k6iJQt9tixxvchsluOm2myQTQQMTNE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748492815; 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=Ex3pdBmkOUDRqy601U9SQqEbyhPUzX43nDu/KUjEDkA=; b=CcbW3Ysc6PzyTw3jq9p1g+aCRGFOkHmEO45HWGkNxiNNGrxHSlcJmc/DoK010OMyyDlAYp epFR/LeE1GHRIX9lQ6lvUeKmTBPnqFv4OLY9OgUfLkCMWtcPEGWRLlQyXqjJYVbThE1ALe uWS7c0tilr+L1n1T2YV8UEinS3OssaQ= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-xnVi3_IJMD-ACfsZccQhqA-1; Thu, 29 May 2025 00:26:53 -0400 X-MC-Unique: xnVi3_IJMD-ACfsZccQhqA-1 X-Mimecast-MFC-AGG-ID: xnVi3_IJMD-ACfsZccQhqA_1748492813 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-70f841fb19dso8815927b3.1 for ; Wed, 28 May 2025 21:26:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748492813; x=1749097613; 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=Ex3pdBmkOUDRqy601U9SQqEbyhPUzX43nDu/KUjEDkA=; b=FisrYAO6wzzi2c1LHVWQXG7zHMsLsxQxT0d4zBEdbIfstdMZ6YMc2GScdxkz815Fp4 1QkWt5k3Hx3a09hKKG+Zi/pdJzVQynCCTH3xrmcp06/tFWpa30XpcYkxBZdObb6LiC3c mh9HKMyFZ+lfxQvMlVDLi7GgbC9iFj+FQxPT2Q2gKDvVPwh+63Te7s75X/wtFhtzPmFh QD2b/tkQE+02mF+aJnUVODNG4yHgiC9xH8/HZTfpwG55Sl8fqG8Yi6L4xymG4owD+JBM KHaun05dzWk0SB0rkwceDDMuSseD4AzwCAS+pTehKQ6akHRv9QJXkWBO4OmlQUsYY97o cjhQ== X-Gm-Message-State: AOJu0YxjY1vMeVyvitsxr6AGJbSZLK7IeGG1q8ZwU+1DYNDIzYSonhnV 4Lpt8d0NBI5dcw3mIe9JKo2y7j0QWJj1mfWkK3kjXI3vxlkN7J0x4JSDiE+TZr2zQXPHRp8VWdC ctzzvkdL8O5ijmSp++jJyPH2ImrU1u6BRVQdRLwoyTcgYd40LaGVsnz3oMXy7NZ1VYfND9A//66 Mlckk8uC5vMR3JZDqkGxWElf0VW3s= X-Gm-Gg: ASbGncsoDbJApAk2VaxWuSNA8jzbNb9Rfg8+cfR5MSe24eaojNvuAJJJ11h+yGtwJNU NBKOo1gnMjBc32RjCvUDZIW61fh/MydVtzYlGSVG2Il2mEsaskZTXHpRkCHn5A1R8ZeM+uyc= X-Received: by 2002:a05:690c:15:b0:70e:7ff6:9fd0 with SMTP id 00721157ae682-70f3147ae7amr69347387b3.35.1748492812674; Wed, 28 May 2025 21:26:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGa/qWJYpJ/+QQie7VzzCQqjW7fcD4CgkSyasKC81Gvwr9UAPZCZblvzZ/MNvjAq7MgTXKwRCRo7nhYrIssl3A= X-Received: by 2002:a05:690c:15:b0:70e:7ff6:9fd0 with SMTP id 00721157ae682-70f3147ae7amr69347107b3.35.1748492812231; Wed, 28 May 2025 21:26:52 -0700 (PDT) MIME-Version: 1.0 References: <20250515033857.132535-1-npache@redhat.com> In-Reply-To: From: Nico Pache Date: Wed, 28 May 2025 22:26:25 -0600 X-Gm-Features: AX0GCFubEhLqG8ZmT5mBKytjQcZ__0Xo41eeNzsj8MkbhGwDDub_V9w5CoIgzsg Message-ID: Subject: Re: [PATCH v6 0/4] mm: introduce THP deferred setting To: Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, rientjes@google.com, hannes@cmpxchg.org, rdunlap@infradead.org, mhocko@suse.com, Liam.Howlett@oracle.com, zokeefe@google.com, surenb@google.com, jglisse@google.com, cl@gentwo.org, jack@suse.cz, dave.hansen@linux.intel.com, will@kernel.org, tiwai@suse.de, catalin.marinas@arm.com, anshuman.khandual@arm.com, dev.jain@arm.com, raquini@redhat.com, aarcange@redhat.com, kirill.shutemov@linux.intel.com, yang@os.amperecomputing.com, thomas.hellstrom@linux.intel.com, vishal.moola@gmail.com, sunnanyong@huawei.com, usamaarif642@gmail.com, wangkefeng.wang@huawei.com, ziy@nvidia.com, shuah@kernel.org, peterx@redhat.com, willy@infradead.org, ryan.roberts@arm.com, baolin.wang@linux.alibaba.com, baohua@kernel.org, david@redhat.com, mathieu.desnoyers@efficios.com, mhiramat@kernel.org, rostedt@goodmis.org, corbet@lwn.net, akpm@linux-foundation.org X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: C8PepjC5b8vpvdqxD7PlIsi1FJf3TwvYJpYg43-ohWM_1748492813 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 417668000D X-Stat-Signature: 7ca95an6umqwcpz17dx79cnhrwz43zhk X-Rspam-User: X-HE-Tag: 1748492816-211962 X-HE-Meta: U2FsdGVkX190fMlZPUMBIGe3xiVRv/CzTxxJHAxAx140YoAaxqzladYyi1eUF0lm5eENWNEa0+RJpPw52AJ9qhay07F/PHJ8aXft12br4dW+NPD7WjvWbKJteO1RQZ/zK5B+ss2p9QUMApmC5FX31L9/ZL6tD29yUWJz+jXgii/ttxUZCGnvjOdq0M1TwQZNRiazmagapv8OFhnI6Q/d4q9W+JgjzfDJyvy1LUyrjiB78XceGZcrIP6kZWViq2yOXwV3qfbCh5GBU4aLZ1ZYLK4vyLS4HV5rJDCnsSZtyUFxCawAejvtDuKWKghQyROd76be1dIVNRXE1u7knSEKi7ZPrWkttnX66G/2YBFYBVvg4jFDVFtTWPHGJkUsW9omA3GXYtkgmrLGtN79v7SGXmGx/Bwr7HzHSS6Wk7ll/m9e7uDikm+BiJmca3UzAYu0NlcApEHc/9Dq1R78/SOcn8EN2xdNAeEXltmJAtrVnMrCLWEqmUa/P+l2vR7hWN0/jUXCvjMUBrXr2v+fwx3T+QvKpcfsHeT2XC57KO5ytsfJmLZKrW7j4GkG5Ce0kYLEcGjY3vsQObKu+7J650J5eyDCbclI/csKCYCX3mVXBvkifHT5TAIuBeaaTgNeV1861Ml5OQfIcEnlnofOzGG/B0Ykx0qxLHeR6S4VKX9Y2Yho7TzqAfqdWZWgjQvFkE/FOPvDc7klIrA+g0FW9XDr9W1qcRJA4H5gxxQOCOMqqo73+DDhmVt6Bdm13Vq2hiBCg9q+BLjj26m57K87lJOL2Ap+rQJQ9tsCJm41Fjtegq6XmKNyEhnl8W2A7SLw+5tJ1wfg03Nk3oaeN3UpDSGyqQnZK3a5G3mp1AdLXvpYWfpqfkaa8axgbiSbCt7SooMQsKM7CZ+qFF/d79Tfv/c6vEbX1/LwbPfLEPDHelwamLw0WgfncbxBUnnfBNIooGjdete7gsz2eBo18bHCiED VwbLmFaD AfOqnZ1jenyB1mpLiAsRpekJF+bR6UtzQ+LEL5C7j4pqfYL+Vg6ZPw2S3Lt774P54VJUJJ3+CHUz5eTp2I7Y/MEyrl52UF2wRIgME1tjZZZsbJv82jzvY48ykgXOND4FXZXvr1VyVgI1ONWXKPKKvSToTPk0eF23CalRbeZoS0sThrCCCduxiYN1xPkA5c+il/PoWo8wLkNMTkp9hJbN/Maf3JkMBXIkeGE23tVt5KL8/3YsPTrlCn6N5tz5rK2XJLxhMwxoQ+QVsd5Z2CSvcIil5emcOLVFf91Kk8OVwqW4cPAH6TJFeeb0Xc/pqUUIfizYSvSgKxb8pZV0hGvMLipiHdH3ViH7Fr7LN/LjjvPhFSRe9eHHYdg7zfIrnklpaeB/qkGs1nFQ5GHYSYQAAXpCbewx+EUS1+07nVRauMDK//u7PsZ4lJ+fT5mTJyngyLvMG 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 Wed, May 21, 2025 at 5:25=E2=80=AFAM Lorenzo Stoakes wrote: > > To start with I do apologise for coming to this at v6, I realise it's > irritating to have push back at this late stage. This is more so my attem= pt > to understand where this series -sits- so I can properly review it. No worries at all! The only thing that frustrates/upsets me in upstream mailing lists is unprovoked rudeness (which you have not been). > > So please bear with me here :) > > So, I remain very confused. This may just be a _me_ thing here :) > > So let me check my understanding: > > 1. This series introduces this new THP deferred mode. > 2. By 'follow-up' really you mean 'inspired by' or 'related to' right? > 3. If this series lands before [1], commits 2 - 4 are 'undefined > behaviour'. The khugepaged mTHP support should land first as without it, adding a defer option to the global parameters, makes for undefined behavior in the sysctls from a admin perspective. > > In my view if 3 is true this series should be RFC until [1] merges. Ideally I was trying to get them merged together (Andrew actually had them both in mm-new a few weeks ago, but a bug was found that got it pulled, but that is fixed now). The series' complement each other nicely. > > If I've got it wrong and this needs to land first, we should RFC [1]. The khugepaged series [1] should get merged first, but I was shooting for both at the same time. > > That way we can un-RFC once the dependency is met. > > We have about 5 [m]THP series in flight at the moment, all touching at > least vaguely related stuff, so any help for reviewers would be hugely > appreciated thanks :) > > On Wed, May 21, 2025 at 04:41:54AM -0600, Nico Pache wrote: > > On Tue, May 20, 2025 at 3:43=E2=80=AFAM Lorenzo Stoakes > > wrote: > > > > > > On Wed, May 14, 2025 at 09:38:53PM -0600, Nico Pache wrote: > > > > This series is a follow-up to [1], which adds mTHP support to khuge= paged. > > > > mTHP khugepaged support is a "loose" dependency for the sysfs/sysct= l > > > > configs to make sense. Without it global=3D"defer" and mTHP=3D"inh= erit" case > > > > is "undefined" behavior. > > > > > > How can this be a follow up to an unmerged series? I'm confused by th= at. > > Hi Lorenzo, > > > > follow up or loose dependency. Not sure the correct terminology. > > > > See above. Let's nail this down please. > > > Either way, as I was developing this as a potential solution for the > > THP internal fragmentation issue, upstream was working on adding > > mTHPs. By adding a new THP sysctl entry I noticed mTHP would now be > > missing the same entry. Furthermore I was told mTHP support for > > khugepaged was a desire, so I began working on it in conjunction. So > > given the undefined behavior of defer globally while any mix of mTHP > > settings, it became dependent on the khugepaged support. Either way > > patch 1 of this series is the core functionality. The rest is to fill > > the undefined behavior gap. > > > > > > And you're saying that you're introducing 'undefined behaviour' on th= e > > > assumption that another series which seems to have quite a bit of > > > discussion let to run will be merged? > > This could technically get merged without the mTHP khugepaged changes, > > but then the reviews would probably all be pointing out what I pointed > > out above. Chicken or Egg problem... > > > > > > While I'd understand if this was an RFC just to put the idea out ther= e, > > > you're not proposing it as such? > > Nope we've already discussed this in both the MM alignment and thp > > upstream meetings, no one was opposing it, and a lot of testing was > > done-- by me, RH's CI, and our perf teams. Ive posted several RFCs > > before posting a patchset. > > > > > > Unless there's a really good reason we're doing this way (I may be mi= ssing > > > something), can we just have this as an RFC until the series it depen= ds on > > > is settled? > > Hopefully paragraph one clears this up! They were built in > > conjunction, but posting them as one series didn't feel right (and > > IIRC this was also discussed, and this was decided). > > 'This was also discussed and this was decided' :) > > I'm guessing rather you mean discussion was had with other reviewers and = of > course our earstwhile THP maintainer David, and you guys decided this mad= e > more sense? > > Obviously upstream discussion is what counts, but as annoying as it is, o= ne > does have to address the concerns of reviewers even if late to a series > (again, apologies for this). > > So, to be clear - I'm not intending to hold up or block the series, I jus= t > want to understand how things are, this is the purpose here. Thanks I do appreciate the discussion around the process as I am fairly new to upstream work (at least to this magnitude). I have been mostly downstream focused for the last 6 years and I'm trying to shift upstream as much as possible. So please bear with me as I learn all the minor undocumented caveats! > > Thanks! > > > > > > > > > > > > We've seen cases were customers switching from RHEL7 to RHEL8 see a > > > > significant increase in the memory footprint for the same workloads= . > > > > > > > > Through our investigations we found that a large contributing facto= r to > > > > the increase in RSS was an increase in THP usage. > > > > > > > > For workloads like MySQL, or when using allocators like jemalloc, i= t is > > > > often recommended to set /transparent_hugepages/enabled=3Dnever. Th= is is > > > > in part due to performance degradations and increased memory waste. > > > > > > > > This series introduces enabled=3Ddefer, this setting acts as a midd= le > > > > ground between always and madvise. If the mapping is MADV_HUGEPAGE,= the > > > > page fault handler will act normally, making a hugepage if possible= . If > > > > the allocation is not MADV_HUGEPAGE, then the page fault handler wi= ll > > > > default to the base size allocation. The caveat is that khugepaged = can > > > > still operate on pages that are not MADV_HUGEPAGE. > > > > > > > > This allows for three things... one, applications specifically desi= gned to > > > > use hugepages will get them, and two, applications that don't use > > > > hugepages can still benefit from them without aggressively insertin= g > > > > THPs at every possible chance. This curbs the memory waste, and def= ers > > > > the use of hugepages to khugepaged. Khugepaged can then scan the me= mory > > > > for eligible collapsing. Lastly there is the added benefit for thos= e who > > > > want THPs but experience higher latency PFs. Now you can get base p= age > > > > performance at the PF handler and Hugepage performance for those ma= ppings > > > > after they collapse. > > > > > > > > Admins may want to lower max_ptes_none, if not, khugepaged may > > > > aggressively collapse single allocations into hugepages. > > > > > > > > TESTING: > > > > - Built for x86_64, aarch64, ppc64le, and s390x > > > > - selftests mm > > > > - In [1] I provided a script [2] that has multiple access patterns > > > > - lots of general use. > > > > > > OK so this truly is dependent on the unmerged series? Or isn't it? > > > > > > Is your testing based on that? > > Most of the testing was done in conjunction, but independent testing > > was also done on this series (including by a large customer that was > > itching to try the changes, and they were very satisfied with the > > results). > > You should make this very clear in the cover letter. I will try to do better at updating and providing more information in my cover letters and patches. I was never sure how much information to include! I guess the more the merrier. > > > > > > > Because again... that surely makes this series a no-go until we land = the > > > prior (which might be changed, and thus necessitate re-testing). > > > > > > Are you going to provide any of these numbers/data anywhere? > > There is a link to the results in this cover letter > > [3] - https://people.redhat.com/npache/mthp_khugepaged_defer/testoutput= 2/output.html > > > > > Ultimately it's not ok in mm to have a link to a website that might go aw= ay > any time, these cover letters are 'baked in' to the commit log. Are you > sure this website with 'testoutput2' will exist in 10 years time? :) > > You should at the very least add a summary of this data in the cover > letter, perhaps referring back to this link as 'at the time of writing fu= ll > results are available at' or something like this. Ok good to know I will find a way to summarize the performance and result changes more cleanly in the cover letter. > > > > > - redis testing. This test was my original case for the defer mode.= What I > > > > was able to prove was that THP=3Dalways leads to increased max_l= atency > > > > cases; hence why it is recommended to disable THPs for redis ser= vers. > > > > However with 'defer' we dont have the max_latency spikes and can= still > > > > get the system to utilize THPs. I further tested this with the m= THP > > > > defer setting and found that redis (and probably other jmalloc u= sers) > > > > can utilize THPs via defer (+mTHP defer) without a large latency > > > > penalty and some potential gains. I uploaded some mmtest results > > > > here[3] which compares: > > > > stock+thp=3Dnever > > > > stock+(m)thp=3Dalways > > > > khugepaged-mthp + defer (max_ptes_none=3D64) > > > > > > > > The results show that (m)THPs can cause some throughput regressio= n in > > > > some cases, but also has gains in other cases. The mTHP+defer res= ults > > > > have more gains and less losses over the (m)THP=3Dalways case. > > > > > > > > V6 Changes: > > > > - nits > > > > - rebased dependent series and added review tags > > > > > > > > V5 Changes: > > > > - rebased dependent series > > > > - added reviewed-by tag on 2/4 > > > > > > > > V4 Changes: > > > > - Minor Documentation fixes > > > > - rebased the dependent series [1] onto mm-unstable > > > > commit 0e68b850b1d3 ("vmalloc: use atomic_long_add_return_relax= ed()") > > > > > > > > V3 Changes: > > > > - Combined the documentation commits into one, and moved a section = to the > > > > khugepaged mthp patchset > > > > > > > > V2 Changes: > > > > - base changes on mTHP khugepaged support > > > > - Fix selftests parsing issue > > > > - add mTHP defer option > > > > - add mTHP defer Documentation > > > > > > > > [1] - https://lore.kernel.org/all/20250515032226.128900-1-npache@re= dhat.com/ > > > > [2] - https://gitlab.com/npache/khugepaged_mthp_test > > > > [3] - https://people.redhat.com/npache/mthp_khugepaged_defer/testou= tput2/output.html > > > > > > > > Nico Pache (4): > > > > mm: defer THP insertion to khugepaged > > > > mm: document (m)THP defer usage > > > > khugepaged: add defer option to mTHP options > > > > selftests: mm: add defer to thp setting parser > > > > > > > > Documentation/admin-guide/mm/transhuge.rst | 31 +++++++--- > > > > include/linux/huge_mm.h | 18 +++++- > > > > mm/huge_memory.c | 69 ++++++++++++++++++= +--- > > > > mm/khugepaged.c | 8 +-- > > > > tools/testing/selftests/mm/thp_settings.c | 1 + > > > > tools/testing/selftests/mm/thp_settings.h | 1 + > > > > 6 files changed, 106 insertions(+), 22 deletions(-) > > > > > > > > -- > > > > 2.49.0 > > > > > > > > > > > Cheers, Lorenzo >