From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A280606A336 for ; Thu, 5 Nov 2026 12:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gM+grsc5 Received: by kanga.kvack.org (Postfix) id 9EC016B05B8; Thu, 5 Nov 2026 07:23:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C34F6B05BA; Thu, 5 Nov 2026 07:23:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9005A6B05C0; Thu, 5 Nov 2026 07:23:17 -0500 (EST) 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 5AE216B05B8 for ; Thu, 5 Nov 2026 07:23:17 -0500 (EST) Received: from smtpin01.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C6F281609BC for ; Thu, 5 Nov 2026 12:23:16 +0000 (UTC) X-FDA: 85400980392.01.B35F9CE Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf31.hostedemail.com (Postfix) with ESMTP id 3693220005 for ; Thu, 5 Nov 2026 12:23:14 +0000 (UTC) Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=gM+grsc5; spf=pass (imf31.hostedemail.com: domain of kas@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=kas@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1793881393; b=JVnXrTb2LB4nvoNmx5XEsXaNDIaIgOkoOY+OGlb1v6uwsAnaOdzB9yX/OTy4nB6x07u16C bBu8+Nx0+dQgABS43d3Kjpux2NIQdnOLSapoE7lzAocwFrT2NIT7uKOiQlbyG4AVxjhysN QKO6xj5D48Q2c2aE2ymk9qfpqQZpMn8= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=gM+grsc5; spf=pass (imf31.hostedemail.com: domain of kas@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=kas@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1793881392; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iivs6yaaggKZsHwVDovGVqLyO+85xXEu4nFRfS6NxC0=; b=q1Xp1kTiejvv3KEbkaQvKTsMravgmC8BHpb8pkJkn4Mwl81aTPzagzkMXDVCdohpOSvDPu NWu0f8WbGGJKJv+sjGUDh2ULODY1DrnAnXFfe3r0ZXe37NoOIRo6lssaizWG/lSA6ZXDII bZhykAXK85aWKeBQ1LMouvijeHZ9kNg= Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 811D660F1C; Thu, 5 Nov 2026 12:23:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF2D91F00A02; Thu, 5 Nov 2026 12:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793881392; bh=iivs6yaaggKZsHwVDovGVqLyO+85xXEu4nFRfS6NxC0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=gM+grsc5ON2YWfiXw5ezs4zq1DkpkWsOpfchNUxTp5Yjauau4ZDwF7cL7o7EToXPl nC+WM1osWOj5OO3sFsgXA1qTb3HYYqv2hgKXRrzURCKMh9kI+yqUhtZ7ZISUprdBxQ qn/gKmcuMOkDiaG4k+ZZcqk0RzikRdHdwS2UozLLpeoqDaa1LeqAH4AOUrJihZRSRy i1AEn6FrS/m3ncFt+sjkxNi4fkCSkTfAeAsdHUpGxPRnrkFKJ37iJZ+SoclQPuLnwT Hfh4mDUlKgqfeJu/9Ov4zoD7vKrJNAuPJzsYgsUf16h4HIBdRgX3/U9p61Q0WAX5f4 wYnWj6MOCYXvw== Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfauth.ams.internal (Postfix) with ESMTP id 07E23198003A; Thu, 5 Nov 2026 07:23:05 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Thu, 05 Nov 2026 07:23:09 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGVfuvqVkxki9la42m479/fuAu38sqk3h0/RigiFu9otpD+tJDC7VpSSzL3xzhHJ4 i+ve1m8wGeY65rOatgOHPXcpXjsv37rr7dyddgk/yAh0bDgP3MmmcTyP5UuxCqL85qvYUE o3u5pQ01TYYDV7f5IxieW8w1IOzD+rgpiA1H6Vh6obTbbIORbX53uFr2uTwYAKHk3fGKhc nUjO0rZPzPOpSVWtVYAS2TWWUq4Jccmsti9YwbSGeZjAh0LJk1kOnkCSKQRopjQ71bxgjS TSGO6CCKXZhNHP3vWoiLOPNjZ60UCE0GBZ8z69OTYOiPSQLPEiIPzed3LiNolFhPbCszcL f/CoAF9Trls1SHQheisn1S1ScJDviV4DEuNsNBLfv95fTgAX8v6vgvCreRGkH8ESGYfxy8 XB0VYu1j3mN7Ij4AM65xmkHX4JdsLKgYi2YSDYI6WjbcUszx7D98PujZZuU08axwcKIlve MutaEkyW+7RyiupRYqfFc0ybLprdk+wh8Fk7lBIpjRv7EVUlKXMUH4fK1d5RLw1yZt8xCM vTz3hgZrIxi5a6ps1osb/rKlkbeDdEIk1OppWk03UpyETN25Lus4NntoQZ/GHpEiSSTAHW PMV+N7Rr9FDzshyE2Nm8p8lff+jZBylcqXHRcjehdSfMeoeMtchqTrNKC2jw X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Nov 2026 07:23:04 -0500 (EST) Date: Thu, 5 Nov 2026 12:23:04 +0000 From: Kiryl Shutsemau To: Joanne Koong Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, baohua@kernel.org, usama.arif@linux.dev, hannes@cmpxchg.org, alex@ghiti.fr, ziy@nvidia.com, baolin.wang@linux.alibaba.com, liam@infradead.org, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, lance.yang@linux.dev, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, willy@infradead.org, linux-mm@kvack.org Subject: Re: [PATCH v4 2/4] mm/huge_memory: don't queue folios when underused splitting is inactive Message-ID: References: <20261103212004.1356327-1-joannelkoong@gmail.com> <20261103212004.1356327-3-joannelkoong@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261103212004.1356327-3-joannelkoong@gmail.com> X-Stat-Signature: domxamax74buchp99ts8zpcxs5nkrajj X-Rspamd-Queue-Id: 3693220005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1793881394-772968 X-HE-Meta: U2FsdGVkX187EoQtnSl7PovT+2zL0X6OWIJnkYKu8TocaPMEnxEx0/6GFvdTckV4IALr2LAgbXjB3sz9nxcwGk6TfXFSUIahYTDEyAvMKRlGh1tLhpTnK+TJDbIn+60SWliq9UWpb9Mpe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9NdbwjoqTpECO+Dqs8LToOzrMO456DqIgA1PJCBIH5IceeyCh6zH4s3wkrhtenbd1NdkXckuJP9QT+1kfklS7x95YzzVp3ljb5tHHqpJIETOvDPXufd+z5kzQwUyTHk1jAVvvP29n77AEp23GI9KSOjytm2zkB1MWDHR3I9Ty6WgADEmqhqN4ke6Mko6zU+atV17VxZ7FTg== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, Nov 03, 2026 at 01:20:02PM -0800, Joanne Koong wrote: > Every anonymous PMD-sized folio is put on the deferred split queue when > it is first mapped, so that the shrinker can find it under memory > pressure and split it if it turns out to be mostly zero-filled. > > With the default khugepaged/max_ptes_none this is wasted work. The > default is HPAGE_PMD_NR - 1, which tells thp_underused() that any number > of zero-filled pages is tolerable, which means the shrinker will never > split any of these folios for being underused. They take the list_lru > lock at fault time, inflate the object count the shrinker reports, and > are then walked and dropped when they're first scanned. > > Skip the queueing when khugepaged/max_ptes_none is at its maximum, and > factor that check out into thp_underused_never() so that > deferred_split_folio() and thp_underused() share it. Since the default > is the maximum, out of the box no folio is queued for underused > splitting at all, PMD-sized ones included. Partially mapped folios are > still queued as before. > > This also matters for a subsequent patch that adds anonymous mTHP folios > to the deferred split list, as it keeps systems running the default from > paying for that on every anonymous fault. > > Please note that the queue has always been best-effort. A folio that was > queued before khugepaged/max_ptes_none is lowered gets dropped from the > queue by the first scan that finds it's not underused, so changing the > sysctl has never retroactively applied to folios that were already > scanned. Requeueing eligible folios when the sysctl changes will be > addressed in a separate patch. > > Suggested-by: Johannes Weiner > Suggested-by: David Hildenbrand > Signed-off-by: Joanne Koong I believe I've already: Reviewed-by: Kiryl Shutsemau (Meta) Don't lose it in case of repost :) -- Kiryl Shutsemau / Kirill A. Shutemov