From: Dmitry Ilvokhin <d@ilvokhin.com>
To: Peter Zijlstra <peterz@infradead.org>,
Dan Williams <djbw@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Ira Weiny <ira.weiny@intel.com>, Miguel Ojeda <ojeda@kernel.org>,
Thomas Gleixner <tglx@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Marco Elver <elver@google.com>, "H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, kernel-team@meta.com,
Dmitry Ilvokhin <d@ilvokhin.com>
Subject: [PATCH v5 0/4] cleanup: Remove NULL check from unconditional guards
Date: Tue, 2 Jun 2026 07:12:49 +0000 [thread overview]
Message-ID: <cover.1780064327.git.d@ilvokhin.com> (raw)
Unconditional guard destructors have dead NULL checks. The lock operation in
the constructor would crash before the destructor ever runs with NULL.
- Patches 1-2 prepare guards that legitimately handle NULL.
- Patch 3 adds __nonnull_args() to guard constructors for compile-time
enforcement.
- Patch 4 removes the dead checks.
As compiled by GCC-11 with defconfig on top of the locking/core:
Total: Before=23889980, After=23834334, chg -0.23%
Changes in v5:
- Renamed __nonnull() attribute to __nonnull_args() to fix User Mode Linux
build failures (kernel test robot).
- Dropped Acked-by tag from Miguel, since I renamed the attribute.
Changes in v4:
- Re-worded commit message paragraph about nonnull "compiler-enforced
verification" (Miguel Ojeda).
- Fixed GCC documentation link for nonnull() attribute (Miguel Ojeda).
- Placed nonnull() before nonstring() in
include/linux/compiler_attributes.h (Miguel Ojeda).
- Picked up tags, where appropriate.
Changes in v3:
- Audited usages of DEFINE_GUARD(), __DEFINE_UNLOCK_GUARD() and
DEFINE_LOCK_GUARD_1() to make sure NULL check removal will work correctly
(Peter Zijlstra).
- Moved NULL check into irqdesc_lock unlock expression (Peter Zijlstra).
- Added compiler-enforced nonnull() check for guard constructors.
- Converted nvdimm_bus guard to class.
Changes in v2:
- Expand commit message with detailed reasoning, why the proposed
change is correct.
- Rebase on top of locking/core.
v4: https://lore.kernel.org/all/cover.1779286416.git.d@ilvokhin.com/
v3: https://lore.kernel.org/all/cover.1779116497.git.d@ilvokhin.com/
v2: https://lore.kernel.org/all/20260512071510.92451-1-d@ilvokhin.com/
v1: https://lore.kernel.org/all/20260427165037.205337-1-d@ilvokhin.com/
See also [1] for relevant discussion.
[1]: https://lore.kernel.org/all/afCS4d4YccQFtvpi@shell.ilvokhin.com/
Dmitry Ilvokhin (4):
nvdimm: Convert nvdimm_bus guard to class
genirq: Move NULL check into irqdesc_lock guard unlock expression
cleanup: Annotate guard constructors with nonnull
cleanup: Remove NULL check from unconditional guards
drivers/nvdimm/nd.h | 7 +++++--
include/linux/cleanup.h | 8 +++++---
include/linux/compiler_attributes.h | 9 +++++++++
kernel/irq/internals.h | 2 +-
4 files changed, 20 insertions(+), 6 deletions(-)
--
2.53.0-Meta
next reply other threads:[~2026-06-02 7:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 7:12 Dmitry Ilvokhin [this message]
2026-06-02 7:12 ` [PATCH v5 1/4] nvdimm: Convert nvdimm_bus guard to class Dmitry Ilvokhin
2026-06-03 14:25 ` [tip: locking/core] " tip-bot2 for Dmitry Ilvokhin
2026-06-02 7:12 ` [PATCH v5 2/4] genirq: Move NULL check into irqdesc_lock guard unlock expression Dmitry Ilvokhin
2026-06-02 20:37 ` Thomas Gleixner
2026-06-03 14:25 ` [tip: locking/core] " tip-bot2 for Dmitry Ilvokhin
2026-06-02 7:12 ` [PATCH v5 3/4] cleanup: Annotate guard constructors with nonnull Dmitry Ilvokhin
2026-06-02 7:32 ` Miguel Ojeda
2026-06-02 9:19 ` Dmitry Ilvokhin
2026-06-03 14:25 ` [tip: locking/core] " tip-bot2 for Dmitry Ilvokhin
2026-06-05 5:46 ` [PATCH v5 3/4] " Dan Carpenter
2026-06-05 10:46 ` Dmitry Ilvokhin
2026-06-05 13:08 ` [tip: locking/core] cleanup: Specify nonnull argument index tip-bot2 for Dmitry Ilvokhin
2026-06-02 7:12 ` [PATCH v5 4/4] cleanup: Remove NULL check from unconditional guards Dmitry Ilvokhin
2026-06-03 14:25 ` [tip: locking/core] " tip-bot2 for Dmitry Ilvokhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1780064327.git.d@ilvokhin.com \
--to=d@ilvokhin.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=elver@google.com \
--cc=hpa@zytor.com \
--cc=ira.weiny@intel.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nvdimm@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.