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 CB194C2D0CD for ; Wed, 21 May 2025 10:42:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 509B06B00A1; Wed, 21 May 2025 06:42:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4936D6B00A2; Wed, 21 May 2025 06:42:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35A276B00A3; Wed, 21 May 2025 06:42:26 -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 141CF6B00A1 for ; Wed, 21 May 2025 06:42:26 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BE4381A0F53 for ; Wed, 21 May 2025 10:42:25 +0000 (UTC) X-FDA: 83466575850.12.2F0FD76 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 71B80C000F for ; Wed, 21 May 2025 10:42:23 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KOaigD1O; spf=pass (imf10.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=1747824143; 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=CKNmbB10vcbsW4zmbX/wZ2PtRPWlG9QOl8Yo9wDdnoM=; b=Cyy0R5SvxSbvuXSezKAvcYpWWwe2MPpGVIqsMH5FchidJr72vNABqsbOjJUSN+Was/5B2+ 6g2Q/aKYGLW1M+nEmDSImT1CAFVya3J5SgkLtr1gFX1wJR9JE8IPwlxBbsUi1EZkZujcGq 5LbLsuhxLOwyHf7q4bFLCjHGyLOtr5s= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KOaigD1O; spf=pass (imf10.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=1747824143; a=rsa-sha256; cv=none; b=5oLEcRd/GHZ6TI3+PqCWYgvpi62EPDwrnccqao3JtsCGu/QPBaSIZJEM4gbyoqQgZvFWpV fZzf8PtZM980UJ0V1dicam7apPNc2eWJ//0e97JHTTbHCi5ykGwFVlgmaZdzLIz4xhCgbQ h/ZBTR0wiWj1zGDGwp54NM26/+LZU4o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747824142; 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=CKNmbB10vcbsW4zmbX/wZ2PtRPWlG9QOl8Yo9wDdnoM=; b=KOaigD1OCG4PP2nB1BxAvQi/8kD1s5WaIJk4yMvVdMoV04LRMYd+bBgprrAqdEaAr9xafe ZOMeP+uhSYxj6ao13nmLscS8o2bne+atItAA9WheW94O60x0QJl67gNJ9aP4fGSFoSDSTB D/nMcbV/A5QQtMUdH/o/4SldujqwvSs= 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-30-3QEmC2abOsWL_xuzeLRINw-1; Wed, 21 May 2025 06:42:21 -0400 X-MC-Unique: 3QEmC2abOsWL_xuzeLRINw-1 X-Mimecast-MFC-AGG-ID: 3QEmC2abOsWL_xuzeLRINw_1747824141 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-70df446e876so5112097b3.0 for ; Wed, 21 May 2025 03:42:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747824141; x=1748428941; 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=CKNmbB10vcbsW4zmbX/wZ2PtRPWlG9QOl8Yo9wDdnoM=; b=jvc7nfADtfoE9Dk//Q50evgDgoGthh8uFGc+z2MQ4N+0LkxflU+E/r+UTa6O0vYmo7 1rYzMk7VJFDE+QoOqQ/3mGgK/ToDwo8EnB3i29bgZNFT5sCL/E2he7BGJSo3I/7WWAYO 3/KrGiRivFpXGlMAEBK04lGVjD5DcCyp18+FDxyCZeCNWoxlxfib7tN7M0K7CqZ3Z6xr Beh7PXfauAjTNpIIvG5dzCF02k+OgnBZdI0n8BwVsyZGZNEoOaAY8taXeIP25ll22kep YvY3Mn91BggoE3gnN4e9kbzMTZwjzs22AxCTbk2No2by3zZQhHNvJFkjbei3qhFvMCGH Y/Sg== X-Gm-Message-State: AOJu0Ywa6R8g2io7ORHRUROg+nbbZtn/v6lq7DK+ZsPUjy01fpE5RCpe cYd4b19S+p5Soa8gEYC3INm4hH+kXgCdHKzjNoDK3neZ4by+bzDupVFfWA3rVU3wfiHXZWlUnaq b06U3Xlu40Qju8RrdGNZ6aRTCf0LRmWaRMhqM91GKR0fnp7v8J9K/D7obz9eB9o5QKuwhUHB9l2 4vbxzQpWKymv67b8wx6a+/Cd4e/2o= X-Gm-Gg: ASbGncuXe31XYj3dCIbGp1ufoGlFhHdSn7aBTYcZL96YJ8+3nTP6CYNVX70q6yqnadC XnOS9BG/IFwOW+S5Z0Gh131IQk6Eyk7p0Vr3DpnsHL97DFnoHV+1o5Hpp1zq9qpLewGxd+ww= X-Received: by 2002:a05:690c:7489:b0:70c:ceba:16 with SMTP id 00721157ae682-70cceba054emr174587547b3.17.1747824141109; Wed, 21 May 2025 03:42:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFc7itCFV8Xw+8JFZwPZvK43iKB77KRF0fgP5X10fayvh+Qx9isOV/fA63yAJNt9cpK5i7uTHoJVNBN1jb2w5w= X-Received: by 2002:a05:690c:7489:b0:70c:ceba:16 with SMTP id 00721157ae682-70cceba054emr174587387b3.17.1747824140736; Wed, 21 May 2025 03:42:20 -0700 (PDT) MIME-Version: 1.0 References: <20250515033857.132535-1-npache@redhat.com> In-Reply-To: From: Nico Pache Date: Wed, 21 May 2025 04:41:54 -0600 X-Gm-Features: AX0GCFtHdsofhzIiCk03cEhb4MTgnqpC3s_PCMaCZSWego9Gx5BB4HSyLT-TgIE 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: FOPmfjZyJxqednUSZWXJLz_ylpiHSvlnSyEdGQK7eRw_1747824141 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 71B80C000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5fbgrz8di9cmfy7g43knytq5itkesbkb X-HE-Tag: 1747824143-959750 X-HE-Meta: U2FsdGVkX1+S9CtHASFpmy40RephXTKUmPuDnBtH+CKHFGoqLKA4WG6dJMIdaflm2k9npHHdKOfHrcQIEWo+KDo78+KFf5KFQ2OXM6la8e9DIyf7hnHQGghii7NSVcc1+OTHbNa7QspBgjwHz6I85XAQ5ZjYCuYFMT6i4uTSjnqGvCrO0o1E9Wb9aiMhpckv4yzGl9M28BXYu8UXNSZNqCVhpK9DFrJvl5WyYXsNdYkfGODx0FNn9vQIqPST4C1wcWy/DIx8B8SDAlFIywc13mryD4ZJ4ofBUuXZE0I5ujeFDify8LXHfJOyMlmKMWSmP3xB5UmuQr5N5Nf8t4gQqIr7Mg/QK2d+lz9xHY6exNQe67TXN5883q8qHE/p/osBcgNmUfoLl2il1iUZzxQwNBBderNiqaH9gHnUHKnSrn5j19PHlbB/DwwhLySk9GA9T5e0K+/Lt5GrOYJGWPcBgmpoSA/yuLkNxJLecxLb9CclGf/ceFtzfJY/WPsq5ydHfyyHjUksEaMMTOaVe4G9GK5MXTBkGNIwr5vxkTh3EIaOs1YZSorG9ljtbw3vvciDJ8LbfVJjOdn83YtgB1zmSS8JchnI8sIGBD4CKoXRbsRXzkTg3LyTOp389onAqkwPOUPu1gJirJCDooH8BASVsre6iAgyV01z/t7QvZrkilV2/JUxVUkP8e+HrlDUh2B5fq/34hPZwFpiYzyTqbVKp7cOYcGVmzuBU9hZ/XaPip3X1fO17JWNR06tgvuNtDotSbN2aq416n9V76Q6yoF1N6uYxq9HmtYj9icMp18pJONhW4rONyw0Vqjkpcjy98WfpH3T7jywb5yzzn0Lr1jXAR3tSIJbL82xFvs2jQXaGgSFAKoB/dY8kuBw7d12Tc96U2E/9M9hIdkvtnWlGzJNxIoALF2uGMvi/TlATA2EaGzRSMToaMeXWc5C6/g0DkwIvY7BT86hmb5GMKFs9hn GS5ePfad MEwGhnd0zCh71Gy5uHamd47Uxzuz9r7mRpxCXHR8zSAElf0587nx8Tto7QGXawshOuFdUvOxHkczkZotX2FWBd5+fGSGSRRdoRR+6WUFVYh+lX1m9igbZU28qOML+xIdkJSFMRg9m2A6aUmUE4uR/7aiV0P1uake2s0Kk/qE7DLyQ3iOK6awlSSDwVzQ2hOik/QOuMyzBcB+zAz66ZqVirdy/moKWEBEDETcS0YyTHCCZcQmVCB3YlGhhAmDjEvhVRVKCS/sjOdfo97L8C2YuiZJsOgqaHwLylxXsQHTDn59ZeugPCdKThUb8vCiItt07tXVI5cNuI7rWfh7XTmmumNuNm3P5EhKcqH1Hor83HPTI4Ea5yM5XXq4lhpdc7ta494z7zqHWla98Z/pBgpZvMeNORCG+BcNrzSMv+S+nMi4OMFhTe/xLnYfNHjtglVJ4OLVj 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 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 khugepage= d. > > mTHP khugepaged support is a "loose" dependency for the sysfs/sysctl > > configs to make sense. Without it global=3D"defer" and mTHP=3D"inherit= " case > > is "undefined" behavior. > > How can this be a follow up to an unmerged series? I'm confused by that. Hi Lorenzo, follow up or loose dependency. Not sure the correct terminology. 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 the > 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 there, > 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 missin= g > something), can we just have this as an RFC until the series it depends o= n > 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). > > > > > 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 factor to > > the increase in RSS was an increase in THP usage. > > > > For workloads like MySQL, or when using allocators like jemalloc, it is > > often recommended to set /transparent_hugepages/enabled=3Dnever. This i= s > > in part due to performance degradations and increased memory waste. > > > > This series introduces enabled=3Ddefer, this setting acts as a middle > > 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 will > > 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 designed= to > > use hugepages will get them, and two, applications that don't use > > hugepages can still benefit from them without aggressively inserting > > THPs at every possible chance. This curbs the memory waste, and defers > > the use of hugepages to khugepaged. Khugepaged can then scan the memory > > for eligible collapsing. Lastly there is the added benefit for those wh= o > > want THPs but experience higher latency PFs. Now you can get base page > > performance at the PF handler and Hugepage performance for those mappin= gs > > 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). > > 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/testoutput2/ou= tput.html > > > - redis testing. This test was my original case for the defer mode. Wha= t I > > was able to prove was that THP=3Dalways leads to increased max_laten= cy > > cases; hence why it is recommended to disable THPs for redis servers= . > > However with 'defer' we dont have the max_latency spikes and can sti= ll > > get the system to utilize THPs. I further tested this with the mTHP > > defer setting and found that redis (and probably other jmalloc users= ) > > 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 regression in > > some cases, but also has gains in other cases. The mTHP+defer results > > 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_relaxed()= ") > > > > V3 Changes: > > - Combined the documentation commits into one, and moved a section to t= he > > 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@redhat= .com/ > > [2] - https://gitlab.com/npache/khugepaged_mthp_test > > [3] - https://people.redhat.com/npache/mthp_khugepaged_defer/testoutput= 2/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 > > >