From patchwork Fri Oct 16 06:03:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 317800 Delivered-To: patch@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp1154511ilm; Thu, 15 Oct 2020 23:04:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWFBS0x0igRAKm/lPGcul4sulQ1zsZZB5RzNUxiu971id4tTniZ2druFd1qXQYRQ8corZ2 X-Received: by 2002:a17:906:c444:: with SMTP id ck4mr1986258ejb.398.1602828250039; Thu, 15 Oct 2020 23:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602828250; cv=none; d=google.com; s=arc-20160816; b=n9bng7zyz+LgzIRquJrh9R5VvyzwHsur/2n+d47bXQKKnS3OMJmmlXZ3RgClisz31u iKJ2H2oTsxQ6SLVIA4iRefO774OHYyS1ZOS4V6THQctpMYDfAAG8DWtcs2UDhJ7pyIWa GxX6U3v7J0ugQDkw8NH6RHFocgaYW0RVjfuJT/hom/HH7Fu1ZA2HPXyyJRlRoamySS/D xH0T6lDdcMmgsJ43yyGdCWFDyaCX4XEE/leqlmErKaFPAaGQCDJDr2cCABDiKYiUzlZW EvGdCpnRicCt/RnzadBFXEbKm7wTMg8TTYPvMR91u2TaDPUHQ9zH7BsXjHNfuAIzCy6F LJZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:cc:to :from; bh=HdGCCiDNxZbfFiehRl0Xyj6ImK1Ybm5iis6VCl3SJoE=; b=Y14epdtpLjOB3w9/nwYDqKdHAiko6n8aZIA8XC0QQ77JcfQ6bzUNXmjY8YNrZ2wVOG w2FaDGmpd7V5J90KsiUh82+L9Xgc8QnOMHMn6fymArUa1im3VSmLNNZMVQZT9Dnfm6JV H6jZiwaJG2BSMoCX0WhosdWNZYRCsk4WX2E2scYKppJQARP+5Wqm7kFELPLhK2Ft6Qat qwe4MyfEja7iZ84ALqEnyqxN+fWj6z3Uvjg20XSQZ+nwFB0Hh0tvcn1GJEl3lFTADkux xDsJxXeFRnUm6M8JeBqwRoQ1usaZkiR0aWNrgFjK2TteQgY6BWNe46ls5XiGBbkb6yCj F2Uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id a1si1024719ejt.206.2020.10.15.23.04.09; Thu, 15 Oct 2020 23:04:10 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 553581EA65; Fri, 16 Oct 2020 08:04:04 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 5672A1EA5E; Fri, 16 Oct 2020 08:04:01 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BCFA130E; Thu, 15 Oct 2020 23:03:59 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A78E73F66B; Thu, 15 Oct 2020 23:03:59 -0700 (PDT) From: Honnappa Nagarahalli To: dev@dpdk.org, honnappa.nagarahalli@arm.com, john.mcnamara@intel.com Cc: ruifeng.wang@arm.com, juraj.linkes@pantheon.tech, david.marchand@redhat.com, nd@arm.com, stable@dpdk.org Date: Fri, 16 Oct 2020 01:03:48 -0500 Message-Id: <20201016060349.19940-1-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH 1/2] test/rcu: fix array subscript is above array bounds 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" When RTE_MAX_LCORE value is small, following compiler errors are observed. ../app/test/test_rcu_qsbr.c:296:54: error: iteration 2 invokes undefined behavior [-Werror=aggressive-loop-optimizations] ../app/test/test_rcu_qsbr.c:315:55: error: array subscript is above array bounds [-Werror=array-bounds] Fixes: b87089b0bb19 ("test/rcu: add API and functional tests") Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Ruifeng Wang --- app/test/test_rcu_qsbr.c | 56 +++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 23 deletions(-) -- 2.17.1 Tested-by: Lukasz Wojciechowski Reviewed-by: Lukasz Wojciechowski Tested-by: Lukasz Wojciechowski Reviewed-by: Lukasz Wojciechowski diff --git a/app/test/test_rcu_qsbr.c b/app/test/test_rcu_qsbr.c index 0a9e5ecd1..848a68092 100644 --- a/app/test/test_rcu_qsbr.c +++ b/app/test/test_rcu_qsbr.c @@ -286,13 +286,13 @@ static int test_rcu_qsbr_start(void) { uint64_t token; - int i; + unsigned int i; printf("\nTest rte_rcu_qsbr_start()\n"); rte_rcu_qsbr_init(t[0], RTE_MAX_LCORE); - for (i = 0; i < 3; i++) + for (i = 0; i < num_cores; i++) rte_rcu_qsbr_thread_register(t[0], enabled_core_ids[i]); token = rte_rcu_qsbr_start(t[0]); @@ -306,14 +306,18 @@ test_rcu_qsbr_check_reader(void *arg) { struct rte_rcu_qsbr *temp; uint8_t read_type = (uint8_t)((uintptr_t)arg); + unsigned int i; temp = t[read_type]; /* Update quiescent state counter */ - rte_rcu_qsbr_quiescent(temp, enabled_core_ids[0]); - rte_rcu_qsbr_quiescent(temp, enabled_core_ids[1]); - rte_rcu_qsbr_thread_unregister(temp, enabled_core_ids[2]); - rte_rcu_qsbr_quiescent(temp, enabled_core_ids[3]); + for (i = 0; i < num_cores; i++) { + if (i % 2 == 0) + rte_rcu_qsbr_quiescent(temp, enabled_core_ids[i]); + else + rte_rcu_qsbr_thread_unregister(temp, + enabled_core_ids[i]); + } return 0; } @@ -324,7 +328,8 @@ test_rcu_qsbr_check_reader(void *arg) static int test_rcu_qsbr_check(void) { - int i, ret; + int ret; + unsigned int i; uint64_t token; printf("\nTest rte_rcu_qsbr_check()\n"); @@ -342,7 +347,7 @@ test_rcu_qsbr_check(void) ret = rte_rcu_qsbr_check(t[0], token, true); TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Blocking QSBR check"); - for (i = 0; i < 3; i++) + for (i = 0; i < num_cores; i++) rte_rcu_qsbr_thread_register(t[0], enabled_core_ids[i]); ret = rte_rcu_qsbr_check(t[0], token, false); @@ -357,7 +362,7 @@ test_rcu_qsbr_check(void) /* Threads are offline, hence this should pass */ TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Non-blocking QSBR check"); - for (i = 0; i < 3; i++) + for (i = 0; i < num_cores; i++) rte_rcu_qsbr_thread_unregister(t[0], enabled_core_ids[i]); ret = rte_rcu_qsbr_check(t[0], token, true); @@ -365,7 +370,7 @@ test_rcu_qsbr_check(void) rte_rcu_qsbr_init(t[0], RTE_MAX_LCORE); - for (i = 0; i < 4; i++) + for (i = 0; i < num_cores; i++) rte_rcu_qsbr_thread_register(t[0], enabled_core_ids[i]); token = rte_rcu_qsbr_start(t[0]); @@ -928,7 +933,7 @@ test_rcu_qsbr_dq_functional(int32_t size, int32_t esize, uint32_t flags) static int test_rcu_qsbr_dump(void) { - int i; + unsigned int i; printf("\nTest rte_rcu_qsbr_dump()\n"); @@ -945,7 +950,7 @@ test_rcu_qsbr_dump(void) rte_rcu_qsbr_thread_register(t[0], enabled_core_ids[0]); - for (i = 1; i < 3; i++) + for (i = 1; i < num_cores; i++) rte_rcu_qsbr_thread_register(t[1], enabled_core_ids[i]); rte_rcu_qsbr_dump(stdout, t[0]); @@ -1095,7 +1100,7 @@ test_rcu_qsbr_sw_sv_3qs(void) { uint64_t token[3]; uint32_t c; - int i; + int i, num_readers; int32_t pos[3]; writer_done = 0; @@ -1118,7 +1123,11 @@ test_rcu_qsbr_sw_sv_3qs(void) thread_info[0].ih = 0; /* Reader threads are launched */ - for (i = 0; i < 4; i++) + /* Keep the number of reader threads low to reduce + * the execution time. + */ + num_readers = num_cores < 4 ? num_cores : 4; + for (i = 0; i < num_readers; i++) rte_eal_remote_launch(test_rcu_qsbr_reader, &thread_info[0], enabled_core_ids[i]); @@ -1151,7 +1160,7 @@ test_rcu_qsbr_sw_sv_3qs(void) /* Check the quiescent state status */ rte_rcu_qsbr_check(t[0], token[0], true); - for (i = 0; i < 4; i++) { + for (i = 0; i < num_readers; i++) { c = hash_data[0][0][enabled_core_ids[i]]; if (c != COUNTER_VALUE && c != 0) { printf("Reader lcore %d did not complete #0 = %d\n", @@ -1169,7 +1178,7 @@ test_rcu_qsbr_sw_sv_3qs(void) /* Check the quiescent state status */ rte_rcu_qsbr_check(t[0], token[1], true); - for (i = 0; i < 4; i++) { + for (i = 0; i < num_readers; i++) { c = hash_data[0][3][enabled_core_ids[i]]; if (c != COUNTER_VALUE && c != 0) { printf("Reader lcore %d did not complete #3 = %d\n", @@ -1187,7 +1196,7 @@ test_rcu_qsbr_sw_sv_3qs(void) /* Check the quiescent state status */ rte_rcu_qsbr_check(t[0], token[2], true); - for (i = 0; i < 4; i++) { + for (i = 0; i < num_readers; i++) { c = hash_data[0][6][enabled_core_ids[i]]; if (c != COUNTER_VALUE && c != 0) { printf("Reader lcore %d did not complete #6 = %d\n", @@ -1206,7 +1215,7 @@ test_rcu_qsbr_sw_sv_3qs(void) writer_done = 1; /* Wait and check return value from reader threads */ - for (i = 0; i < 4; i++) + for (i = 0; i < num_readers; i++) if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0) goto error; rte_hash_free(h[0]); @@ -1236,6 +1245,12 @@ test_rcu_qsbr_mw_mv_mqs(void) unsigned int i, j; unsigned int test_cores; + if (RTE_MAX_LCORE < 5 || num_cores < 4) { + printf("Not enough cores for %s, expecting at least 5\n", + __func__); + return TEST_SKIPPED; + } + writer_done = 0; test_cores = num_cores / 4; test_cores = test_cores * 4; @@ -1321,11 +1336,6 @@ test_rcu_qsbr_main(void) { uint16_t core_id; - if (rte_lcore_count() < 5) { - printf("Not enough cores for rcu_qsbr_autotest, expecting at least 5\n"); - return TEST_SKIPPED; - } - num_cores = 0; RTE_LCORE_FOREACH_SLAVE(core_id) { enabled_core_ids[num_cores] = core_id; From patchwork Fri Oct 16 06:03:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 317801 Delivered-To: patch@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp1154686ilm; Thu, 15 Oct 2020 23:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmmYWSJyyDRvC48OUX1kqMXMfnSRtGylArcJ7HhO/PsCsykA4uAyhR7dyKcJPxWxed7GbR X-Received: by 2002:a17:906:131a:: with SMTP id w26mr2163011ejb.271.1602828267865; Thu, 15 Oct 2020 23:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602828267; cv=none; d=google.com; s=arc-20160816; b=t0fzQ7QX+HGRf8v+Pa0KqOPobb+1zGbn1OIzlN4ik4/f/QMPXwetIuwL9qhgFtEOTS 3M5bQgfddITd2Eh//PBc9O0Ghz29NrDyVX6Bv9kRfvd2102Ogz16lymWz4kRUXbi+e9X KrVMO9/N6nNKeRIcX362WJBspZXzSTjdGIbZJlORnwoKVVK7G9aGjrvk2ppd3PxyofZv j1EWI8bjmxnOwVJUNFq/0/xRDkvPf5FXUEzwmU3PdW9cnPkRBDOM/DU6fKetC8kI8uEI gpmi0HUeG7Xrp1fOSJ3E1elLKp5wMwoXxtjO4XKe2M1Cg4NKChjrLR6GD6QDXgVEA8j/ gi0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=81LlBGrNqkqYiWRdU9eKDcFRelZzuYO2o/2IkKLx3Po=; b=z98zc/Vjhsw4SZ3tO4dIcwbKAM3FhsB5vlWSHxxK/Ih2m8sjlfj0kXys9f5e8DFp1H DWriyCSktFdfTHJExP9bHG2+p7Y4JmnRYW/x8mBVNBlV4XP8tgORTUc2Hd0sOi9DrFvV N13vibVwWfeQuWCyvNeWksuRuZZskvpJSQ0bvBZuYNFFM/bWQxeHDWaZjwPwkx4piwCp bI3C9Qo2Sv5tDr0Sjw/xuHae0rVxcuhKGfpmHb5XsU/UlNorMlF8Hmm+ldkHWZszzwN2 PI2XFQDyKieq143ULeFMRAnu8w+n8KMqaxMwO0VfdxJQJY1EMHiirkHnpzC5+ZM4EeXz GcVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id c27si997829ejd.125.2020.10.15.23.04.27; Thu, 15 Oct 2020 23:04:27 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F7C41EA8D; Fri, 16 Oct 2020 08:04:07 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 176A71EA5E; Fri, 16 Oct 2020 08:04:03 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 86EF6113E; Thu, 15 Oct 2020 23:04:01 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 752873F66B; Thu, 15 Oct 2020 23:04:01 -0700 (PDT) From: Honnappa Nagarahalli To: dev@dpdk.org, honnappa.nagarahalli@arm.com, john.mcnamara@intel.com Cc: ruifeng.wang@arm.com, juraj.linkes@pantheon.tech, david.marchand@redhat.com, nd@arm.com, ian.betts@intel.com, stable@dpdk.org Date: Fri, 16 Oct 2020 01:03:49 -0500 Message-Id: <20201016060349.19940-2-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201016060349.19940-1-honnappa.nagarahalli@arm.com> References: <20201016060349.19940-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH 2/2] examples/performance-thread: fix undef behavior 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" When the value of RTE_MAX_LCORE is small, it results in the following compilation error. ../examples/performance-thread/l3fwd-thread/main.c:2338:34: error: iteration 4 invokes undefined behavior [-Werror=aggressive-loop-optimizations] Fixes: d48415e1fee3 ("examples/performance-thread: add l3fwd-thread app") Cc: ian.betts@intel.com Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Ruifeng Wang --- examples/performance-thread/l3fwd-thread/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: David Marchand diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index 818e483d2..dc34d4893 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -599,8 +599,8 @@ struct thread_rx_conf rx_thread[MAX_RX_THREAD]; struct thread_tx_conf { struct thread_conf conf; - uint16_t tx_queue_id[RTE_MAX_LCORE]; - struct mbuf_table tx_mbufs[RTE_MAX_LCORE]; + uint16_t tx_queue_id[RTE_MAX_ETHPORTS]; + struct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS]; struct rte_ring *ring; struct lthread_cond **ready;