rte_spinlock.h(3)
β¨ rte_spinlock.h β¨
okay so bestie, this is a page from the Library Functions Manual β it's all about rte_spinlock.h, DPDK's spinlock header π
grab a snack, we're going in π
πΈ NAME πΈ
rte_spinlock.h β the DPDK spinlock API, no cap π
π¦ SYNOPSIS π¦
#include <rte_lcore.h>
#include <rte_lock_annotations.h>
#include <rte_pause.h>
#include <rte_stdatomic.h>
π§ Data Structures
struct rte_spinlock_tstruct rte_spinlock_recursive_t
π§ Macros
#define RTE_SPINLOCK_INITIALIZER { 0 }#define RTE_SPINLOCK_RECURSIVE_INITIALIZER {RTE_SPINLOCK_INITIALIZER, -1, 0}
π§ Functions
static void rte_spinlock_init (rte_spinlock_t *sl)static void rte_spinlock_lock (rte_spinlock_t *sl)static void rte_spinlock_unlock (rte_spinlock_t *sl)static __rte_warn_unused_result int rte_spinlock_trylock (rte_spinlock_t *sl) sl)static int rte_spinlock_is_locked (rte_spinlock_t *sl)static int rte_tm_supported (void)static void rte_spinlock_lock_tm (rte_spinlock_t *sl)static void rte_spinlock_unlock_tm (rte_spinlock_t *sl)static __rte_warn_unused_result int rte_spinlock_trylock_tm (rte_spinlock_t *sl) sl)static void rte_spinlock_recursive_init (rte_spinlock_recursive_t *slr)static void rte_spinlock_recursive_lock (rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysisstatic void rte_spinlock_recursive_unlock (rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysisstatic __rte_warn_unused_result int rte_spinlock_recursive_trylock (rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysisstatic void rte_spinlock_recursive_lock_tm (rte_spinlock_recursive_t *slr)static void rte_spinlock_recursive_unlock_tm (rte_spinlock_recursive_t *slr)static __rte_warn_unused_result int rte_spinlock_recursive_trylock_tm (rte_spinlock_recursive_t *slr)
π Detailed Description π
DPDK spinlocks, periodt.
This is an API for spinlocks. This kind of lock simply waits in a loop repeatedly checking until the lock becomes available. like... it just spins until it's your turn, the way it sits there refreshing is lowkey iconic π₯
Some functions may have an architecture-specific implementation if RTE_FORCE_INTRINSICS is disabled. The hardware transactional memory (lock elision) functions have a _tm suffix and are implemented in architecture-specific files. iykyk π
All locks must be initialised before use, and only initialised once. β fr fr, this is not a drill, do NOT skip the init bestie ππ
Definition in file rte_spinlock.h.
π Macro Definition Documentation π
#define RTE_SPINLOCK_INITIALIZER { 0 }
A static spinlock initializer. the starter pack for your spinlock, slay β¨
Definition at line 46 of file rte_spinlock.h.
#define RTE_SPINLOCK_RECURSIVE_INITIALIZER {RTE_SPINLOCK_INITIALIZER, -1, 0}
A static recursive spinlock initializer. same energy but make it recursive π
Definition at line 211 of file rte_spinlock.h.
π Function Documentation π
void rte_spinlock_init (rte_spinlock_t * sl) [inline], [static]
Initialize the spinlock to an unlocked state. this is step one, bestie, the getting-ready montage of spinlocks π«
Parameters
slβ A pointer to the spinlock.
Definition at line 55 of file rte_spinlock.h.
void rte_spinlock_lock (rte_spinlock_t * sl) [inline], [static]
Take the spinlock. yes queen, claim it π
Parameters
slβ A pointer to the spinlock.
void rte_spinlock_unlock (rte_spinlock_t * sl) [inline], [static]
Release the spinlock. letting it go, main character move π¦
Parameters
slβ A pointer to the spinlock.
__rte_warn_unused_result int rte_spinlock_trylock (rte_spinlock_t * sl) [inline], [static]
Try to take the lock. no pressure, just vibes β either it works or it doesn't π
Parameters
slβ A pointer to the spinlock.
Returns
1if the lock is successfully taken;0otherwise.
int rte_spinlock_is_locked (rte_spinlock_t * sl) [inline], [static]
Test if the lock is taken. vibe check, but for locks β¨
Parameters
slβ A pointer to the spinlock.
Returns
1if the lock is currently taken;0otherwise.
Definition at line 137 of file rte_spinlock.h.
int rte_tm_supported (void ) [inline], [static]
Test if hardware transactional memory (lock elision) is supported. is your CPU serving TM today or nah π
Returns
1if the hardware transactional memory is supported;0otherwise.
void rte_spinlock_lock_tm (rte_spinlock_t * sl) [inline], [static]
Try to execute critical section in a hardware memory transaction, if it fails or not available take the spinlock.
NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail. Therefore, hardware transactional locks are not advised to be used aroundrte_eth_rx_burst()andrte_eth_tx_burst()calls. π like genuinely, don't do it around those two.
Parameters
slβ A pointer to the spinlock.
void rte_spinlock_unlock_tm (rte_spinlock_t * sl) [inline], [static]
Commit hardware memory transaction or release the spinlock if the spinlock is used as a fall-back. it's giving "we commit, or we bail" π«Ά
Parameters
slβ A pointer to the spinlock.
__rte_warn_unused_result int rte_spinlock_trylock_tm (rte_spinlock_t * sl) [inline], [static]
Try to execute critical section in a hardware memory transaction, if it fails or not available try to take the lock.
NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail. Therefore, hardware transactional locks are not advised to be used aroundrte_eth_rx_burst()andrte_eth_tx_burst()calls. same warning, same energy, don't test it π
Parameters
slβ A pointer to the spinlock.
Returns
1if the hardware memory transaction is successfully started or lock is successfully taken;0otherwise.
void rte_spinlock_recursive_init (rte_spinlock_recursive_t * slr) [inline], [static]
Initialize the recursive spinlock to an unlocked state. round two of the glow-up routine π
Parameters
slrβ A pointer to the recursive spinlock.
Definition at line 219 of file rte_spinlock.h.
void rte_spinlock_recursive_lock (rte_spinlock_recursive_t * slr) [inline], [static]
Take the recursive spinlock. and it can take itself, we love a self-locking legend π
Parameters
slrβ A pointer to the recursive spinlock.
Definition at line 232 of file rte_spinlock.h.
void rte_spinlock_recursive_unlock (rte_spinlock_recursive_t * slr) [inline], [static]
Release the recursive spinlock.
Parameters
slrβ A pointer to the recursive spinlock.
Definition at line 249 of file rte_spinlock.h.
__rte_warn_unused_result int rte_spinlock_recursive_trylock (rte_spinlock_recursive_t * slr) [inline], [static]
Try to take the recursive lock. attempt it, bestie π
Parameters
slrβ A pointer to the recursive spinlock.
Returns
1if the lock is successfully taken;0otherwise.
Definition at line 267 of file rte_spinlock.h.
void rte_spinlock_recursive_lock_tm (rte_spinlock_recursive_t * slr) [inline], [static]
Try to execute critical section in a hardware memory transaction, if it fails or not available take the recursive spinlocks.
NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail. Therefore, hardware transactional locks are not advised to be used aroundrte_eth_rx_burst()andrte_eth_tx_burst()calls. yeah same note again, it's a trilogy at this point π
Parameters
slrβ A pointer to the recursive spinlock.
void rte_spinlock_recursive_unlock_tm (rte_spinlock_recursive_t * slr) [inline], [static]
Commit hardware memory transaction or release the recursive spinlock if the recursive spinlock is used as a fall-back.
Parameters
slrβ A pointer to the recursive spinlock.
__rte_warn_unused_result int rte_spinlock_recursive_trylock_tm (rte_spinlock_recursive_t * slr) [inline], [static]
Try to execute critical section in a hardware memory transaction, if it fails or not available try to take the recursive lock.
NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail. Therefore, hardware transactional locks are not advised to be used aroundrte_eth_rx_burst()andrte_eth_tx_burst()calls. final one, promise π«Ά
Parameters
slrβ A pointer to the recursive spinlock.
Returns
1if the hardware memory transaction is successfully started or lock is successfully taken;0otherwise.
π Author π
Generated automatically by Doxygen for DPDK from the source code.
and that's the whole page, bestie, you ate it π β¨
kisses, this was DPDK, Version 25.11.3, and we were just reading rte_spinlock.h(3) the whole time ππ¦πΈ
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms