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=1796388562; b=bOPhtgEIEGf6JVyn2vwZ9T+yqhgdo8KjDOMP2A+XhjCMpCB2C2xOLp8broswYY/HKB1D L73z0B6OXKUdFGunt0O/eskhruNWRxDHSd3AjbSFoaFd6hNb0LfHk15L2QOUCVHazJYgK e8FM/9k+D23+iWVATgoKJ5CNBfUX2JgntFouPSEZZY9dmG+1aSq3JeqzFslGtsXAakM8M Ia0Cz51Xz6yUl4RklmUXff8wYnfdJAanPmb8rnnbZxVTobV1menbb0303pe78Q5aaulus /dgBnvSOgz0M4axGlt+2dpF8OR8ESrb2OG/676TLckYyJCCHwiJKtq2Q1nw7HXM5N3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388562; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=u9zDHIiC1ScEUDNcmXISiA0F8yo7KR5CcyUP14jsrws=; b=kdPcSf3JR9E700hXFRduc2tplNhfg2vecTf3LPCks7SICx9rXN/H65kcTeIz6tAXISkW +fI/cA5gUovqv4ITka55t2E0NM1QydSJ0BY23c7l2sDb5QoWQ8L1+Eq+VZNZOrdSHTLSo eAVICPfsvDqHGKMCfPu+7QhpPKlD9ZUQuSGcdRRDuaOF5Qq5Hp8eguQ5gGB2VtwM+Wysi 3n2TWHPY06KTCfXYLvMY6v8dYu5QvILzGBvzo6jiOZq+I+7pFAQBHdsGktJDcN+TqoY8j dJo+yxUkMVt3Y9oUZprWK/3h5xcYZBcopOilEpocmcpTTGVtqOYs91hHKUoNXxnBW6Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=DkVYuqdB; 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 3DACC606A322; Fri, 4 Dec 2026 12:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=DkVYuqdB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DEA91F000C2; Fri, 4 Dec 2026 12:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388562; bh=u9zDHIiC1ScEUDNcmXISiA0F8yo7KR5CcyUP14jsrws=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DkVYuqdBTPiMJxj0TXNvINwtrzJ7sFU3winqxl9SxwkNc7wOMyPLLvpHzf81w4usf XONo9UUpfrwxcmMMz27GwGj+jeNkq/1G6C0zK9roVwsfldYLhjGz63IEIjdS4Fu0xt r3aaxmMs/QH9gtpRYNnzAtX5q/leA4j51d9+5wPI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Gregory Price (Meta)" , Zi Yan , "Vlastimil Babka (SUSE)" , Sasha Levin Subject: [PATCH 6.1 0664/1059] mm/page_alloc: dont undo another isolation in alloc_contig_range Date: Fri, 4 Dec 2026 19:03:15 +0900 Message-ID: <20261204100701.235217086@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gregory Price (Meta) [ Upstream commit 7d9c29ed8feec8bfbe5e5f673ba2b5926da11375 ] An alloc_contig_range() that overlaps a block going offline can leave the offline spinning until it gets a signal, holding the device hotplug lock. When isolation fails, alloc_contig_frozen_range() undoes it over the whole range, clearing the offline's MIGRATE_ISOLATE too: CPU 1 (offline_pages) CPU 2 (alloc_contig_range) start_isolate_page_range() blocks are MIGRATE_ISOLATE start_isolate_page_range() -EBUSY on CPU 1's blocks undo_isolate_page_range() blocks are MIGRATE_MOVABLE test_pages_isolated() never succeeds again start_isolate_page_range() fails only on a block someone else isolated, after undoing its own, so this undo only ever clears another caller's. Return directly, as before alloc_contig_range() went pageblock granular. With offline_pages() parked after isolating a DIMM block and a 1G hugetlb allocation made over it, the offline on base still loops 30s later in 4 of 4 runs: offline_pages+0x5b2/0x1570 memory_subsys_offline+0x17e/0x470 device_offline+0x250/0x340 state_store+0x88/0x110 With this patch the allocation still fails, and the offline completes in 3 of 3 runs. Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity") Cc: stable@vger.kernel.org Signed-off-by: Gregory Price (Meta) Link: https://patch.msgid.link/20261027042204.3741307-5-gourry@gourry.net Reviewed-by: Zi Yan Signed-off-by: Vlastimil Babka (SUSE) [ sashal: Adapted the change to alloc_contig_range(), where start_isolate_page_range() takes migratetype, 0, and gfp_mask instead of mode. ] Signed-off-by: Sasha Levin --- mm/page_alloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 44a22f7f213da..96dbf055ae99f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -9358,9 +9358,13 @@ int alloc_contig_range(unsigned long start, unsigned long end, * put back to page allocator so that buddy can use them. */ + /* + * On failure this has undone its own isolation, and any other + * isolated blocks in the range belong to someone else, e.g. offline. + */ ret = start_isolate_page_range(start, end, migratetype, 0, gfp_mask); if (ret) - goto done; + return ret; drain_all_pages(cc.zone); -- 2.53.0