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 5ADB0606A322 for ; Fri, 4 Dec 2026 22:33:03 +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=GM+2tfMB Received: by kanga.kvack.org (Postfix) id C8C0B6B00EF; Fri, 4 Dec 2026 17:33:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3C746B05B1; Fri, 4 Dec 2026 17:33:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2BCF6B05B2; Fri, 4 Dec 2026 17:33:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 753916B00EF for ; Fri, 4 Dec 2026 17:33:01 -0500 (EST) Received: from smtpin06.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DE0A0C0635 for ; Fri, 4 Dec 2026 22:33:00 +0000 (UTC) X-FDA: 85507752120.06.6589A34 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf06.hostedemail.com (Postfix) with ESMTP id D67C8180005 for ; Fri, 4 Dec 2026 22:32:58 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=GM+2tfMB; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of kas@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=kas@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796423579; b=TGONWIEib6T/N5Joi+ZQUyXQA+Qw9pOqY+XdXjOZw8GvmyndTsJm5xDwPaRXdOYEDgHMyT TA4FI6QPxNjle6zcuFbT8JSH8ER2rowayoLaYjZMpsOAfshAu2MveKUB3LMv24GzEgD32w uzZ8PPXdCmDvaEIbKOi/0R1AYWb21R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796423579; 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=hNXX+t8ZjgCpMLydP0ReUeF3zJaMX9LsosKIKksjXHI=; b=iJLv1V8EEvrTUJWpiijf5sXRHSty9KXGl2JA2slUzg5xXP7VRcV4GPNGocc3ld0b73y60c bvF98YZTuSeYHcayJS/B+C6ScqnmMkEvEgK432rDjdnsQf7KWueXR4cGTZDALHEg3t2HZE 5oO9bjgFOUYFP16Zac55g3G5KRKlq+k= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=GM+2tfMB; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of kas@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=kas@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 285B0600F4; Fri, 4 Dec 2026 22:32:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D88F1F00936; Fri, 4 Dec 2026 22:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796423577; bh=hNXX+t8ZjgCpMLydP0ReUeF3zJaMX9LsosKIKksjXHI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=GM+2tfMBsoNDFkfhd1vN/vByCyENvqjNh/G4cBRQR3mt9E1b+p4jBTSFtJjUHzxAm a2ZhBiNm7f80hqv0St8dcVB9gRSwPva4UNOMXlPp/QbLvb5UofBoMrr8nrDutq3esR J6mjd34WiZAVwAncNJhdut6jcGAywdgRUW+JiIdhX74i1xzo+mJXsE3Aqew5hwKUY3 PDPalqePbWbEbQK6l497XsOdv/DrXsDX7yPROuEcP8DiPWsqgcL1n5Ec9mZSpd2PxC qQkYqnMgq+n/+4umCYXQNRrSo9S7y3NHMh8xDRP+Ilup5R8gPfS8A16rd1kv+KwaAf Bo7Zs9f2ldK1g== Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfauth.ams.internal (Postfix) with ESMTP id E8A1C198003A; Fri, 4 Dec 2026 17:32:53 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Fri, 04 Dec 2026 17:32:55 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFiwoWfu2Y0rVF0VcxIHK2Qe32WNCMSeKGAVB0pQyWW8A5HoO8Rz3no/uZdUdmQbL bqMRZNkDpKkeumxXGcK/oIcCa1yU/BNu0Oa3XOO/8nYu/k5f4Kwc9TAC/Zo6cVA6FEFgtd uerWs6j22Wk4tevEKMsr1dM1vnCKDCNVC7PHszw1oNCopWdfWjxNqlAJTfIdiB1ArpzXY1 N9RCsUni1idVSJqFSLEKs7Y2jokSEALlVujaJ2i2WWDYvztqgbF+QOFcsJ3czhEmMdWjlN qkqrQGH7KMnL/clrZivbZC4k0GMQTjPKoi4oqhAkvfa0rx04Tjc2uUl40t7QIZ6CEzAjTZ PYJjJMY7Xg8UG/KovVGDDIMwKPpNQhfj8huiCo7jHopMYwzaAGZdkdqmNQotBgDEtG732P XcvGIm6fPurn/OAA/l9qmlWmdRHOzzPwI79rKAc4nV2Ld5E9mmZC2OyOs9UhTjpI/W/9xh fuVGaQ9mWDfIko6l3gtNbkx8HpHHRUuTaJadVEFozczCkCnn+3/tvC4lS/1gzFBUyFWTHJ s25ziNv4YzwJ62q5tiUi19SzUwMLLy/duHi1ZsD+auTS3mLW4qslkS2XzwuKbbBxnpX57J Il26q00FiebMftJpeP+15Cs2VT0gbp3y0eL8rM+UTfrxPgh7okP/zKEuuU9Q X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Dec 2026 17:32:52 -0500 (EST) Date: Fri, 4 Dec 2026 14:32:51 -0800 From: "Kiryl Shutsemau (Meta)" To: Dev Jain , Rik van Riel Cc: Zi Yan , "Vlastimil Babka (SUSE)" , Qi Wu , Johannes Weiner , Andrew Morton , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Mel Gorman , linux-mm@kvack.org Subject: Re: [PATCH] mm: page_alloc: do not capture HIGHATOMIC pages Message-ID: References: <20261129142350.123923-1-shijing.wuqi@linux.alibaba.com> <2ec15e68-5993-4186-bf0a-198a5630cfe9@arm.com> <3eec3d9b-bea3-4deb-ad2d-7ece5b85cf4f@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam02 X-Rspam-User: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Stat-Signature: s7rph87hwt3q6juhstsdgdacytruz9ph X-Rspamd-Queue-Id: D67C8180005 X-HE-Tag: 1796423578-415234 X-HE-Meta: U2FsdGVkX1/OyRsm+OCSlVEseXwRMmhWIuoaedv8PWZFDxwcAq2BsuWf+foyXhnBhf4nUK8RFOx/NuOeyWj0vUPEqxXFeXRyxnl0Bx8uBd0iABPoV0gDtd6p9eIDp30L5tP20v14TUIfYc7DecXgOC8jqOkz+Sp7kqg+NDHHLFopN6//sHU6l1f3m2mYRsqE/Eg2EKo/vkEaSXAjGuCvMnItX8LzMGr1Fs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jw4Bq0/meTB4tewRtful9y2jN6ZS9WifyhmEKNO1GzsNMMsu9tkArkcehJ8DCUQeC1egTmZh4mD/I/Kv8bu213C7tFepK+P9k6CVGAY8O7JGW5UN0+SWai3EMPO9T6rTH6gFOst6cPt2OQh7/PPQJCiipbKY4zwZub1yD932/opzn3OmNcsPOHzrYhfBCEQggamaqW4nZLyyqR080IVQMMWK8FSkAoOlZEDhCBi/I96i4M3gXGATTc+Jq0yKfsGfv8eFhG22xWlvEGmUHaLRYruPbt99VzAf2zG59+27Y4kyPNG/OiPTx/tl2oZHP8pUVPfFY2usoTDlRYw== 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 Fri, Dec 04, 2026 at 10:31:49AM +0530, Dev Jain wrote: > Looks good at cursory glance. You may want to audit all cases, for example, > perhaps we hand out a page which was not supposed to be handed out due to > watermark restrictions etc. Essentially, if capc->page == NULL but compaction > was indeed able to create the free space, we need to consider the cases where > get_page_from_freelist() would definitely fail to get that page due to "restrictions". I went through get_page_from_freelist(). With Qi's patch and mine, capture does not hand out a page the freelists would refuse. Watermarks seem to be fine: the captured page was just freed by compaction, and the page compaction consumes is the migration target, which __isolate_free_page() takes only above min. compaction_suitable() already checked the request's watermark and lowmem reserve before compaction started. try_to_compact_pages() applies the same cpuset check as the freelists. The difference is the pageblock type. When the freelists give a whole block to another migratetype, try_to_claim_block() converts it; capture does not. Harmless if the allocation is freed whole, but a partial free puts pages on the old type's freelist: a THP captures a whole unmovable block, a partial munmap() splits it, and unmovable allocations fill the freed pages next to the remaining movable ones. Rik, your RFC [1] converts only a movable block taken by a non-movable request. The diff below converts in every direction. It needs Qi's patch, or it would convert a highatomic block. The compaction_capture() fixes could go as one series: 1. Qi's patch, as posted; 2. the ALLOC_NOFRAGMENT check from my previous mail; 3. move change_pageblock_range() up, no functional change; 4. convert a whole captured block. The diff below is 3 and 4. Rik, are you OK with 4 replacing your 5/5? Vlastimil, Dev, if it looks good I can submit it. Or Qi's patch can go in on its own, ahead of the rest. [1] https://lore.kernel.org/all/20261007021250.1665929-6-riel@surriel.com/ diff --git a/mm/page_alloc.c b/mm/page_alloc.c --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -545,6 +545,17 @@ static void set_pageblock_migratetype(struct page *page, PAGEBLOCK_MIGRATETYPE_MASK | PAGEBLOCK_ISO_MASK); } +static void change_pageblock_range(struct page *pageblock_page, + int start_order, int migratetype) +{ + int nr_pageblocks = 1 << (start_order - pageblock_order); + + while (nr_pageblocks--) { + set_pageblock_migratetype(pageblock_page, migratetype); + pageblock_page += pageblock_nr_pages; + } +} + void __meminit init_pageblock_migratetype(struct page *page, enum migratetype migratetype, bool isolate) @@ -759,6 +770,14 @@ compaction_capture(struct capture_control *capc, struct page *page, trace_mm_page_alloc_extfrag(page, capc->order, order, capc->migratetype, migratetype); + /* + * The freelists convert a whole block they hand to another + * migratetype, see try_to_claim_block(). Do the same, so that + * pages freed from it later go to the right freelist. + */ + if (order >= pageblock_order && migratetype != capc->migratetype) + change_pageblock_range(page, order, capc->migratetype); + capc->page = page; return true; } @@ -906,17 +925,6 @@ buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn, NULL) != NULL; } -static void change_pageblock_range(struct page *pageblock_page, - int start_order, int migratetype) -{ - int nr_pageblocks = 1 << (start_order - pageblock_order); - - while (nr_pageblocks--) { - set_pageblock_migratetype(pageblock_page, migratetype); - pageblock_page += pageblock_nr_pages; - } -} - /* * Freeing function for a buddy system allocator. * -- Kiryl Shutsemau / Kirill A. Shutemov