Sponsor:

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

rte_seqcount.h - Man Page

Synopsis

#include <stdbool.h>
#include <stdint.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_stdatomic.h>

Data Structures

struct rte_seqcount_t

Macros

#define RTE_SEQCOUNT_INITIALIZER   { .sn = 0 }

Functions

static void rte_seqcount_init (rte_seqcount_t *seqcount)
static uint32_t rte_seqcount_read_begin (const rte_seqcount_t *seqcount)
static bool rte_seqcount_read_retry (const rte_seqcount_t *seqcount, uint32_t begin_sn)
static void rte_seqcount_write_begin (rte_seqcount_t *seqcount)
static void rte_seqcount_write_end (rte_seqcount_t *seqcount)

Detailed Description

RTE Seqcount

The sequence counter synchronizes a single writer with multiple, parallel readers. It is used as the basis for the RTE sequence lock.

See also

rte_seqlock.h

Definition in file rte_seqcount.h.

Macro Definition Documentation

#define RTE_SEQCOUNT_INITIALIZER   { .sn = 0 }

A static seqcount initializer.

Definition at line 40 of file rte_seqcount.h.

Function Documentation

static void rte_seqcount_init (rte_seqcount_t * seqcount) [inline], [static]

Initialize the sequence counter.

Parameters

seqcount A pointer to the sequence counter.

Definition at line 49 of file rte_seqcount.h.

static uint32_t rte_seqcount_read_begin (const rte_seqcount_t * seqcount) [inline], [static]

Begin a read-side critical section.

A call to this function marks the beginning of a read-side critical section, for seqcount.

rte_seqcount_read_begin() returns a sequence number, which is later used in rte_seqcount_read_retry() to check if the protected data underwent any modifications during the read transaction.

After (in program order) rte_seqcount_read_begin() has been called, the calling thread reads the protected data, for later use. The protected data read must be copied (either in pristine form, or in the form of some derivative), since the caller may only read the data from within the read-side critical section (i.e., after rte_seqcount_read_begin() and before rte_seqcount_read_retry()), but must not act upon the retrieved data while in the critical section, since it does not yet know if it is consistent.

The protected data may be read using atomic and/or non-atomic operations.

After (in program order) all required data loads have been performed, rte_seqcount_read_retry() should be called, marking the end of the read-side critical section.

If rte_seqcount_read_retry() returns true, the just-read data is inconsistent and should be discarded. The caller has the option to either restart the whole procedure right away (i.e., calling rte_seqcount_read_begin() again), or do the same at some later time.

If rte_seqcount_read_retry() returns false, the data was read atomically and the copied data is consistent.

Parameters

seqcount A pointer to the sequence counter.

Returns

The seqcount sequence number for this critical section, to later be passed to rte_seqcount_read_retry().

See also

rte_seqcount_read_retry()

Definition at line 97 of file rte_seqcount.h.

static bool rte_seqcount_read_retry (const rte_seqcount_t * seqcount, uint32_t begin_sn) [inline], [static]

End a read-side critical section.

A call to this function marks the end of a read-side critical section, for seqcount. The application must supply the sequence number produced by the corresponding rte_seqcount_read_begin() call.

After this function has been called, the caller should not access the protected data.

In case rte_seqcount_read_retry() returns true, the just-read data was modified as it was being read and may be inconsistent, and thus should be discarded.

In case this function returns false, the data is consistent and the set of atomic and non-atomic load operations performed between rte_seqcount_read_begin() and rte_seqcount_read_retry() were atomic, as a whole.

Parameters

seqcount A pointer to the sequence counter.
begin_sn The sequence number returned by rte_seqcount_read_begin().

Returns

true or false, if the just-read seqcount-protected data was inconsistent or consistent, respectively, at the time it was read.

See also

rte_seqcount_read_begin()

Definition at line 137 of file rte_seqcount.h.

static void rte_seqcount_write_begin (rte_seqcount_t * seqcount) [inline], [static]

Begin a write-side critical section.

A call to this function marks the beginning of a write-side critical section, after which the caller may go on to modify (both read and write) the protected data, in an atomic or non-atomic manner.

After the necessary updates have been performed, the application calls rte_seqcount_write_end().

Multiple, parallel writers must use some external serialization.

This function is not preemption-safe in the sense that preemption of the calling thread may block reader progress until the writer thread is rescheduled.

Parameters

seqcount A pointer to the sequence counter.

See also

rte_seqcount_write_end()

Definition at line 182 of file rte_seqcount.h.

static void rte_seqcount_write_end (rte_seqcount_t * seqcount) [inline], [static]

End a write-side critical section.

A call to this function marks the end of the write-side critical section, for seqcount. After this call has been made, the protected data may no longer be modified.

Parameters

seqcount A pointer to the sequence counter.

See also

rte_seqcount_write_begin()

Definition at line 209 of file rte_seqcount.h.

Author

Generated automatically by Doxygen for DPDK from the source code.

Referenced By

The man pages rte_seqcount_init(3), RTE_SEQCOUNT_INITIALIZER(3), rte_seqcount_read_begin(3), rte_seqcount_read_retry(3), rte_seqcount_write_begin(3) and rte_seqcount_write_end(3) are aliases of rte_seqcount.h(3).

Version 23.11.0 DPDK