main loop of threads */
| 166 | |
| 167 | /* main loop of threads */ |
| 168 | __rte_noreturn uint32_t |
| 169 | eal_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); |
no test coverage detected