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 CD20C3DA7F5 for ; Mon, 27 Apr 2026 17:00:20 +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=1777309222; cv=none; b=jInOw9teckvhfOuRIjMT79joFVY8bRjzz/DoPZIqXjVs9i04Gw4hZ578U2tIJtEfaa3flcKSLGKdJLl4vPdLJBlSa6BUllhu0lpPFoJG705Mgd8gGSNUw8Cg0eocPHRRQ/ft5WceJvgy3oCe9nzb5HUvU2bvG+IzqLhqL5RiTMc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777309222; c=relaxed/simple; bh=DGj3GXGkUfFyVXe5Vnjb9ax15Fxb/GFxowLW7UC+4Ls=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Qx3va5uNyx/izQvdWREzOsCD6NpYBFgnybX9V2T53b0ZVfZaOMDrU4eucKI5+UcSoIRc6dP+wOTnxa2eMDVi8pY9UtHkm2GF6Prfm38qSpg4345CyDDW7z6frpD/SMdUqfYfSazoYffQVQ+LrB+mOui8arxw5hwU1RnzbVi7rzg= 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=YQDj2eBR; 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="YQDj2eBR" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id BB604C7966; Mon, 27 Apr 2026 16:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1777308664; bh=Di0Etxui169qRnRooajrzDSyqwkhyD0hpidzw6bAyGg=; h=From:To:Cc:Subject:Date; b=YQDj2eBRaRm0JA0vVq/QDzXenU4Ez3lfNmfBZP3ZZzP4dVeFCs72VXsF5K4QcHyfp SGt4HyTjePTr7xiuTCRv1kDQk0R0TuTDN5ILCAO09QpSGD96tYE2E6VJ4skhYtpWZY fJTYmuC/JwA4/9HYWA0W3ggZaZbX5jcDj0JegPRI= From: Dmitry Ilvokhin To: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Dan Williams , Andrew Morton , "Paul E. McKenney" , Marco Elver Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Dmitry Ilvokhin Subject: [PATCH] cleanup: Remove NULL check from unconditional guards Date: Mon, 27 Apr 2026 16:50:37 +0000 Message-ID: <20260427165037.205337-1-d@ilvokhin.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The unconditional guard destructors check whether the lock pointer is NULL before unlocking. This check is unnecessary because unconditional guards always acquire the lock: the pointer can never be NULL. Conditional (_try) variants have their own destructors via EXTEND_CLASS_COND() that handle the failure case before reaching the base destructor. As compiled by GCC-16 with defconfig on top of the locking/core: Total: Before=23770501, After=23716538, chg -0.23% Signed-off-by: Dmitry Ilvokhin --- include/linux/cleanup.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h index ea95ca4bc11c..1410effa8780 100644 --- a/include/linux/cleanup.h +++ b/include/linux/cleanup.h @@ -397,7 +397,7 @@ static __maybe_unused const bool class_##_name##_is_conditional = _is_cond __DEFINE_GUARD_LOCK_PTR(_name, _T) #define DEFINE_GUARD(_name, _type, _lock, _unlock) \ - DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \ + DEFINE_CLASS(_name, _type, _unlock, ({ _lock; _T; }), _type _T); \ DEFINE_CLASS_IS_GUARD(_name) #define DEFINE_GUARD_COND_4(_name, _ext, _lock, _cond) \ @@ -491,7 +491,7 @@ typedef struct { \ static __always_inline void class_##_name##_destructor(class_##_name##_t *_T) \ __no_context_analysis \ { \ - if (_T->lock) { _unlock; } \ + _unlock; \ } \ \ __DEFINE_GUARD_LOCK_PTR(_name, &_T->lock) -- 2.52.0