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_t
  • struct 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_analysis
  • static void rte_spinlock_recursive_unlock (rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysis
  • static __rte_warn_unused_result int rte_spinlock_recursive_trylock (rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysis
  • static 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

  • 1 if the lock is successfully taken; 0 otherwise.

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

  • 1 if the lock is currently taken; 0 otherwise.

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

  • 1 if the hardware transactional memory is supported; 0 otherwise.

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 around rte_eth_rx_burst() and rte_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 around rte_eth_rx_burst() and rte_eth_tx_burst() calls. same warning, same energy, don't test it πŸ™ˆ

Parameters

  • sl β€” A pointer to the spinlock.

Returns

  • 1 if the hardware memory transaction is successfully started or lock is successfully taken; 0 otherwise.

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

  • 1 if the lock is successfully taken; 0 otherwise.

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 around rte_eth_rx_burst() and rte_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 around rte_eth_rx_burst() and rte_eth_tx_burst() calls. final one, promise 🫢

Parameters

  • slr β€” A pointer to the recursive spinlock.

Returns

  • 1 if the hardware memory transaction is successfully started or lock is successfully taken; 0 otherwise.

🌈 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