From nobody Thu Apr 9 17:58:38 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 3DBFB3ECBED for ; Fri, 6 Mar 2026 16:06:27 +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=1772813189; cv=none; b=seqWrwOBZSO4h79vnfTYGIaLMSZhGU4A6tih5zE2W4s1/w2A1odvDXkIr1PNKPxFINdAVMBo2EaNpdyvrB97J+Gfs2fuP6c0kpwxwrna672K2ZlZ1tsNDUU11ctTGb3mwAAyWGNcNLFOh8LQoUi512tDZdUVsy4ErDjvqOs0PTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772813189; c=relaxed/simple; bh=wN17P6L+Gg/xFfEbbdEyEn6r8U5yWu3eeJhCp0iQv0Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nOp0Uy+xmZiw/XTPtbvRDRle2CWJedNtj+UzgUSZfWZK/uwbmWEH/7PRtO/3ZUn0GzgmruOhqd6Y75yMCZwtXT90DNarxjG+ZvHb/r/jEYdpZxQ1pcq674BDgxPqQAAUk/gsBAHOErQ2FQ9QEe8jRl1ec4ixCSWWUVI4T5SjgOk= 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=tGHmLqWR; 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="tGHmLqWR" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 450D5B3446; Fri, 06 Mar 2026 16:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1772813185; bh=5lC/RKPmOVVI62+gZKGXoWGLnTSSGp29jP+MVgzYIVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tGHmLqWRQRsEr6+QfNuAGGqpAmvSYNip2Au34RkMFR+m1MpWBBoeg9gW0iEwgnz2/ Qt/z/g7xtmJrvMGmRlJfc8cal+HyIPma5Pd8YLIO38E/kL6/CXIUytTwfi07Hq0SuY 5iKnrm+12E4wMSzt3LLLjuTstIVsbimTbd5oMe7Y= From: Dmitry Ilvokhin To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , 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 4/8] mm: use zone lock guard in set_migratetype_isolate() Date: Fri, 6 Mar 2026 16:05:38 +0000 Message-ID: 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 zone_lock_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 dc1e18124228..e7f006e8870c 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -168,48 +168,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 - zone_lock_irqsave(zone, 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)) { - zone_unlock_irqrestore(zone, 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)) { - zone_unlock_irqrestore(zone, flags); + scoped_guard(zone_lock_irqsave, zone) { + /* + * 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++; - zone_unlock_irqrestore(zone, flags); - return 0; } - - zone_unlock_irqrestore(zone, flags); if (mode =3D=3D PB_ISOLATE_MODE_MEM_OFFLINE) { /* * printk() with zone lock held will likely trigger a --=20 2.47.3