| 91 | } |
| 92 | |
| 93 | static int |
| 94 | test_pflock_perf(void) |
| 95 | { |
| 96 | unsigned int i; |
| 97 | int lock = 0; |
| 98 | uint64_t total = 0; |
| 99 | const unsigned int lcore = rte_lcore_id(); |
| 100 | |
| 101 | printf("\nTest with no lock on single core...\n"); |
| 102 | __atomic_store_n(&synchro, 1, __ATOMIC_RELAXED); |
| 103 | load_loop_fn(&lock); |
| 104 | printf("Core [%u] Cost Time = %"PRIu64" us\n", |
| 105 | lcore, time_count[lcore]); |
| 106 | memset(time_count, 0, sizeof(time_count)); |
| 107 | |
| 108 | printf("\nTest with phase-fair lock on single core...\n"); |
| 109 | lock = 1; |
| 110 | __atomic_store_n(&synchro, 1, __ATOMIC_RELAXED); |
| 111 | load_loop_fn(&lock); |
| 112 | printf("Core [%u] Cost Time = %"PRIu64" us\n", |
| 113 | lcore, time_count[lcore]); |
| 114 | memset(time_count, 0, sizeof(time_count)); |
| 115 | |
| 116 | printf("\nPhase-fair test on %u cores...\n", rte_lcore_count()); |
| 117 | |
| 118 | /* clear synchro and start workers */ |
| 119 | __atomic_store_n(&synchro, 0, __ATOMIC_RELAXED); |
| 120 | if (rte_eal_mp_remote_launch(load_loop_fn, &lock, SKIP_MAIN) < 0) |
| 121 | return -1; |
| 122 | |
| 123 | /* start synchro and launch test on main */ |
| 124 | __atomic_store_n(&synchro, 1, __ATOMIC_RELAXED); |
| 125 | load_loop_fn(&lock); |
| 126 | |
| 127 | rte_eal_mp_wait_lcore(); |
| 128 | |
| 129 | RTE_LCORE_FOREACH(i) { |
| 130 | printf("Core [%u] cost time = %"PRIu64" us\n", |
| 131 | i, time_count[i]); |
| 132 | total += time_count[i]; |
| 133 | } |
| 134 | |
| 135 | printf("Total cost time = %"PRIu64" us\n", total); |
| 136 | memset(time_count, 0, sizeof(time_count)); |
| 137 | |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | /* |
| 142 | * - There is a global pflock and a table of pflocks (one per lcore). |
no test coverage detected