DPDK 22.11.5
|
#include <stdbool.h>
#include <stdint.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_compat.h>
Go to the source code of this file.
Data Structures | |
struct | rte_seqcount_t |
Macros | |
#define | RTE_SEQCOUNT_INITIALIZER { .sn = 0 } |
Functions | |
static __rte_experimental void | rte_seqcount_init (rte_seqcount_t *seqcount) |
static __rte_experimental uint32_t | rte_seqcount_read_begin (const rte_seqcount_t *seqcount) |
static __rte_experimental bool | rte_seqcount_read_retry (const rte_seqcount_t *seqcount, uint32_t begin_sn) |
static __rte_experimental void | rte_seqcount_write_begin (rte_seqcount_t *seqcount) |
static __rte_experimental void | rte_seqcount_write_end (rte_seqcount_t *seqcount) |
RTE Seqcount
The sequence counter synchronizes a single writer with multiple, parallel readers. It is used as the basis for the RTE sequence lock.
Definition in file rte_seqcount.h.
#define RTE_SEQCOUNT_INITIALIZER { .sn = 0 } |
A static seqcount initializer.
Definition at line 40 of file rte_seqcount.h.
|
inlinestatic |
Initialize the sequence counter.
seqcount | A pointer to the sequence counter. |
Definition at line 53 of file rte_seqcount.h.
|
inlinestatic |
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.
seqcount | A pointer to the sequence counter. |
Definition at line 106 of file rte_seqcount.h.
|
inlinestatic |
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.
seqcount | A pointer to the sequence counter. |
begin_sn | The sequence number returned by rte_seqcount_read_begin(). |
Definition at line 151 of file rte_seqcount.h.
|
inlinestatic |
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.
seqcount | A pointer to the sequence counter. |
Definition at line 201 of file rte_seqcount.h.
|
inlinestatic |
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.
seqcount | A pointer to the sequence counter. |
Definition at line 232 of file rte_seqcount.h.