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 2BBC83B19CC for ; Wed, 8 Apr 2026 13:33:46 +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=1775655227; cv=none; b=KCIdprNXMB5KNz2zLAlZFMffeqZ5KuGGu233N1q11VKyNcnz3YBZ+fTQe15hBkSsUTgyvZ42AbXWwn11i0E9LaCZfK1tYtP0OFVShEdFtgj9zbd90u8y1vqG4+tDXUk7+zmh2aD5JacFay5z8eSPK9dNZev1biM3X4dSGn9Bni8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775655227; c=relaxed/simple; bh=deugPrvj7XP6nRKhD8+9NMiKZyppDQMXkrUy9D2PUws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kFvmQf/r/xkPHrIXche8LPZhO4lXree3P49pqn1m2hmkAd4Vv5917WNo5txNmtBUcU6KdW+cW0Y6Q8lu8chUWd3aiZ1fIBeDvutOxsWYAOrdyltJPqKvKhntpHpotkKMKzqlXwBiscadA2ztFNBt46kOiHIhzwBk3BQA1Kcp088= 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=B6CgjiPE; 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="B6CgjiPE" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id DFA7EBE70F; Wed, 08 Apr 2026 13:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1775655219; bh=zCLRAjuTrAQTizeHsvvcGO1levRtnCTOyZrIbtMQ40A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=B6CgjiPEf0oUY+HcHI1TGUkeqsMFfR+z6iwLuuCNGT6xWUh1mPNDAFsbKgfc0z8g0 kctIIZ/mwbnFCIccEJAX9CCMrtczS5vOUz6mniz4QA7JS/H2zTg35B1na/ftX1vy0G BRILKsctNBtNAGDKC44EVtNjzejbgY2r8DJxRNIg= 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: [RESEND PATCH v2 1/8] mm: use zone lock guard in reserve_highatomic_pageblock() Date: Wed, 8 Apr 2026 13:33:16 +0000 Message-ID: <9423598fd4f5664c72c0e030efaef2ac5ceae978.1775654118.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 --- 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 111b54df8a3c..3a4523c35fb6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3431,7 +3431,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 @@ -3445,29 +3445,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