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 60124606A321 for ; Wed, 11 Nov 2026 19:49:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CFLB/cPC Received: by kanga.kvack.org (Postfix) id 7FBAB6B05B0; Wed, 11 Nov 2026 14:49:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D2A56B05BB; Wed, 11 Nov 2026 14:49:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E8806B05BC; Wed, 11 Nov 2026 14:49:39 -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 4A4C26B05B0 for ; Wed, 11 Nov 2026 14:49:39 -0500 (EST) Received: from smtpin04.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DC4FC1603BE for ; Wed, 11 Nov 2026 19:49:38 +0000 (UTC) X-FDA: 85423878036.04.82DAB65 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf28.hostedemail.com (Postfix) with ESMTP id D760DC0005 for ; Wed, 11 Nov 2026 19:49:36 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b="CFLB/cPC"; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of kas@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=kas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1794426577; 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=gVc6YM8M5IAHsgG4XamDTanrt4p9Rvguj7WxgEd5KeQ=; b=6RPtquW8cvPLB1nKbCCA3KIoxn6pJOI0FpNgrMCPjYRCLa8taUp/Ry6gDFus4JR9gFcAcv s1NTssJJGiMsohi+py7htwgYM+TKKeRh9TJDRjgsfYKK8klxfm7LaIXHnEqe/xTdUflcf2 qc5ELnCwKTfDH/Dx3ouDm/HvsoMiW/A= ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1794426577; b=d73CEA8nM2GNV0bEo0sG6E9W/n1IqezHDLh6YQmflY99G777XjPiMu6p12+LvFm7pU1V3v OfaImDRg4bcENTwb3NVHXoEr5OVSeqqoCJ+TbIbhlfoGo5DMUxp8UbGzwmn6x3ULvaXB1J B3mW1c7ZOevSXduFyE41RglkKCS8U78= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b="CFLB/cPC"; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of kas@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=kas@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 030C745D4C; Wed, 11 Nov 2026 19:49:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65EE31F00A07; Wed, 11 Nov 2026 19:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794426575; bh=gVc6YM8M5IAHsgG4XamDTanrt4p9Rvguj7WxgEd5KeQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=CFLB/cPChRYUDHwlEFHTvMKQ/okKxzi0IRhO0GRhxiBRDDZnNScQyxbPO45ZWQ6zT PXncE585W0d7wWT2u3P+rDmhOotopn2mdO1EJF1peW1OhvmrVkH06SDOfnSFJiU5nM ZugV5YoAyQ0b5sUvEBEZiAlzOYNlhCSoZdQTe/tkZVsHjyxo0BiYZNVQGVFuOCHmhh O7ysLZ/d2PlmU+pIf/tHolLnKbhMJygw2KSRqpB7g3XzgV1FkZNIjbzIRYVKFFnRrT IoCOjjd+19UnCUQkHoH9rHLVjRiK+b44FcXcFmbBtnWHyxBTn4vcZ6rh/zQVNE2m2H yAJ/Io8JzD+tA== Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfauth.ams.internal (Postfix) with ESMTP id D8164198003A; Wed, 11 Nov 2026 14:49:27 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Wed, 11 Nov 2026 14:49:31 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEdupPFVg3GK2wZR+bhvzM7lmON/H/kDh6eMRSZDwCb3j3MA/z6XpUq9kN9AFvMyS zgxK6eXvhIO/RlMkjFBwb6NDEhcxkQGM+ACP2GZ/sgZgNDe6+uGo6DY8cKIOoSXxTC7CzQ STnAxo1I132FTLSmWThy9YNRnudLY9EDMrsciu+IGf2CIyse2jIL7gv5MVc80vDitFJ4U+ mJa+1MgYj2BRB9R4oUsbobDR/aJklmz1wsXV6ESw+/XNvzptwzM9MY/mDWBfhH3chRy0QJ y5U0sNSuNj1EezXb2QP44Q5Lkgpa6wR3t6023acNG9sJppH9oxwxd9eR591GcP2ppb1lH2 9S2G4kR3wtXvNPsWspIA/0Gd/QUWrd1DVm0HKb0D5bu2hcxrOSzvi3/rTYfdsZTfkRpmmQ ezRHgRTtaXq25k0YNRxgHo7tv+NcwNnTKQJl/eLtG3FTo9aDwj95rA6naYiyotToUXuIRO gaW5SPyZ3wu1koL57+YZGq3K6TVfBhDja32VftjmcnB5Hk9UaDGAuM1c/Y11dPYh5Ax/CQ ofQjaluRH5K84DYLxfT6/EyFe0PJ3Tr8rtDbFnUcKraJd/EXdwJRER1axDZmeVoE08ZeWf 1EYf5iUDuodS6fzd0eEafO7mRGK62lmyyrmRDkWafHh/YcasbXTWAC55psmw X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Nov 2026 14:49:26 -0500 (EST) Date: Wed, 11 Nov 2026 19:49:25 +0000 From: Kiryl Shutsemau To: Harry Yoo Cc: Andrew Morton , Vlastimil Babka , Johannes Weiner , David Hildenbrand , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Zi Yan , Lorenzo Stoakes , "Liam R. Howlett" , Mike Rapoport , Qi Zheng , Shakeel Butt , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , Dev Jain , Usama Arif , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v2 1/3] mm: page_alloc: add a watermark check that knows the migratetype Message-ID: References: <20261102093939.3340540-1-kas@kernel.org> <20261102093939.3340540-2-kas@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: m5smigb94yopm3imkuzbdnwiqogyxxwq X-Rspam-User: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D760DC0005 X-HE-Tag: 1794426576-801083 X-HE-Meta: U2FsdGVkX1/qT7SP2NC3gk4OTy7t4s5nv7KXDhDDK6wnrwldNd2XsV8hXcsk9b0gBvgAaOE/EgDLUwEUKkLNsKwMA5nY//AC4ybgFGbXuuJ6ljCSyvjbO1S7QYwATR3X8WnIwAFDnsQmOt/rWnI5HeRYxem3GJxL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Cn+q8/jXU9ZF8/hhps+tkW5bK70380B+sGHW7Y+oJbCvoEZalpi4wRTfTScHw= 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 Thu, Nov 05, 2026 at 05:06:39PM +0000, Harry Yoo wrote: > On Mon, Nov 02, 2026 at 09:39:34AM +0000, Kiryl Shutsemau (Meta) wrote: > > The high-order check in __zone_watermark_ok() accepts a free page of any > > migratetype. Under ALLOC_NOFRAGMENT, a request below pageblock_order can > > only take a page of its own migratetype or claim a whole free block, so > > the check can pass when the allocation cannot succeed. > > > > Telling those apart needs the request's migratetype, but not every check > > wants them told apart. A check whether an allocation can be served now > > has to count only the pages it can take. > > > > A check whether there is enough free memory counts every migratetype: > > kswapd and kcompactd balancing a zone, order-0 thresholds, the > > slowpath's forecast whether reclaim and compaction can still make > > progress. Reclaim and compaction work across migratetypes to free whole > > pageblocks. > > nit: perhaps we could make the changelog above bit more concise. > > I think the necessary bit here is "With defrag_mode, allocations cannot > steal a page from pageblocks of other migrate type, thus > __zone_watermark_ok() needs to take that into account." It is ALLOC_NOFRAGMENT, not defrag_mode: Normal zone allocations get it on the first attempt when DMA32 is populated, with defrag_mode off. And such an allocation can still claim a whole free pageblock of another migratetype. But fair, it can be shorter. A tighter version is below; it also says why kcompactd passes MIGRATE_MOVABLE. > nit: maybe let's set cc.migratetype and pass it? The value is not read there: __zone_watermark_ok_mt() uses the migratetype only under ALLOC_NOFRAGMENT, and kcompactd never passes it. kcompactd_node_suitable() makes the same call and has no compact_control to take it from. Thanks for the review. The new changelog: The high-order check in __zone_watermark_ok() accepts a free page of any migratetype. Under ALLOC_NOFRAGMENT, a request below pageblock_order can only take a page of its own migratetype or claim a whole free block, so the check can pass when the allocation cannot succeed. Only a check whether one allocation can be served now should count just the pages it can take. A check whether a zone has enough free memory serves no single allocation and counts every migratetype: reclaim and compaction free whole pageblocks across migratetypes. Add __zone_watermark_ok_mt(), which takes the migratetype, for the first kind: - the allocator fast path, zone_watermark_fast(); - its recheck after node reclaim in get_page_from_freelist(); - compaction's up-front check, compaction_suit_allocation_order(). __zone_watermark_ok() wraps it for the second kind. kcompactd shares compaction_suit_allocation_order() with direct compaction and passes MIGRATE_MOVABLE, which is not read without ALLOC_NOFRAGMENT. Declare both in mm/internal.h: nothing outside mm uses them. Nothing reads the migratetype yet: no functional change. Preparation for making the high-order check honour ALLOC_NOFRAGMENT. Looks good? -- Kiryl Shutsemau / Kirill A. Shutemov