MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_pflock_write_lock

Function rte_pflock_write_lock

dpdk/lib/eal/include/rte_pflock.h:138–164  ·  view source on GitHub ↗

* Take the pflock for write. * * @param pf * A pointer to the pflock structure. */

Source from the content-addressed store, hash-verified

136 * A pointer to the pflock structure.
137 */
138static inline void
139rte_pflock_write_lock(rte_pflock_t *pf)
140{
141 uint16_t ticket, w;
142
143 /* Acquire ownership of write-phase.
144 * This is same as rte_ticketlock_lock().
145 */
146 ticket = rte_atomic_fetch_add_explicit(&pf->wr.in, 1, rte_memory_order_relaxed);
147 rte_wait_until_equal_16((uint16_t *)(uintptr_t)&pf->wr.out, ticket,
148 rte_memory_order_acquire);
149
150 /*
151 * Acquire ticket on read-side in order to allow them
152 * to flush. Indicates to any incoming reader that a
153 * write-phase is pending.
154 *
155 * The load of rd.out in wait loop could be executed
156 * speculatively.
157 */
158 w = RTE_PFLOCK_PRES | (ticket & RTE_PFLOCK_PHID);
159 ticket = rte_atomic_fetch_add_explicit(&pf->rd.in, w, rte_memory_order_relaxed);
160
161 /* Wait for any pending readers to flush. */
162 rte_wait_until_equal_16((uint16_t *)(uintptr_t)&pf->rd.out, ticket,
163 rte_memory_order_acquire);
164}
165
166/**
167 * Release a pflock held for writing.

Callers 3

test_pflock_per_coreFunction · 0.85
load_loop_fnFunction · 0.85
test_pflockFunction · 0.85

Calls 1

rte_wait_until_equal_16Function · 0.50

Tested by 3

test_pflock_per_coreFunction · 0.68
load_loop_fnFunction · 0.68
test_pflockFunction · 0.68