Thread (22 messages) 22 messages, 4 authors, 2024-06-06

Re: [PATCH v4 net-next 01/14] locking/local_lock: Add local nested BH locking infrastructure.

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: 2024-06-06 07:59:14
Also in: lkml

On 2024-06-06 09:52:44 [+0200], Peter Zijlstra wrote:
On Tue, Jun 04, 2024 at 05:24:08PM +0200, Sebastian Andrzej Siewior wrote:
quoted
Add local_lock_nested_bh() locking. It is based on local_lock_t and the
naming follows the preempt_disable_nested() example.

For !PREEMPT_RT + !LOCKDEP it is a per-CPU annotation for locking
assumptions based on local_bh_disable(). The macro is optimized away
during compilation.
For !PREEMPT_RT + LOCKDEP the local_lock_nested_bh() is reduced to
the usual lock-acquire plus lockdep_assert_in_softirq() - ensuring that
BH is disabled.

For PREEMPT_RT local_lock_nested_bh() acquires the specified per-CPU
lock. It does not disable CPU migration because it relies on
local_bh_disable() disabling CPU migration.
should we assert this? lockdep_assert(current->migration_disabled) or
somesuch should do, rite?
local_lock_nested_bh() has lockdep_assert_in_softirq(). You want the
migration check additionally or should that softirq assert work?
quoted
With LOCKDEP it performans the usual lockdep checks as with !PREEMPT_RT.
Due to include hell the softirq check has been moved spinlock.c.

The intention is to use this locking in places where locking of a per-CPU
variable relies on BH being disabled. Instead of treating disabled
bottom halves as a big per-CPU lock, PREEMPT_RT can use this to reduce
the locking scope to what actually needs protecting.
A side effect is that it also documents the protection scope of the
per-CPU variables.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Otherwise I suppose sp.. not a fan of the whole nested thing, but I
don't really have an alternative proposal so yeah, whatever :-)
Cool.

Sebastian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help