Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] cleanup: Remove NULL check from unconditional guards
@ 2026-05-21  7:18 Dmitry Ilvokhin
  2026-05-21  7:18 ` [PATCH v4 1/4] nvdimm: Convert nvdimm_bus guard to class Dmitry Ilvokhin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dmitry Ilvokhin @ 2026-05-21  7:18 UTC (permalink / raw)
  To: Peter Zijlstra, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
	Miguel Ojeda, Thomas Gleixner, Christian Brauner, Marco Elver,
	H. Peter Anvin, Andrew Morton
  Cc: nvdimm, linux-kernel, linux-mm, kernel-team, Dmitry Ilvokhin

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() 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 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.

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 | 6 ++++++
 kernel/irq/internals.h              | 2 +-
 4 files changed, 17 insertions(+), 6 deletions(-)

-- 
2.53.0-Meta



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-21  7:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21  7:18 [PATCH v4 0/4] cleanup: Remove NULL check from unconditional guards Dmitry Ilvokhin
2026-05-21  7:18 ` [PATCH v4 1/4] nvdimm: Convert nvdimm_bus guard to class Dmitry Ilvokhin
2026-05-21  7:18 ` [PATCH v4 2/4] genirq: Move NULL check into irqdesc_lock guard unlock expression Dmitry Ilvokhin
2026-05-21  7:18 ` [PATCH v4 3/4] cleanup: Annotate guard constructors with __nonnull() Dmitry Ilvokhin
2026-05-21  7:18 ` [PATCH v4 4/4] cleanup: Remove NULL check from unconditional guards Dmitry Ilvokhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox