* - There is a global pflock and a table of pflocks (one per lcore). * * - The test function takes all of these locks and launches the * ``test_pflock_per_core()`` function on each core (except the main). * * - The function takes the global write lock, display something, * then releases the global lock. * - Then, it takes the per-lcore write lock, display something, and * rel
| 158 | * message. The autotest script checks that the message order is correct. |
| 159 | */ |
| 160 | static int |
| 161 | test_pflock(void) |
| 162 | { |
| 163 | int i; |
| 164 | |
| 165 | rte_pflock_init(&sl); |
| 166 | for (i = 0; i < RTE_MAX_LCORE; i++) |
| 167 | rte_pflock_init(&sl_tab[i]); |
| 168 | |
| 169 | rte_pflock_write_lock(&sl); |
| 170 | |
| 171 | RTE_LCORE_FOREACH_WORKER(i) { |
| 172 | rte_pflock_write_lock(&sl_tab[i]); |
| 173 | rte_eal_remote_launch(test_pflock_per_core, NULL, i); |
| 174 | } |
| 175 | |
| 176 | rte_pflock_write_unlock(&sl); |
| 177 | |
| 178 | RTE_LCORE_FOREACH_WORKER(i) { |
| 179 | rte_pflock_write_unlock(&sl_tab[i]); |
| 180 | rte_delay_ms(100); |
| 181 | } |
| 182 | |
| 183 | rte_pflock_write_lock(&sl); |
| 184 | /* this message should be the last message of test */ |
| 185 | printf("Global write lock taken on main core %u\n", rte_lcore_id()); |
| 186 | rte_pflock_write_unlock(&sl); |
| 187 | |
| 188 | rte_eal_mp_wait_lcore(); |
| 189 | |
| 190 | if (test_pflock_perf() < 0) |
| 191 | return -1; |
| 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | REGISTER_FAST_TEST(pflock_autotest, true, true, test_pflock); |
nothing calls this directly
no test coverage detected