From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id B7495A0487 for ; Sun, 9 Jun 2019 00:23:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB24F1BD78; Sun, 9 Jun 2019 00:22:57 +0200 (CEST) Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by dpdk.org (Postfix) with ESMTP id D68F41BD27 for ; Sun, 9 Jun 2019 00:22:49 +0200 (CEST) Received: by mail-lf1-f66.google.com with SMTP id 136so4114484lfa.8 for ; Sat, 08 Jun 2019 15:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=Z0O2VKZma8y0COQpod10IIkJNUPgEfCBXA22Izo8oOY=; b=N2GPo3zl9OEJHDgjm1u0UifVLp8DDer4UtFHnslb3cTXr8jpWaoAvkh1SYW1smqByN UGfOTuzd1xvYnbc31VYKlHNV7j9w85EIQ9nuIbNFsYz8/HFf2w8wiZsI1caefi2fOt1m H9iY4u9RWgN473GI3TnSFLPlGZ191WtvHcQBVvkEFOgyqZ8lNvQyT4pGTn4b1pVS2xmZ NjKUOCohedyk+QveWePjJAK5Ps+m6M63AYKcP8nxJIWAr6SUkCSqf32797f53uBSMF5r O6Bh/7xFZb3/Zddwm9WBkuowSqkg0Pp0E7uR7VppmZPT5rKHeWl8sMy22rJ3Uit4asMP Sh9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Z0O2VKZma8y0COQpod10IIkJNUPgEfCBXA22Izo8oOY=; b=V7Y2TwYWhAoT8fIVbKqR5UONDgUHm1U6EFMrgYI7Co/DvHuPF+HjslpEEWvC8EJVQJ 5mweU1PJzKo3FCfOmJ39b36mmqwIRvTYMxT7+BV3Y7pnEAJwdYoTkHZBV5xkmi2FR7Cf ErbOZEIEM/wWv0bDDxQvgrrP4flj6jUR2gq5KRPk/qj7vX/j/RN9p7iQBJ0luuy7smjC L/R0IIiixeHv/pfzN9nV3nm/RgcQqkGWOQK3RIkgnc1FripzmeALjyk6mhasqldDOvNE P80xbERt/1yZfZCst+ONAY4pVfxcumSAbz35fX6llm3ihnDpkWKCgZlkbOby7YM39jCA /ExA== X-Gm-Message-State: APjAAAWBFxQqXj29QPvxgTFRWWgMjBFuL2YggwXOx0FSQmGSxdIFx4k6 UCFbSFFp8gUmrqKNzEy4XreErM2Csyg= X-Google-Smtp-Source: APXvYqxKsDk8GWuwEU+aPHOoeP7Qm7j1Eo94GtYQKi8xtO0qkBivTW2apemVI3u4kLApjV9RyAzO+g== X-Received: by 2002:ac2:5446:: with SMTP id d6mr29873095lfn.138.1560032569281; Sat, 08 Jun 2019 15:22:49 -0700 (PDT) Received: from tj-idea-500s.lan (user-5-173-144-53.play-internet.pl. [5.173.144.53]) by smtp.gmail.com with ESMTPSA id w28sm1060597ljd.12.2019.06.08.15.22.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 08 Jun 2019 15:22:48 -0700 (PDT) From: Tomasz Jozwiak To: dev@dpdk.org, fiona.trahe@intel.com, tjozwiakgm@gmail.com, shallyv@marvell.com Date: Sun, 9 Jun 2019 00:22:32 +0200 Message-Id: <1560032553-15528-7-git-send-email-tjozwiakgm@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560032553-15528-1-git-send-email-tjozwiakgm@gmail.com> References: <1559203588-24046-1-git-send-email-tomaszx.jozwiak@intel.com> <1560032553-15528-1-git-send-email-tjozwiakgm@gmail.com> Subject: [dpdk-dev] [PATCH v2 6/7] app/test-compress-perf: add force process termination X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Tomasz Jozwiak This patch adds a possibility to force controlled process termination as a result of two signals: SIGTERM and SIGINT Signed-off-by: Tomasz Jozwiak --- app/test-compress-perf/comp_perf_options.h | 1 + app/test-compress-perf/comp_perf_test_benchmark.c | 13 ++++++++++++ app/test-compress-perf/comp_perf_test_verify.c | 14 ++++++++++++ app/test-compress-perf/main.c | 26 +++++++++++++++++++++-- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h index 79e63d5..534212d 100644 --- a/app/test-compress-perf/comp_perf_options.h +++ b/app/test-compress-perf/comp_perf_options.h @@ -68,6 +68,7 @@ struct comp_test_data { double ratio; enum cleanup_st cleanup; + int perf_comp_force_stop; }; int diff --git a/app/test-compress-perf/comp_perf_test_benchmark.c b/app/test-compress-perf/comp_perf_test_benchmark.c index 9b0b146..b38b33c 100644 --- a/app/test-compress-perf/comp_perf_test_benchmark.c +++ b/app/test-compress-perf/comp_perf_test_benchmark.c @@ -183,6 +183,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); @@ -241,6 +244,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, @@ -305,6 +311,13 @@ main_loop(struct cperf_benchmark_ctx *ctx, enum rte_comp_xform_type type) 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; } diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c index c2aab70..b2cd7a0 100644 --- a/app/test-compress-perf/comp_perf_test_verify.c +++ b/app/test-compress-perf/comp_perf_test_verify.c @@ -187,6 +187,9 @@ main_loop(struct cperf_verify_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); @@ -267,6 +270,9 @@ main_loop(struct cperf_verify_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, @@ -345,6 +351,14 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type) 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; } diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c index f8e5f15..a9022f6 100644 --- a/app/test-compress-perf/main.c +++ b/app/test-compress-perf/main.c @@ -2,6 +2,10 @@ * Copyright(c) 2018 Intel Corporation */ +#include +#include +#include + #include #include #include @@ -42,6 +46,8 @@ static const struct cperf_test cperf_testmap[] = { } }; +static struct comp_test_data *test_data; + static int comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) { @@ -283,12 +289,24 @@ comp_perf_dump_input_data(struct comp_test_data *test_data) return ret; } +static void +comp_perf_cleanup_on_signal(int signalNumber __rte_unused) +{ + test_data->perf_comp_force_stop = 1; +} + +static void +comp_perf_register_cleanup_on_signal(void) +{ + signal(SIGTERM, comp_perf_cleanup_on_signal); + signal(SIGINT, comp_perf_cleanup_on_signal); +} + int main(int argc, char **argv) { uint8_t level_idx = 0; int ret, i; - struct comp_test_data *test_data; void *ctx[RTE_MAX_LCORE] = {}; uint8_t enabled_cdevs[RTE_COMPRESS_MAX_DEVS]; int nb_compressdevs = 0; @@ -310,6 +328,8 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Cannot reserve memory in socket %d\n", rte_socket_id()); + comp_perf_register_cleanup_on_signal(); + ret = EXIT_SUCCESS; test_data->cleanup = ST_TEST_DATA; comp_perf_options_default(test_data); @@ -429,8 +449,10 @@ main(int argc, char **argv) /* fallthrough */ case ST_COMPDEV: for (i = 0; i < nb_compressdevs && - i < RTE_COMPRESS_MAX_DEVS; i++) + i < RTE_COMPRESS_MAX_DEVS; i++) { rte_compressdev_stop(enabled_cdevs[i]); + rte_compressdev_close(enabled_cdevs[i]); + } /* fallthrough */ case ST_TEST_DATA: rte_free(test_data); -- 2.7.4