From nobody Thu Apr 9 19:19: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 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 --- 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