From mboxrd@z Thu Jan 1 00:00:00 1970 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 3C13C38F233 for ; Wed, 29 Apr 2026 12:02:34 +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=1777464156; cv=none; b=R10W79fc1LzbtbO/PjFgsjKLFQ0y5TjaDwW90LFbYp4OmyE2lmZ/2Z87+qEt88cw/uvBdzjbNq+8WP7YQM2GUfuN55OEjcMZ2UvxRHvW6J5afiI3RCw8pkWeaYewOG5ei/FiS+p0EAlA5jUBEsTMjA1Y7KasYYZmxad9rZWoJcE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777464156; c=relaxed/simple; bh=xkB4iXHoyqdWDAbpoycqRnyjzvHpdTFsGkIl59h45K8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FGcWBHkuGrsqg7cvLEviWbXhGuJAUDcR+fkvExicnPHYJ2+6FDr7rnQHugNyM0i9icNVAgnE/cDN56FZTZWN2exmYG/C6cPudkYtMfQsofuHqkkC1EHY5Zzz1DjKaKmJDFbObOgGi+sA1fIX8WP9e5s9bK73/q/+bzGn8ILYTks= 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=IuG7wGao; 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="IuG7wGao" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 7E868C7A7C; Wed, 29 Apr 2026 12:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1777464146; bh=KGNhH3EjUaTQ7/DOs7LxTGRaC2rJZ5LfPVMVIRVko5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IuG7wGaoP3203s1PEB9g4mBAYThzg0IK8w0ePN4DjXVSDldHy5/yUMPqilCoIqo/t 8qfGLF/j1aCUkzQYJEl10NcBI7YI71ARhqPTgOdwwHtaUavcun0Lc+coVlGvN3XZyS EzVboqauIlQOFOA6x0VgHQ1zZmVPbBxAM01w9Ebw= 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 v3 1/8] mm: use zone lock guard in reserve_highatomic_pageblock() Date: Wed, 29 Apr 2026 12:02:06 +0000 Message-ID: <3657e1144e2ffc1ca0eb57d57d89bfec4073d8c6.1777462630.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: 8bit Use the spinlock_irqsave zone 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 Acked-by: Michal Hocko --- mm/page_alloc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 65e205111553..14c172c9b6c6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3429,7 +3429,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; /* * The number reserved as: minimum is 1 pageblock, maximum is @@ -3443,29 +3443,26 @@ static void reserve_highatomic_pageblock(struct page *page, int order, if (zone->nr_reserved_highatomic >= max_managed) return; - spin_lock_irqsave(&zone->lock, flags); + guard(spinlock_irqsave)(&zone->lock); /* Recheck the nr_reserved_highatomic limit under the lock */ if (zone->nr_reserved_highatomic >= max_managed) - goto out_unlock; + return; /* Yoink! */ mt = get_pageblock_migratetype(page); /* Only reserve normal pageblocks (i.e., they can merge with others) */ if (!migratetype_is_mergeable(mt)) - goto out_unlock; + return; if (order < pageblock_order) { if (move_freepages_block(zone, page, mt, MIGRATE_HIGHATOMIC) == -1) - goto out_unlock; + return; zone->nr_reserved_highatomic += pageblock_nr_pages; } else { change_pageblock_range(page, order, MIGRATE_HIGHATOMIC); zone->nr_reserved_highatomic += 1 << order; } - -out_unlock: - spin_unlock_irqrestore(&zone->lock, flags); } /* -- 2.52.0