mempool: fix slow allocation of large mempools
[dpdk.git] / app / test-compress-perf / comp_perf_test_benchmark.c
index e0f852b..0c6bb9b 100644 (file)
@@ -15,7 +15,8 @@ cperf_benchmark_test_destructor(void *arg)
 {
        if (arg) {
                comp_perf_free_memory(
-                               &((struct cperf_benchmark_ctx *)arg)->ver.mem);
+                       ((struct cperf_benchmark_ctx *)arg)->ver.options,
+                       &((struct cperf_benchmark_ctx *)arg)->ver.mem);
                rte_free(arg);
        }
 }
@@ -184,6 +185,9 @@ main_loop(struct cperf_benchmark_ctx *ctx, enum rte_comp_xform_type type)
                                ops[op_id]->private_xform = priv_xform;
                        }
 
+                       if (unlikely(test_data->perf_comp_force_stop))
+                               goto end;
+
                        num_enq = rte_compressdev_enqueue_burst(dev_id,
                                                                mem->qp_id, ops,
                                                                num_ops);
@@ -242,6 +246,9 @@ main_loop(struct cperf_benchmark_ctx *ctx, enum rte_comp_xform_type type)
 
                /* Dequeue the last operations */
                while (total_deq_ops < total_ops) {
+                       if (unlikely(test_data->perf_comp_force_stop))
+                               goto end;
+
                        num_deq = rte_compressdev_dequeue_burst(dev_id,
                                                           mem->qp_id,
                                                           deq_ops,
@@ -306,6 +313,13 @@ end:
        rte_mempool_put_bulk(mem->op_pool, (void **)ops, allocated);
        rte_compressdev_private_xform_free(dev_id, priv_xform);
        rte_free(ops);
+
+       if (test_data->perf_comp_force_stop) {
+               RTE_LOG(ERR, USER1,
+                     "lcore: %d Perf. test has been aborted by user\n",
+                       mem->lcore_id);
+               res = -1;
+       }
        return res;
 }
 
@@ -316,9 +330,26 @@ cperf_benchmark_test_runner(void *test_ctx)
        struct comp_test_data *test_data = ctx->ver.options;
        uint32_t lcore = rte_lcore_id();
        static rte_atomic16_t display_once = RTE_ATOMIC16_INIT(0);
+       int i, ret = EXIT_SUCCESS;
 
        ctx->ver.mem.lcore_id = lcore;
-       int i, ret = EXIT_SUCCESS;
+
+       /*
+        * printing information about current compression thread
+        */
+       if (rte_atomic16_test_and_set(&ctx->ver.mem.print_info_once))
+               printf("    lcore: %u,"
+                               " driver name: %s,"
+                               " device name: %s,"
+                               " device id: %u,"
+                               " socket id: %u,"
+                               " queue pair id: %u\n",
+                       lcore,
+                       ctx->ver.options->driver_name,
+                       rte_compressdev_name_get(ctx->ver.mem.dev_id),
+                       ctx->ver.mem.dev_id,
+                       rte_compressdev_socket_id(ctx->ver.mem.dev_id),
+                       ctx->ver.mem.qp_id);
 
        /*
         * First the verification part is needed
@@ -361,7 +392,7 @@ cperf_benchmark_test_runner(void *test_ctx)
                        1000000000;
 
        if (rte_atomic16_test_and_set(&display_once)) {
-               printf("%12s%6s%12s%17s%15s%16s\n",
+               printf("\n%12s%6s%12s%17s%15s%16s\n",
                        "lcore id", "Level", "Comp size", "Comp ratio [%]",
                        "Comp [Gbps]", "Decomp [Gbps]");
        }