Skip to contentSkip to conversation

local_lock: Minor improvements of local_trylock*() documentation

PATCH Superseded Leonardo Bras 2 participants 3 messages May 5, 2025 – May 21, 2025 Locking primitives

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 local_lock: Minor improvements of local_trylock*() documentation

Fix local_trylock_init() documentation, as it was mentioning the non-try helper instead, and use the opportunity to make clear the try_lock*() needs to receive a local_trylock_t variable as parameter.

---

Changes since RFC:
- Replace try-enabled lock with local_trylock{,_t}

 include/linux/local_lock.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/local_lock.h +3 -3
index 16a2ee4f8310b..58adaaf98dd74 100644
@@ -45,38 +45,38 @@
 /**
  * local_unlock_irqrestore - Release a per CPU local lock and restore
  *			      interrupt flags
  * @lock:	The lock variable
  * @flags:      Interrupt flags to restore
  */
 #define local_unlock_irqrestore(lock, flags)			\
 	__local_unlock_irqrestore(lock, flags)
 
 /**
- * local_lock_init - Runtime initialize a lock instance
+ * local_trylock_init - Runtime initialize a local_trylock instance
  */
 #define local_trylock_init(lock)	__local_trylock_init(lock)
 
 /**
  * local_trylock - Try to acquire a per CPU local lock
- * @lock:	The lock variable
+ * @lock:	The local_trylock_t variable
  *
  * The function can be used in any context such as NMI or HARDIRQ. Due to
  * locking constrains it will _always_ fail to acquire the lock in NMI or
  * HARDIRQ context on PREEMPT_RT.
  */
 #define local_trylock(lock)		__local_trylock(lock)
 
 /**
  * local_trylock_irqsave - Try to acquire a per CPU local lock, save and disable
  *			   interrupts if acquired
- * @lock:	The lock variable
+ * @lock:	The local_trylock_t variable
  * @flags:	Storage for interrupt flags
  *
  * The function can be used in any context such as NMI or HARDIRQ. Due to
  * locking constrains it will _always_ fail to acquire the lock in NMI or
  * HARDIRQ context on PREEMPT_RT.
  */
 #define local_trylock_irqsave(lock, flags)			\
 	__local_trylock_irqsave(lock, flags)
 
 DEFINE_GUARD(local_lock, local_lock_t __percpu*,
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Leonardo Bras

Fix local_trylock_init() documentation, as it was mentioning the non-try helper instead, and use the opportunity to make clear the try_lock*() needs to receive a local_trylock_t variable as parameter.

…

Quoted 5 lines
include/linux/local_lock.h +0 -0
@@ -45,38 +45,38 @@
 /**
  * local_unlock_irqrestore - Release a per CPU local lock and restore

include/linux/local_lock.h line 55

Quoted 10 lines
include/linux/local_lock.h +1 -1
  *			      interrupt flags
  * @lock:	The lock variable
  * @flags:      Interrupt flags to restore
  */
 #define local_unlock_irqrestore(lock, flags)			\
 	__local_unlock_irqrestore(lock, flags)
 
 /**
- * local_lock_init - Runtime initialize a lock instance
+ * local_trylock_init - Runtime initialize a local_trylock instance

If you replace "lock instance" please use local_trylock_t instead "local_trylock"

Other than that,

include/linux/local_lock.h line 57

Quoted 2 lines
include/linux/local_lock.h +0 -0
  */
 #define local_trylock_init(lock)	__local_trylock_init(lock)

…

Sebastian

#2 lore raw

Hi Sebastian,

Quoted 20 lines · Sebastian Andrzej Siewior
Quoted 5 lines · Leonardo Bras

Fix local_trylock_init() documentation, as it was mentioning the non-try helper instead, and use the opportunity to make clear the try_lock*() needs to receive a local_trylock_t variable as parameter.

…

Quoted 12 lines
include/linux/local_lock.h +0 -0
@@ -45,38 +45,38 @@
 /**
  * local_unlock_irqrestore - Release a per CPU local lock and restore
  *                         interrupt flags
  * @lock:    The lock variable
  * @flags:      Interrupt flags to restore
  */
 #define local_unlock_irqrestore(lock, flags)                 \
      __local_unlock_irqrestore(lock, flags)
 
Quoted 6 lines

include/linux/local_lock.h line 55

Quoted 3 lines
include/linux/local_lock.h +1 -1
 /**
- * local_lock_init - Runtime initialize a lock instance
+ * local_trylock_init - Runtime initialize a local_trylock instance

If you replace "lock instance" please use local_trylock_t instead "local_trylock"

Will do

Quoted 3 lines

Other than that,

Thanks!
Leo

Quoted 8 lines

include/linux/local_lock.h line 57

Quoted 3 lines
include/linux/local_lock.h +0 -0
  */
 #define local_trylock_init(lock)     __local_trylock_init(lock)

…

Sebastian