From nobody Thu Apr 9 17:57:53 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 54BE530F532 for ; Fri, 6 Mar 2026 16:06:26 +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=1772813188; cv=none; b=cuHqzmnGsE99QCqL4xx+iJu9lrwhwyvJjPxmQh4CX2ZBU91K0yL2TCCr2EhI5VfX9sgcPQrB77nmq5S4ARUrDbPRWX7VUY7SVlW090FbB/kvxwGAZR5cC86mnWD+ERv8CMp30GU/+g3uRl9uQSH8G+KEp1iTZV2C0udgdLCuJks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772813188; c=relaxed/simple; bh=Zqk1gQ7Atvw6gjTVGJNTQAhvcX3Jy8TQqjpE9dC/ZuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i7b6asBMkvreSTRTd8MZvbiHCfocVV/YITfsWUmAkNTsuIf5SQnuewdY3fdCjXuHZrW92P04mTdprVHp8+VwQmiNEl2y9o0zJR9QUXhO+FhcZA+RLZdd2vqNQtx7iUr2DOs7h6J6ZQmmIPfhDq7bT2aBszdjD8ruwG1cHhiE0EM= 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=kIsu87qC; 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="kIsu87qC" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 6D4DEB343A; Fri, 06 Mar 2026 16:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1772813184; bh=i9UEkKMHpo5tNbaHzJ6bf5dC7adclkzJ3ytPit9GXIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kIsu87qCkpQM60NfUwX2uTA3cZQ1SRKOjnU7PGWuT3Y76LtaFmxUaE7TF2LuaKa5D KbUgRhD1q2TZaVN+7l9IoZ/e+/Sr6qnyw3f3LksEdr7coxXDaIgC9R/8tAlzG+dRZa s7jxzba4KWLI5P8orJ4WEY5O4kaS/BUNk8YKyCSY= 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 1/8] mm: use zone lock guard in reserve_highatomic_pageblock() Date: Fri, 6 Mar 2026 16:05:35 +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 the newly introduced zone_lock_irqsave lock guard in reserve_highatomic_pageblock() to replace the explicit lock/unlock and goto out_unlock pattern with automatic scope-based cleanup. Suggested-by: Steven Rostedt Signed-off-by: Dmitry Ilvokhin Reviewed-by: Steven Rostedt (Google) --- include/linux/mmzone_lock.h | 9 +++++++++ mm/page_alloc.c | 13 +++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/linux/mmzone_lock.h b/include/linux/mmzone_lock.h index 6bd8b026029f..fe399a4505ba 100644 --- a/include/linux/mmzone_lock.h +++ b/include/linux/mmzone_lock.h @@ -97,4 +97,13 @@ static inline void zone_unlock_irq(struct zone *zone) spin_unlock_irq(&zone->_lock); } =20 +DEFINE_LOCK_GUARD_1(zone_lock_irqsave, struct zone, + zone_lock_irqsave(_T->lock, _T->flags), + zone_unlock_irqrestore(_T->lock, _T->flags), + unsigned long flags) +DECLARE_LOCK_GUARD_1_ATTRS(zone_lock_irqsave, + __acquires(_T), __releases(*(struct zone **)_T)) +#define class_zone_lock_irqsave_constructor(_T) \ + WITH_LOCK_GUARD_1_ATTRS(zone_lock_irqsave, _T) + #endif /* _LINUX_MMZONE_LOCK_H */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 75ee81445640..260fb003822a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3407,7 +3407,7 @@ static void reserve_highatomic_pageblock(struct page = *page, int order, struct zone *zone) { int mt; - unsigned long max_managed, flags; + unsigned long max_managed; =20 /* * The number reserved as: minimum is 1 pageblock, maximum is @@ -3421,29 +3421,26 @@ static void reserve_highatomic_pageblock(struct pag= e *page, int order, if (zone->nr_reserved_highatomic >=3D max_managed) return; =20 - zone_lock_irqsave(zone, flags); + guard(zone_lock_irqsave)(zone); =20 /* Recheck the nr_reserved_highatomic limit under the lock */ if (zone->nr_reserved_highatomic >=3D max_managed) - goto out_unlock; + return; =20 /* Yoink! */ mt =3D get_pageblock_migratetype(page); /* Only reserve normal pageblocks (i.e., they can merge with others) */ if (!migratetype_is_mergeable(mt)) - goto out_unlock; + return; =20 if (order < pageblock_order) { if (move_freepages_block(zone, page, mt, MIGRATE_HIGHATOMIC) =3D=3D -1) - goto out_unlock; + return; zone->nr_reserved_highatomic +=3D pageblock_nr_pages; } else { change_pageblock_range(page, order, MIGRATE_HIGHATOMIC); zone->nr_reserved_highatomic +=3D 1 << order; } - -out_unlock: - zone_unlock_irqrestore(zone, flags); } =20 /* --=20 2.47.3 From nobody Thu Apr 9 17:57:53 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 8CD3D3E8C6C for ; Fri, 6 Mar 2026 16:06:26 +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=1772813188; cv=none; b=Wj96PnyntoC9LPgsvzonxPlBg6XfoosK8VHgcivg1kVEzxtyDBOdxpqOlP/xV2oZJndBkg2KoBtBgaOCiMkahVCQKIBgc4RBlsunhiajr8clnbzWwVrS8rO8maQsNkWPOD6VwdlHnb1q3PrpTL3tJF4/VZi2RcDLpPvy89phbKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772813188; c=relaxed/simple; bh=oDXQFELYtTTSZtjXt2IVARr4zqwQK1N33MMTWi17kd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LtKcijXFRuf2PSWWg9YgaAWvqi7jwjnYYQqZ4nBiFPi5AHKacB0hN1k5TkKni8SpO6arzv20zWsleakfOZrC1Fn1php/iYfkhsoP7ZOGU+tSggl5nadYMQbnwiG09bc+m5agUTfskFPz+tYMA271reQcTPGpgA4Dweoqj40ytgg= 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=BpySMpVw; 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="BpySMpVw" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id B32F9B343E; Fri, 06 Mar 2026 16:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1772813184; bh=5MNMr1IHoVTzBoiG5P1ta/i/aMAz7SlmBpjrvkTxTqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BpySMpVwFeY9+TCd+MZC+3/XwNvGqnwn/V5SiPGg2iQQblqmuGnAxUuZexkBhPlEr uLZEY8pqaLVhfws1wtEkeCwPaX8//6ZwcG+jtHxUBtTwE6MTnvcC5YVRrfxhUC+/1D dsKMpl7qUm/I5MJOwJ6KIMNtFSs8x+KgpdBLO5kg= 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 2/8] mm: use zone lock guard in unset_migratetype_isolate() Date: Fri, 6 Mar 2026 16:05:36 +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 lock guard in unset_migratetype_isolate() to replace the explicit lock/unlock and goto pattern with automatic scope-based cleanup. Suggested-by: Steven Rostedt Signed-off-by: Dmitry Ilvokhin Reviewed-by: Steven Rostedt (Google) --- mm/page_isolation.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/page_isolation.c b/mm/page_isolation.c index e8414e9a718a..dc1e18124228 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -224,15 +224,14 @@ static int set_migratetype_isolate(struct page *page,= enum pb_isolate_mode mode, static void unset_migratetype_isolate(struct page *page) { struct zone *zone; - unsigned long flags; bool isolated_page =3D false; unsigned int order; struct page *buddy; =20 zone =3D page_zone(page); - zone_lock_irqsave(zone, flags); + guard(zone_lock_irqsave)(zone); if (!is_migrate_isolate_page(page)) - goto out; + return; =20 /* * Because freepage with more than pageblock_order on isolated @@ -280,8 +279,6 @@ static void unset_migratetype_isolate(struct page *page) __putback_isolated_page(page, order, get_pageblock_migratetype(page)); } zone->nr_isolate_pageblock--; -out: - zone_unlock_irqrestore(zone, flags); } =20 static inline struct page * --=20 2.47.3 From nobody Thu Apr 9 17:57:53 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 DD93D3E95B0 for ; Fri, 6 Mar 2026 16:06:26 +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=GIakBaStvdbxpFi9LirSshbR5dYXGIPaYiYq+gIVpRHJO/RTCXXt4ZqMfqTnZ6h/YvXWwoH+IHJAkFJCqirjQ6Ln7HAyD5/qdqQarEtihQtUFbBvNXkpHRZ3qrO5O7eW+Neg2+YnOIfFBu4t/naunXfLqqt07cdRLfdR7YMogfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772813189; c=relaxed/simple; bh=QMtdn+L9pd4/KB2h1GrkWpa6okvj0X3jqHDIh+iGlSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ey1/UFWNit5lZMyFB4S/YMg0oAWp8dds5jWZfo6KwN2YqpkuSWMJnN2SDTTYh49OMQ/i5tHF2Op4brZjaeOlgkH1gNk/kxip06sY+nxu/gm/QJQcwQz+lSseRHbhAhPuHH0goWxnWb2HRz+Gden3TGEs8LRjJB0cSQXtbP8hHeY= 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=um+dgqwq; 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="um+dgqwq" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 01E31B3441; Fri, 06 Mar 2026 16:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1772813185; bh=xmQ9hgnSXzc8ICiALHSxS12/8YYk8LAoyAkwViY9f/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=um+dgqwqwu+LOmxoH8jJjbUK5QsR6oD/Q8owfus/MFUmLPoQvDHx10/773Tr+Ir7Z newCPiFftX7QukoybePCW3/XhauRad935KKymZgcdNSeqoYULRIJYBblBOQUcxg2G3 2vQJgyXcKoAGEqwuAp7EYootQejw9kF1m4nPQRvk= 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 3/8] mm: use zone lock guard in unreserve_highatomic_pageblock() Date: Fri, 6 Mar 2026 16:05:37 +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 lock guard in unreserve_highatomic_pageblock() to replace the explicit lock/unlock pattern with automatic scope-based cleanup. Suggested-by: Steven Rostedt Signed-off-by: Dmitry Ilvokhin Reviewed-by: Steven Rostedt (Google) --- mm/page_alloc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 260fb003822a..2857daf6ebfd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3456,7 +3456,6 @@ static bool unreserve_highatomic_pageblock(const stru= ct alloc_context *ac, bool force) { struct zonelist *zonelist =3D ac->zonelist; - unsigned long flags; struct zoneref *z; struct zone *zone; struct page *page; @@ -3473,7 +3472,7 @@ static bool unreserve_highatomic_pageblock(const stru= ct alloc_context *ac, pageblock_nr_pages) continue; =20 - zone_lock_irqsave(zone, flags); + guard(zone_lock_irqsave)(zone); for (order =3D 0; order < NR_PAGE_ORDERS; order++) { struct free_area *area =3D &(zone->free_area[order]); unsigned long size; @@ -3521,11 +3520,9 @@ static bool unreserve_highatomic_pageblock(const str= uct alloc_context *ac, */ WARN_ON_ONCE(ret =3D=3D -1); if (ret > 0) { - zone_unlock_irqrestore(zone, flags); return ret; } } - zone_unlock_irqrestore(zone, flags); } =20 return false; --=20 2.47.3 From nobody Thu Apr 9 17:57:53 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 Reviewed-by: Steven Rostedt (Google) --- 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 From nobody Thu Apr 9 17:57:53 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 84A963ECBF8 for ; Fri, 6 Mar 2026 16:06:29 +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=1772813191; cv=none; b=mEryilcP2JbLjQqoZgj/Py/n+eC7OKBxLRIg3j07SXV4smB2Q6UquWpCk7advyvxHXVMitKLRlbfXX+7istLZIeIn9zAhcwkURp66OHWIk3NZ/6IriXhwJqxotH+ReowxlU5H4W0JotVPqgT0RM8FnTfbpBn5zUAVOTWgdhrsGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772813191; c=relaxed/simple; bh=0cjCaj0WSA77OzOPQUqI9rgusEkt0jjILKoZFMR94YY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SjZ0BdPvVlStxM5sSgC6bc3ftzare5VgAOiXeZzAtT0JOnmaqwNJ9xpOMV+3YXNbX+7Xq5glvGAnfTGS5/LYvOpt0QAJ+dRh/9JGcSvRekpOWOKdsatNxfnCP69Abe/0Ccq5Ldzemf1GD3THWGPToHnwISUdUAJydAiVJM6PFMc= 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=fnotV62A; 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="fnotV62A" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 86F89B344A; 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=7SD1FN6utUiARoV67vR12WAaEBhC3lHP/DWE3mGruJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fnotV62Atagvs6s/fhzNgwN3E62OYPBAycgZtQj7EDB0Jmfxz9F6HRVBBXE2EXNQZ JXDEE5IkM8sdOC+gekif3WB0BTXPDOmiX7oyAAvbmcOTTPbltfNJRMUHuxJDDASNpN lx2VzkIRzYVwXU8TC86a53zOj5jMU/brzK1ERxbg= 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 5/8] mm: use zone lock guard in take_page_off_buddy() Date: Fri, 6 Mar 2026 16:05:39 +0000 Message-ID: <9277af9c463a3401e833674d28c8604d314922af.1772811429.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 zone_lock_irqsave lock guard in take_page_off_buddy() to replace the explicit lock/unlock pattern with automatic scope-based cleanup. This also allows to return directly from the loop, removing the 'ret' variable. Suggested-by: Steven Rostedt Signed-off-by: Dmitry Ilvokhin Reviewed-by: Steven Rostedt (Google) --- mm/page_alloc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2857daf6ebfd..92fa922911d5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7493,11 +7493,9 @@ bool take_page_off_buddy(struct page *page) { struct zone *zone =3D page_zone(page); unsigned long pfn =3D page_to_pfn(page); - unsigned long flags; unsigned int order; - bool ret =3D false; =20 - zone_lock_irqsave(zone, flags); + guard(zone_lock_irqsave)(zone); for (order =3D 0; order < NR_PAGE_ORDERS; order++) { struct page *page_head =3D page - (pfn & ((1 << order) - 1)); int page_order =3D buddy_order(page_head); @@ -7512,14 +7510,12 @@ bool take_page_off_buddy(struct page *page) break_down_buddy_pages(zone, page_head, page, 0, page_order, migratetype); SetPageHWPoisonTakenOff(page); - ret =3D true; - break; + return true; } if (page_count(page_head) > 0) break; } - zone_unlock_irqrestore(zone, flags); - return ret; + return false; } =20 /* --=20 2.47.3 From nobody Thu Apr 9 17:57:53 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 84CAC3ED128 for ; Fri, 6 Mar 2026 16:06:29 +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=1772813191; cv=none; b=fQ0jr6i7xQmwWAkjbGemu+ANDxHky1MqkRySsNnHia+zBwQpBuSToLhb/q0e2ShNUoptmWgxJZnOKE+CNS3h+1+wXVHZTb6LkHRo++N8/ldcgSGV8BDL88khsrl1ILgJl0aELfwULG8lQ/ZkPiIz8jmCuTcIEal1KsFuI6/roqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772813191; c=relaxed/simple; bh=MW3YTlKixWpRUBRaD+w3lWCmZb2cAM96v+e91HPVHtw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=heYYnKie/Y/ul1Gfme3bRgefgMjoNkkIwp8HWbcb1AcvN4Q04EW+ILfEWj8NEnrv610kVmQqRay7XCw2R5znvjzP+WSdN4JmnunyQe4sBeuQT21dq6+qxxySYiwFrNDf1HyyXIW7iUyCyOMpO58I03fXFTjGGd3bbxFFMg2j4ZQ= 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=1bOrNU2c; 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="1bOrNU2c" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id CB1C5B344D; 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=1772813186; bh=rAeOH5IgrtG9/UsY5VOxVdlGDjQqvvwATIuVyeglsuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1bOrNU2cmJL/WDIqAPD076EgHgoW/TaOlwkwVczxFJVtGhtPFQ0pXmMCIj0naFCRt 2zTpJP+5oBpkRdpb7ZhjuLAPiLnBv7XLrtohX+f86b3gi1eUzJ7VMQYv89YLomhWrN Xum4wt3f4RVV1F7EsmK+JdLH27ULXCzK1yoaC0ek= 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 6/8] mm: use zone lock guard in put_page_back_buddy() Date: Fri, 6 Mar 2026 16:05:40 +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 lock guard in put_page_back_buddy() to replace the explicit lock/unlock pattern with automatic scope-based cleanup. Suggested-by: Steven Rostedt Signed-off-by: Dmitry Ilvokhin Reviewed-by: Steven Rostedt (Google) --- mm/page_alloc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 92fa922911d5..28b06baa4075 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7524,23 +7524,19 @@ bool take_page_off_buddy(struct page *page) bool put_page_back_buddy(struct page *page) { struct zone *zone =3D page_zone(page); - unsigned long flags; - bool ret =3D false; =20 - zone_lock_irqsave(zone, flags); + guard(zone_lock_irqsave)(zone); if (put_page_testzero(page)) { unsigned long pfn =3D page_to_pfn(page); int migratetype =3D get_pfnblock_migratetype(page, pfn); =20 ClearPageHWPoisonTakenOff(page); __free_one_page(page, pfn, zone, 0, migratetype, FPI_NONE); - if (TestClearPageHWPoison(page)) { - ret =3D true; - } + if (TestClearPageHWPoison(page)) + return true; } - zone_unlock_irqrestore(zone, flags); =20 - return ret; + return false; } #endif =20 --=20 2.47.3 From nobody Thu Apr 9 17:57:53 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 84BEF3ED126 for ; Fri, 6 Mar 2026 16:06:29 +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=1772813192; cv=none; b=NqhTipnYTLKIBmtbhvVpIQ0n4VCjQYxo0J1H8F/LgJisi0y1rpA7a3gcgey/cImnkczz6lfyZWP2mjVqyCmVQh0VIr3Rt0qCNGGXLdNevPbbvDlnjZZ2wkO+6Dhxtw0YsH3eMKECMWVPkBe7NTPKapbLvSBDtAGe7VnuMVXy1j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772813192; c=relaxed/simple; bh=HGhyqHP+XMjKSEx3m75UzkzHSFAXc+6z0q6/AFl1Enk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NS6mszbK+BIhPAT48D1nlYu0eg4/IsMWW1/73PotlxzXQAwKHF7syDQMNnVdvE+EBojUYTRplgbcAH/B7lbgriveaMCvmmWQv/Ov/DeR0yGELAiAUbrj4d8tQrKWdz7mbfgGysSwxt5gUst/l9KPuTmWpl9tq9iUJYcmb78wffU= 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=vTrENs8w; 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="vTrENs8w" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 1BF0FB3450; Fri, 06 Mar 2026 16:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1772813186; bh=LDE9sNwpvCyHqDBgmu8oAPHRFTOTnIBx1S/VGmZEjBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vTrENs8w9kXRwhEVqSh1zTjuDl4Cj/Lj3M9bIixdpG6mDhxBorXg/9Q58IGyVlYsn kzlzgs21Ol9eIA3Tq+uXIOl2z/9uKHU3mm+8cSjAuU5utPa299/oRc1QxlpkG5SX5/ rhuulyKbGbbS/UvCwwjBCvUzDC1mfcd0llmJ19Cc= 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 7/8] mm: use zone lock guard in free_pcppages_bulk() Date: Fri, 6 Mar 2026 16:05:41 +0000 Message-ID: <15d66e640ad30edea62247e7bcd98ebde05be0ff.1772811429.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 zone_lock_irqsave lock guard in free_pcppages_bulk() to replace the explicit lock/unlock pattern with automatic scope-based cleanup. Suggested-by: Steven Rostedt Signed-off-by: Dmitry Ilvokhin Reviewed-by: Steven Rostedt (Google) --- mm/page_alloc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 28b06baa4075..2759e02340fa 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1455,7 +1455,6 @@ static void free_pcppages_bulk(struct zone *zone, int= count, struct per_cpu_pages *pcp, int pindex) { - unsigned long flags; unsigned int order; struct page *page; =20 @@ -1468,7 +1467,7 @@ static void free_pcppages_bulk(struct zone *zone, int= count, /* Ensure requested pindex is drained first. */ pindex =3D pindex - 1; =20 - zone_lock_irqsave(zone, flags); + guard(zone_lock_irqsave)(zone); =20 while (count > 0) { struct list_head *list; @@ -1500,8 +1499,6 @@ static void free_pcppages_bulk(struct zone *zone, int= count, trace_mm_page_pcpu_drain(page, order, mt); } while (count > 0 && !list_empty(list)); } - - zone_unlock_irqrestore(zone, flags); } =20 /* Split a multi-block free page into its individual pageblocks. */ --=20 2.47.3 From nobody Thu Apr 9 17:57:53 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 84B353ECBFF for ; Fri, 6 Mar 2026 16:06:29 +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=1772813191; cv=none; b=sQtRFXWMh8RX9tNU7lFe03MSOUs9PogJoPYem4YiTHXiNi7iFUsV9hozHbdZWXFRtk98eoZqZReHzz6QjwcGfnWwiIaQEXUPV1PIhle/O/WUjjGfzm/BVF5dZaFZUDNEuTJJrpBaxuR0Hv5C9O1I9aqoKCm8GlOKm8oDbxHSJqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772813191; c=relaxed/simple; bh=1yUiUsKIOG9ab5xdXoZavPxUcpD9suELoBvAzpipGCU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nfmPszwnAYRrPplR01FqonwzjBC2LB8aEw0SU6qCC/f5jxQBI/DI+TNTtXicYY6n//pI4/U00C8pnBo5O/36TJgQ8KrtzEqaG9jvRM2Bxrj7ni2bt9uaiMsvsE5mRDSbyrcYYqtHdsPQN8KTpLfwwOkDgK5P8DbyiFtYULyhbRs= 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=TmVIOGiv; 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="TmVIOGiv" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 60685B3455; Fri, 06 Mar 2026 16:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1772813186; bh=1V1/Uxk3C2b3bmWZW0aYP3fQUiU0/LLNtlQCW3eW0iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TmVIOGivH45S62A2GhBBGobf6V3PhxrFmTuo47eRyaYhCBjTLIcvP/JoSpnhfTY+1 PWjTK7mJQSK8f+EpQ9cgd17HyRNqZsjLYRuIHqTBc1ndR46t3MDo8EJqcSJaPAQXBb F3P4BEEX/CdDEWMEbpZoecQ2jmolWzPmaeGHM8DM= 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 8/8] mm: use zone lock guard in __offline_isolated_pages() Date: Fri, 6 Mar 2026 16:05:42 +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 lock guard in __offline_isolated_pages() to replace the explicit lock/unlock pattern with automatic scope-based cleanup. Suggested-by: Steven Rostedt Signed-off-by: Dmitry Ilvokhin Reviewed-by: Steven Rostedt (Google) --- mm/page_alloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2759e02340fa..6f7420e4431f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7380,7 +7380,7 @@ void zone_pcp_reset(struct zone *zone) unsigned long __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) { - unsigned long already_offline =3D 0, flags; + unsigned long already_offline =3D 0; unsigned long pfn =3D start_pfn; struct page *page; struct zone *zone; @@ -7388,7 +7388,7 @@ unsigned long __offline_isolated_pages(unsigned long = start_pfn, =20 offline_mem_sections(pfn, end_pfn); zone =3D page_zone(pfn_to_page(pfn)); - zone_lock_irqsave(zone, flags); + guard(zone_lock_irqsave)(zone); while (pfn < end_pfn) { page =3D pfn_to_page(pfn); /* @@ -7418,7 +7418,6 @@ unsigned long __offline_isolated_pages(unsigned long = start_pfn, del_page_from_free_list(page, zone, order, MIGRATE_ISOLATE); pfn +=3D (1 << order); } - zone_unlock_irqrestore(zone, flags); =20 return end_pfn - start_pfn - already_offline; } --=20 2.47.3