public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <llong@redhat.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Waiman Long <llong@redhat.com>
Cc: linux-kernel@vger.kernel.org, Boqun Feng <boqun.feng@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Will Deacon <will@kernel.org>
Subject: Re: [PATCH] locking/mutex: Redo __mutex_init()
Date: Wed, 5 Nov 2025 08:49:05 -0500	[thread overview]
Message-ID: <10899bd0-09ca-4fcf-8142-3d5cd6e4fedf@redhat.com> (raw)
In-Reply-To: <20251105075729.SJ4cL1rz@linutronix.de>

On 11/5/25 2:57 AM, Sebastian Andrzej Siewior wrote:
> On 2025-11-04 11:21:27 [-0500], Waiman Long wrote:
>>> +#ifdef CONFIG_DEBUG_LOCK_ALLOC
>>> +void mutex_init_ld(struct mutex *lock, const char *name, struct lock_class_key *key);
>>> +
>>> +static inline void __mutex_init(struct mutex *lock, const char *name,
>>> +				struct lock_class_key *key)
>>> +{
>>> +	mutex_init_ld(lock, name, key);
>>> +}
>>> +#else
>>> +extern void mutex_init_plain(struct mutex *lock);
>>> +
>>> +static inline void __mutex_init(struct mutex *lock, const char *name,
>>> +				struct lock_class_key *key)
>>> +{
>>> +	mutex_init_plain(lock);
>>> +}
>>> +#endif /* !CONFIG_DEBUG_LOCK_ALLOC */
>> I think it is a good idea to eliminate useless strings in non-lockdep
>> kernel. However, the function names are kind of awkward to me. First of all,
>> it is hard to associate "ld" with lockdep as ld is also the name of the GNU
>> linker. I would prefer to fully spell out as "lockdep". The "_plain" suffix
>> also looks odd to me. How about using the original __mutex_init for the
>> plain version and __mutex_init_lockdep as the lockdep version which calls
>> __mutex_init and use similar naming scheme for the RT versions. What do you
>> think?
> What about
> 	mutex_init_plain() -> mutex_init_generic()
> 	mutex_init_ld() -> mutex_init_lockdep()
Yes, generic is a much better name.
>
> Using __mutex_init() for the basic/ generic init could work but we have
> already users 13 users (drivers/ mm/ net/) and the rust bindings are
> also attached to it. I would prefer the generic/ lockdep suffix.
>
> If you want __mutex_init() for the generic, regardless, we would first
> need to make room and then something like mutex_init_lockdep() could be
> the public interface replacing __mutex_init() in its current function.

Ah, I don't realize that there are users of __mutex_init() outside of 
the locking subsystem. In this case, we have to maintain the semantics 
of __mutex_init() to avoid affecting other subsystems.

Thanks for the clarification.

Cheers,
Longman


  reply	other threads:[~2025-11-05 13:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04 14:00 [PATCH] locking/mutex: Redo __mutex_init() Sebastian Andrzej Siewior
2025-11-04 16:21 ` Waiman Long
2025-11-05  7:57   ` Sebastian Andrzej Siewior
2025-11-05 13:49     ` Waiman Long [this message]
2025-11-05 13:54       ` Sebastian Andrzej Siewior
2025-11-05 14:23       ` [PATCH v2] " Sebastian Andrzej Siewior
2025-11-05 16:22         ` Waiman Long
2025-11-14 15:33         ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2025-11-28 10:00         ` tip-bot2 for Sebastian Andrzej Siewior
2025-12-01  6:01         ` [tip: locking/core] locking/mutex: Redo __mutex_init() to reduce generated code size tip-bot2 for Sebastian Andrzej Siewior

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=10899bd0-09ca-4fcf-8142-3d5cd6e4fedf@redhat.com \
    --to=llong@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will@kernel.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