Sponsor:

Your company here, and a link to your site. Click to find out more.

rte_spinlock.h - Man Page

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

RTE Spinlocks

This file defines an API for read-write locks, which are implemented in an architecture-specific way. This kind of lock simply waits in a loop repeatedly checking until the lock becomes available.

All locks must be initialised before use, and only initialised once.

Definition in file rte_spinlock.h.

Macro Definition Documentation

#define RTE_SPINLOCK_INITIALIZER   { 0 }

A static spinlock initializer.

Definition at line 38 of file rte_spinlock.h.

#define RTE_SPINLOCK_RECURSIVE_INITIALIZER   {RTE_SPINLOCK_INITIALIZER, -1, 0}

A static recursive spinlock initializer.

Definition at line 203 of file rte_spinlock.h.

Function Documentation

static void rte_spinlock_init (rte_spinlock_t * sl) [inline], [static]

Initialize the spinlock to an unlocked state.

Parameters

sl A pointer to the spinlock.

Definition at line 47 of file rte_spinlock.h.

static void rte_spinlock_lock (rte_spinlock_t * sl) [inline], [static]

Take the spinlock.

Parameters

sl A pointer to the spinlock.

static void rte_spinlock_unlock (rte_spinlock_t * sl) [inline], [static]

Release the spinlock.

Parameters

sl A pointer to the spinlock.

static __rte_warn_unused_result int rte_spinlock_trylock (rte_spinlock_t * sl) [inline], [static]

Try to take the lock.

Parameters

sl A pointer to the spinlock.

Returns

1 if the lock is successfully taken; 0 otherwise.

static int rte_spinlock_is_locked (rte_spinlock_t * sl) [inline], [static]

Test if the lock is taken.

Parameters

sl A pointer to the spinlock.

Returns

1 if the lock is currently taken; 0 otherwise.

Definition at line 129 of file rte_spinlock.h.

static int rte_tm_supported (void) [inline], [static]

Test if hardware transactional memory (lock elision) is supported

Returns

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

static 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.

Parameters

sl A pointer to the spinlock.

static 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

Parameters

sl A pointer to the spinlock.

static __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.

Parameters

sl A pointer to the spinlock.

Returns

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

static void rte_spinlock_recursive_init (rte_spinlock_recursive_t * slr) [inline], [static]

Initialize the recursive spinlock to an unlocked state.

Parameters

slr A pointer to the recursive spinlock.

Definition at line 211 of file rte_spinlock.h.

static void rte_spinlock_recursive_lock (rte_spinlock_recursive_t * slr) [inline], [static]

Take the recursive spinlock.

Parameters

slr A pointer to the recursive spinlock.

Definition at line 224 of file rte_spinlock.h.

static 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 241 of file rte_spinlock.h.

static __rte_warn_unused_result int rte_spinlock_recursive_trylock (rte_spinlock_recursive_t * slr) [inline], [static]

Try to take the recursive lock.

Parameters

slr A pointer to the recursive spinlock.

Returns

1 if the lock is successfully taken; 0 otherwise.

Definition at line 260 of file rte_spinlock.h.

static 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.

Parameters

slr A pointer to the recursive spinlock.

static 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.

static __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.

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.

Referenced By

The man pages rte_spinlock_init(3), RTE_SPINLOCK_INITIALIZER(3), rte_spinlock_is_locked(3), rte_spinlock_lock(3), rte_spinlock_lock_tm(3), rte_spinlock_recursive_init(3), RTE_SPINLOCK_RECURSIVE_INITIALIZER(3), rte_spinlock_recursive_lock(3), rte_spinlock_recursive_lock_tm(3), rte_spinlock_recursive_trylock(3), rte_spinlock_recursive_trylock_tm(3), rte_spinlock_recursive_unlock(3), rte_spinlock_recursive_unlock_tm(3), rte_spinlock_trylock(3), rte_spinlock_trylock_tm(3), rte_spinlock_unlock(3), rte_spinlock_unlock_tm(3) and rte_tm_supported(3) are aliases of rte_spinlock.h(3).

Version 23.11.0 DPDK