Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Dmitry Ilvokhin <d@ilvokhin.com>
Cc: Christian Brauner <brauner@kernel.org>,
	Dan Williams <djbw@kernel.org>, Dave Jiang <dave.jiang@intel.com>,
	Marco Elver <elver@google.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH v2] cleanup: Remove NULL check from unconditional guards
Date: Tue, 12 May 2026 18:55:14 +0200	[thread overview]
Message-ID: <20260512165514.GC2677887@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <agM7Jekhn3py3sIg@shell.ilvokhin.com>

On Tue, May 12, 2026 at 02:37:25PM +0000, Dmitry Ilvokhin wrote:
> On Tue, May 12, 2026 at 02:45:57PM +0200, Peter Zijlstra wrote:
> > 
> > What about class_irqdesc_lock_constructor() ? AFAICT
> > __irq_get_desc_lock() can return NULL.
> 
> Thanks for taking a look, Peter. Yes, that is actually a very good
> catch.
> 
> For some reason I naively thought __DEFINE_UNLOCK_GUARD() wouldn't be
> used outside of include/linux/cleanup.h, but this is obviously wrong
> assumption. There are cases, where DEFINE_LOCK_GUARD_1() doesn't fit
> callers needs, so __DEFINE_UNLOCK_GUARD() is used directly.
> 
> - kernel/irq/internals.h: the case you pointed out. Can be fixed by
>   moving the NULL check into the irqdesc_lock unlock expression
>   directly.
> 
> - include/linux/tty_port.h: similar use case. NULL check can be moved
>   into tty_port_tty as well, similar to previous case.
> 
> - kernel/sched/sched.h: lock and lock2 shouldn't be NULL at destructor
>   time, since they are dereferenced unconditionally at constructor.
> 
> Below is example how this will look like. Does this look reasonable to
> you, or would you prefer a different approach?

Yeah, I don't mind changing things here, but like I said before, only
after a full audit of every single user ;-)

And yeah, fixing up those things shouldn't be hard, but it needs be
done.


      reply	other threads:[~2026-05-12 16:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12  7:15 [PATCH v2] cleanup: Remove NULL check from unconditional guards Dmitry Ilvokhin
2026-05-12 12:45 ` Peter Zijlstra
2026-05-12 14:37   ` Dmitry Ilvokhin
2026-05-12 16:55     ` Peter Zijlstra [this message]

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=20260512165514.GC2677887@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=d@ilvokhin.com \
    --cc=dave.jiang@intel.com \
    --cc=djbw@kernel.org \
    --cc=elver@google.com \
    --cc=hpa@zytor.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox