From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794589388; b=i1OoqGFKBoIyZI4MPmonqIQgxtnyEBm9JIj2HJ5KNP6DWEKSnNTQXskjZh3+nsJvGXxZ CAS2ubkKxe5fDg1y4c9MMWDNzthBYGrOSWsL0m6S+6lu7YPrFf1iXdZsUfRUFSEJAejDC DKLdtcKaO6NRilYY0QS2UA0WuKYdXZk5crH6aUoH4VLlos54CaUe//zUz0i6jkYs4Z65u y0N6LHz1vf3PQyGDB2k4L53AJvmXfbr4AsypdNKbrBaTr2/bOEKjnDKqKTCC0m9kjkAmS JhAScuraHxDdYzxEvw2lOZbd0ooCWwGvvNOJH2onMZisJYLUL7iGf/6FmUWg5y5MsHQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794589388; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:Content-Language:To:Cc:References:From:Autocrypt:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=b1iBR06mysXuO9oyeYat1Y60ZRUTWo8aGvB3eQgMSoA=; b=wQd/RjuM1wv6l7irQHU472HDOCk25/yBjY+VjUmbd03zQcU0BEyL0iWUpNgRQI/JaEek ZuhjCJJsZsSSZkOqTrgc7HAJHMYMHzFmFIGfOaLWc8nevwsMn3tMm3XGfmHwIlEtUrMF9 PbzghVKXFKWtbJilcy04gCDqOv3jLrM4eeYGjxNwdTwLoqz9aC1X+4aCdQijQa2o1AMIl s+9dwKRMUqp4fV2FXADE++L1qYPUO+uwrHR8GgLBVEUN+6oUmAnBXQwlY8MyNE4KG4DDp 2tIB87Z/9KmLldGTo7JIULlKYRHgehJSQf1DNuE2r7uFWlGZ2iwcOUxd39pBcwf07ng== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gxgRo1RS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2383606A893 for ; Fri, 13 Nov 2026 17:03:07 +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=gxgRo1RS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 960901F000C4; Fri, 13 Nov 2026 17:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794589387; bh=b1iBR06mysXuO9oyeYat1Y60ZRUTWo8aGvB3eQgMSoA=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=gxgRo1RSHOc9qKClV3C26LtiU6p9kJ/ozWFc2K79GFXHw+V2zqI8muvqqPuT4rTGb BUE9WsN9VTM1kBKFeWkGNHnimcaZMkVYoq/DW3cbrQSCB2M2NdK2RJ/d3t4+hu4WXM WXpLNE0S3SYsXfJPnIH4GsjXlK0DEshXuvHyAM6VzNlhTsxLBSL5Jo6JBZxBpjsZIX zFYwbUqm6nnXo+AW9MkjpY+zf6p4JSo4FoURUI++QVNVql9g9hYlQcbwrhS9ymsd9h 8u2FsT3d2Q2ZRsjr08T5ai3DkOY6FqfMIa5FUHfIvmXG06XsEKYJdJIccJidjFEDkx 4lAwW/x6Qcm3Q== Message-ID: <13c40a66-4ce9-4d9a-801b-a3debfecee22@kernel.org> Date: Fri, 13 Nov 2026 18:03:00 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/3] mm: page_alloc: add a watermark check that knows the migratetype Content-Language: en-US To: Kiryl Shutsemau , Harry Yoo Cc: Andrew Morton , 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 References: <20261102093939.3340540-1-kas@kernel.org> <20261102093939.3340540-2-kas@kernel.org> From: "Vlastimil Babka (SUSE)" Autocrypt: addr=vbabka@kernel.org; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuwsIZ8OPJCc LM4S7mT25NE5kUTG/TKQCk922vRdGVMoLA7dIQrgXnRXtyT61sg8PG4wcfOnuWf8577aXP1x 6mzw3/jh3F+oSBHb/GcLC7mvWreJifUL2gEdssGfXhGWBo6zLS3qhgtwjay0Jl+kza1lo+Cv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FmBRKAa6wos25moTlMKpCWzTH84+WO5+ziCTsTUZASAToz3RdunTD+vQcHj0GqNTPAHK63sf bAB2I0BslZkXkY1RLb/YhuA6E7JyEd2pilZOrIuBGl/5q2qSakgnAVFWFBR/DO27JuAksYnq +aH8vI0xGvwn75KqSk4UzAkDzWSmO4ZHuahKtQgZNsMYV+PGayRBX9b9zbldzopoLBdqHc4n jQARAQABwsF8BBgBCgAmAhsMFiEEqUDUNJksLo6ZED1QIk+n58yCpmQFAmfIHFQFCRYU6J8A CgkQIk+n58yCpmS2PA//bqN1LfcotmArgElsa+0EGZSQlYgK48pm8WAeTXTngudP9IJ4SuKY HR5RNjHcBeqN+Me0zxRqYzRb8nGanHEkDyf4Im8DQM8d6vbyU+FcPmG4skud4kgS1zMHnlVd SXfSIwKC/hKgdHG8aBV7545Lz9X6Iohea+94wneD0aw/hqF+QWewGZhWJriWAZtvEkzNjQOi 4U9F/trLten/x7bpphDSnDMKJtITbtzATT1Dq7o7VpIUK1nCTQALMuMjKCdi8OdU/+V+R3O4 0PXWvX8qrvqYapVbZ+9KqT74FsuB0Ya9uXwgBF2Q6cRuETZk5vqaqKxzqoQZCO8AOz/58j6O 2RHNy/mZEN+7tJ5Tsq42zVJ4jxsT8b9YplavCMsnBgDeRWhcbYhCyttoL7nYISyWg4kQYZ/P wIV3OuNv2f8iKYsxNsRuClOAF82+gvqOy1/1pprFjy8uo2pkoOrb63aOP3vO5VHnRKgra6dq NcaZ+c6J4H+nEJGi2SkHAUJz5oBzuThvPudLvPA/SK8sKoM01IRxSihev/S/5WLazXB1PGem OCbvzC1IjWJJraxiDJ5IygokapUa2RP7+WBR22skQ3SSl6G107QgWKSyTOGWEaRmV53vxQLV jXuCmzSSasTL60zq5yGrT4/DYQVSNEUiUbG4pYekxJujNeEDkUlky0Y= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/11/26 20:49, Kiryl Shutsemau wrote: > 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. Please try actually reading this sentence, does it make any sense? It instantly reminded me of the meme classic: "Has anyone really been far even as decided to use even go want to do look more like?" > 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. Oh yeah always this damned style again. What did they train the models on? > 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? Not really :(