From nobody Thu Apr 2 17:22:44 2026 Received: from mail.ilvokhin.com (mail.ilvokhin.com [178.62.254.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01F8E347539 for ; Fri, 27 Mar 2026 16:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.62.254.231 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774628115; cv=none; b=czOsUV3yOGn+6uhywKys8depdD1io9gnUGRMI1hV/i8diSBvrlazQAk2LoG4wPAtJeFTOI6eEWGNb8Kca4JqMZsnaB9dMicwyP7PAFUZi0Ed3ofi20B3ih+pLcouXMwNNuHpUXMKbZ5fcFvVq87YP+Ds+amteWrhtBO6KWajxZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774628115; c=relaxed/simple; bh=qDB3n0DefqZEXOgPxw5xItDz7y0w16+JoVG+Y6kvh1M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GEm7BUu6iDqM9NvNq1WsOhFuQnd554waK0Cn6Ngm9hG9a+MnW+bdcJdFJ6LFrn+ARTKHjBUA0ZHHRKLhi4XM3febZYuJS7KLs/wwwGhnN6cB505fu9CWykg2NvVlR16R4omQd625ApBKMKubcFFXGzwOVRofwn+sYqD/L8UpNUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ilvokhin.com; spf=pass smtp.mailfrom=ilvokhin.com; dkim=pass (1024-bit key) header.d=ilvokhin.com header.i=@ilvokhin.com header.b=emO7SczW; arc=none smtp.client-ip=178.62.254.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ilvokhin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ilvokhin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ilvokhin.com header.i=@ilvokhin.com header.b="emO7SczW" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id A93BBBDFFC; Fri, 27 Mar 2026 16:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1774628106; bh=3LpytnOc5QnLYuuG5kgtGtzHAwZXxVYcBS5MJBOR4yE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=emO7SczW8t/0nVeRik7ewArnH8FGmtAuYwyu6Nq69WiY29mHcbRKWx1iBuBmwEnEv uRZTERD4v1Vr89VdVX4yzVQ47pXOK3NDR5VbpbCG2bJ+kgY0hW8EnmlndY3iH8p6Mv pNrDcraxnpxxrLoUDfdp0QkwJNIavds/QsR/jx4I= From: Dmitry Ilvokhin To: Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Dmitry Ilvokhin , Steven Rostedt Subject: [PATCH v2 4/8] mm: use zone lock guard in set_migratetype_isolate() Date: Fri, 27 Mar 2026 16:14:44 +0000 Message-ID: <80377691336ce978dbfcac17ebaa6de9837a0b8f.1774627568.git.d@ilvokhin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use spinlock_irqsave scoped lock guard in set_migratetype_isolate() to replace the explicit lock/unlock pattern with automatic scope-based cleanup. The scoped variant is used to keep dump_page() outside the locked section to avoid a lockdep splat. Suggested-by: Steven Rostedt Signed-off-by: Dmitry Ilvokhin --- mm/page_isolation.c | 60 ++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/mm/page_isolation.c b/mm/page_isolation.c index 9d606052dd80..7a9d631945a3 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -167,48 +167,40 @@ static int set_migratetype_isolate(struct page *page,= enum pb_isolate_mode mode, { struct zone *zone =3D page_zone(page); struct page *unmovable; - unsigned long flags; unsigned long check_unmovable_start, check_unmovable_end; =20 if (PageUnaccepted(page)) accept_page(page); =20 - spin_lock_irqsave(&zone->lock, flags); - - /* - * We assume the caller intended to SET migrate type to isolate. - * If it is already set, then someone else must have raced and - * set it before us. - */ - if (is_migrate_isolate_page(page)) { - spin_unlock_irqrestore(&zone->lock, flags); - return -EBUSY; - } - - /* - * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself. - * We just check MOVABLE pages. - * - * Pass the intersection of [start_pfn, end_pfn) and the page's pageblock - * to avoid redundant checks. - */ - check_unmovable_start =3D max(page_to_pfn(page), start_pfn); - check_unmovable_end =3D min(pageblock_end_pfn(page_to_pfn(page)), - end_pfn); - - unmovable =3D has_unmovable_pages(check_unmovable_start, check_unmovable_= end, - mode); - if (!unmovable) { - if (!pageblock_isolate_and_move_free_pages(zone, page)) { - spin_unlock_irqrestore(&zone->lock, flags); + scoped_guard(spinlock_irqsave, &zone->lock) { + /* + * We assume the caller intended to SET migrate type to + * isolate. If it is already set, then someone else must have + * raced and set it before us. + */ + if (is_migrate_isolate_page(page)) return -EBUSY; + + /* + * FIXME: Now, memory hotplug doesn't call shrink_slab() by + * itself. We just check MOVABLE pages. + * + * Pass the intersection of [start_pfn, end_pfn) and the page's + * pageblock to avoid redundant checks. + */ + check_unmovable_start =3D max(page_to_pfn(page), start_pfn); + check_unmovable_end =3D min(pageblock_end_pfn(page_to_pfn(page)), + end_pfn); + + unmovable =3D has_unmovable_pages(check_unmovable_start, + check_unmovable_end, mode); + if (!unmovable) { + if (!pageblock_isolate_and_move_free_pages(zone, page)) + return -EBUSY; + zone->nr_isolate_pageblock++; + return 0; } - zone->nr_isolate_pageblock++; - spin_unlock_irqrestore(&zone->lock, flags); - return 0; } - - spin_unlock_irqrestore(&zone->lock, flags); if (mode =3D=3D PB_ISOLATE_MODE_MEM_OFFLINE) { /* * printk() with zone->lock held will likely trigger a --=20 2.52.0