| 128 | } |
| 129 | |
| 130 | static int |
| 131 | test_ticketlock_perf(void) |
| 132 | { |
| 133 | unsigned int i; |
| 134 | uint64_t tcount = 0; |
| 135 | uint64_t total_time = 0; |
| 136 | int lock = 0; |
| 137 | const unsigned int lcore = rte_lcore_id(); |
| 138 | |
| 139 | printf("\nTest with no lock on single core...\n"); |
| 140 | load_loop_fn(&lock); |
| 141 | printf("Core [%u] cost time = %"PRIu64" us\n", lcore, time_cost[lcore]); |
| 142 | memset(lcore_count, 0, sizeof(lcore_count)); |
| 143 | memset(time_cost, 0, sizeof(time_cost)); |
| 144 | |
| 145 | printf("\nTest with lock on single core...\n"); |
| 146 | lock = 1; |
| 147 | load_loop_fn(&lock); |
| 148 | printf("Core [%u] cost time = %"PRIu64" us\n", lcore, time_cost[lcore]); |
| 149 | memset(lcore_count, 0, sizeof(lcore_count)); |
| 150 | memset(time_cost, 0, sizeof(time_cost)); |
| 151 | |
| 152 | lcount = 0; |
| 153 | printf("\nTest with lock on %u cores...\n", rte_lcore_count()); |
| 154 | |
| 155 | /* Clear synchro and start workers */ |
| 156 | __atomic_store_n(&synchro, 0, __ATOMIC_RELAXED); |
| 157 | rte_eal_mp_remote_launch(load_loop_fn, &lock, SKIP_MAIN); |
| 158 | |
| 159 | /* start synchro and launch test on main */ |
| 160 | __atomic_store_n(&synchro, 1, __ATOMIC_RELAXED); |
| 161 | load_loop_fn(&lock); |
| 162 | |
| 163 | rte_eal_mp_wait_lcore(); |
| 164 | |
| 165 | RTE_LCORE_FOREACH(i) { |
| 166 | printf("Core [%u] cost time = %"PRIu64" us\n", i, time_cost[i]); |
| 167 | tcount += lcore_count[i]; |
| 168 | total_time += time_cost[i]; |
| 169 | } |
| 170 | |
| 171 | if (tcount != lcount) |
| 172 | return -1; |
| 173 | |
| 174 | printf("Total cost time = %"PRIu64" us\n", total_time); |
| 175 | |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | /* |
| 180 | * Use rte_ticketlock_trylock() to trylock a ticketlock object, |
no test coverage detected