- printf("\nPerf test: 2 writers, %d readers, RCU integration enabled\n",
- num_cores - 2);
-
- /* Create LPM table */
- config.max_rules = NUM_LDEPTH_ROUTE_ENTRIES;
- config.number_tbl8s = NUM_LDEPTH_ROUTE_ENTRIES;
- config.flags = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
- TEST_LPM_ASSERT(lpm != NULL);
-
- /* Init RCU variable */
- sz = rte_rcu_qsbr_get_memsize(num_cores);
- rv = (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz,
- RTE_CACHE_LINE_SIZE);
- rte_rcu_qsbr_init(rv, num_cores);
-
- rcu_cfg.v = rv;
- /* Assign the RCU variable to LPM */
- if (rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg) != 0) {
- printf("RCU variable assignment failed\n");
- goto error;
- }
-
- writer_done = 0;
- __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
-
- __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
-
- /* Launch reader threads */
- for (i = 2; i < num_cores; i++)
- rte_eal_remote_launch(test_lpm_rcu_qsbr_reader, NULL,
- enabled_core_ids[i]);
-
- /* Launch writer threads */
- for (i = 0; i < 2; i++)
- rte_eal_remote_launch(test_lpm_rcu_qsbr_writer,
- (void *)(uintptr_t)i,
- enabled_core_ids[i]);
-
- /* Wait for writer threads */
- for (i = 0; i < 2; i++)
- if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
- goto error;
-
- printf("Total LPM Adds: %d\n", TOTAL_WRITES);
- printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
- printf("Average LPM Add/Del: %"PRIu64" cycles\n",
- __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED)
- / TOTAL_WRITES);
-
- writer_done = 1;
- /* Wait until all readers have exited */
- for (i = 2; i < num_cores; i++)
- rte_eal_wait_lcore(enabled_core_ids[i]);
-
- rte_lpm_free(lpm);
- rte_free(rv);
- lpm = NULL;
- rv = NULL;
-
- /* Test without RCU integration */
- printf("\nPerf test: 2 writers, %d readers, RCU integration disabled\n",
- num_cores - 2);
-
- /* Create LPM table */
- config.max_rules = NUM_LDEPTH_ROUTE_ENTRIES;
- config.number_tbl8s = NUM_LDEPTH_ROUTE_ENTRIES;
- config.flags = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
- TEST_LPM_ASSERT(lpm != NULL);
-
- writer_done = 0;
- __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
- __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
-
- /* Launch reader threads */
- for (i = 2; i < num_cores; i++)
- rte_eal_remote_launch(test_lpm_reader, NULL,
- enabled_core_ids[i]);
-
- /* Launch writer threads */
- for (i = 0; i < 2; i++)
- rte_eal_remote_launch(test_lpm_rcu_qsbr_writer,
- (void *)(uintptr_t)i,
- enabled_core_ids[i]);
-
- /* Wait for writer threads */
- for (i = 0; i < 2; i++)
- if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
- goto error;
-
- printf("Total LPM Adds: %d\n", TOTAL_WRITES);
- printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
- printf("Average LPM Add/Del: %"PRIu64" cycles\n",
- __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED)
- / TOTAL_WRITES);
-
- writer_done = 1;
- /* Wait until all readers have exited */
- for (i = 2; i < num_cores; i++)
- rte_eal_wait_lcore(enabled_core_ids[i]);
-
- rte_lpm_free(lpm);
-
- return 0;
-
-error:
- writer_done = 1;
- /* Wait until all readers have exited */
- rte_eal_mp_wait_lcore();
-
- rte_lpm_free(lpm);
- rte_free(rv);
-
- return -1;
-}
-
-/*
- * Functional test:
- * Single writer, rest are readers
- */
-static int
-test_lpm_rcu_perf(void)
-{
- struct rte_lpm_config config;
- uint64_t begin, total_cycles;
- size_t sz;
- unsigned int i, j;
- uint16_t core_id;
- uint32_t next_hop_add = 0xAA;
- struct rte_lpm_rcu_config rcu_cfg = {0};
-
- if (rte_lcore_count() < 2) {
- printf("Not enough cores for lpm_rcu_perf_autotest, expecting at least 2\n");
- return TEST_SKIPPED;
- }
-
- num_cores = 0;
- RTE_LCORE_FOREACH_WORKER(core_id) {
- enabled_core_ids[num_cores] = core_id;
- num_cores++;
- }
-
- printf("\nPerf test: 1 writer, %d readers, RCU integration enabled\n",
- num_cores);
-
- /* Create LPM table */
- config.max_rules = NUM_LDEPTH_ROUTE_ENTRIES;
- config.number_tbl8s = NUM_LDEPTH_ROUTE_ENTRIES;
- config.flags = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
- TEST_LPM_ASSERT(lpm != NULL);
-
- /* Init RCU variable */
- sz = rte_rcu_qsbr_get_memsize(num_cores);
- rv = (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz,
- RTE_CACHE_LINE_SIZE);
- rte_rcu_qsbr_init(rv, num_cores);
-
- rcu_cfg.v = rv;
- /* Assign the RCU variable to LPM */
- if (rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg) != 0) {
- printf("RCU variable assignment failed\n");
- goto error;
- }
-
- writer_done = 0;
- __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
-
- /* Launch reader threads */
- for (i = 0; i < num_cores; i++)
- rte_eal_remote_launch(test_lpm_rcu_qsbr_reader, NULL,
- enabled_core_ids[i]);
-
- /* Measure add/delete. */
- begin = rte_rdtsc_precise();
- for (i = 0; i < RCU_ITERATIONS; i++) {
- /* Add all the entries */
- for (j = 0; j < NUM_LDEPTH_ROUTE_ENTRIES; j++)
- if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
- large_ldepth_route_table[j].depth,
- next_hop_add) != 0) {
- printf("Failed to add iteration %d, route# %d\n",
- i, j);
+ for (j = 1; j < 3; j++) {
+ if (use_rcu)
+ printf("\nPerf test: %d writer(s), %d reader(s),"
+ " RCU integration enabled\n", j, num_cores - j);
+ else
+ printf("\nPerf test: %d writer(s), %d reader(s),"
+ " RCU integration disabled\n", j, num_cores - j);
+
+ num_writers = j;
+
+ /* Create LPM table */
+ config.max_rules = NUM_LDEPTH_ROUTE_ENTRIES;
+ config.number_tbl8s = NUM_LDEPTH_ROUTE_ENTRIES;
+ config.flags = 0;
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
+ TEST_LPM_ASSERT(lpm != NULL);
+
+ /* Init RCU variable */
+ if (use_rcu) {
+ sz = rte_rcu_qsbr_get_memsize(num_cores);
+ rv = (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz,
+ RTE_CACHE_LINE_SIZE);
+ rte_rcu_qsbr_init(rv, num_cores);
+
+ rcu_cfg.v = rv;
+ /* Assign the RCU variable to LPM */
+ if (rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg) != 0) {
+ printf("RCU variable assignment failed\n");