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

Function eal_thread_loop

dpdk/lib/eal/common/eal_common_thread.c:168–230  ·  view source on GitHub ↗

main loop of threads */

Source from the content-addressed store, hash-verified

166
167/* main loop of threads */
168__rte_noreturn uint32_t
169eal_thread_loop(void *arg)
170{
171 unsigned int lcore_id = (uintptr_t)arg;
172 char cpuset[RTE_CPU_AFFINITY_STR_LEN];
173 int ret;
174
175 __rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset);
176
177 ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
178 RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
179 lcore_id, rte_thread_self().opaque_id, cpuset,
180 ret == 0 ? "" : "...");
181
182 rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
183
184 /* read on our pipe to get commands */
185 while (1) {
186 lcore_function_t *f;
187 void *fct_arg;
188
189 eal_thread_wait_command();
190
191 /* Set the state to 'RUNNING'. Use release order
192 * since 'state' variable is used as the guard variable.
193 */
194 rte_atomic_store_explicit(&lcore_config[lcore_id].state, RUNNING,
195 rte_memory_order_release);
196
197 eal_thread_ack_command();
198
199 /* Load 'f' with acquire order to ensure that
200 * the memory operations from the main thread
201 * are accessed only after update to 'f' is visible.
202 * Wait till the update to 'f' is visible to the worker.
203 */
204 while ((f = rte_atomic_load_explicit(&lcore_config[lcore_id].f,
205 rte_memory_order_acquire)) == NULL)
206 rte_pause();
207
208 rte_eal_trace_thread_lcore_running(lcore_id, f);
209
210 /* call the function and store the return value */
211 fct_arg = lcore_config[lcore_id].arg;
212 ret = f(fct_arg);
213 lcore_config[lcore_id].ret = ret;
214 lcore_config[lcore_id].f = NULL;
215 lcore_config[lcore_id].arg = NULL;
216
217 /* Store the state with release order to ensure that
218 * the memory operations from the worker thread
219 * are completed before the state is updated.
220 * Use 'state' as the guard variable.
221 */
222 rte_atomic_store_explicit(&lcore_config[lcore_id].state, WAIT,
223 rte_memory_order_release);
224
225 rte_eal_trace_thread_lcore_stopped(lcore_id);

Callers 1

eal_worker_thread_loopFunction · 0.85

Calls 6

__rte_thread_initFunction · 0.85
rte_thread_selfFunction · 0.50
eal_thread_wait_commandFunction · 0.50
eal_thread_ack_commandFunction · 0.50
rte_pauseFunction · 0.50

Tested by

no test coverage detected