From patchwork Sat Jul 4 14:35:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 73108 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44A58A0524; Sat, 4 Jul 2020 16:36:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8C8BF1DB8F; Sat, 4 Jul 2020 16:36:05 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id CFEF31DB8A; Sat, 4 Jul 2020 16:36:03 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.144]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 5778B20053; Sat, 4 Jul 2020 14:36:03 +0000 (UTC) Received: from us4-mdac16-4.at1.mdlocal (unknown [10.110.49.155]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 5399F800A4; Sat, 4 Jul 2020 14:36:03 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.7]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id EEB5740060; Sat, 4 Jul 2020 14:36:02 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id B79FF4C0058; Sat, 4 Jul 2020 14:36:02 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 4 Jul 2020 15:35:58 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 4 Jul 2020 15:35:58 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 064EZww5008085; Sat, 4 Jul 2020 15:35:58 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 3C75E1616AE; Sat, 4 Jul 2020 15:35:58 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov , , "Harry van Haaren" Date: Sat, 4 Jul 2020 15:35:47 +0100 Message-ID: <1593873347-13686-1-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25520.003 X-TM-AS-Result: No-0.696700-8.000000-10 X-TMASE-MatchedRID: sppTXxFcLW3RhjL796mSwBouoVvF2i0ZNV9S7O+u3KY5yibxcff/slMe 5Blkpry7rdoLblq9S5oO1mVtY5XA0K+/EguYor8cFEUknJ/kEl5q8/xv2Um1avoLR4+zsDTtRcD SKgj6IG2LPZJpE4CXcZdjODtHoG75DvELi71Cdm2r09DnYdZ/103NJGMuEC5G1YCfp67tR6A0Ra GiiwdQJJ0yqLoeoeuHchJw6uJ0wJjaQLtLC8aUqEPBvsmCWGHWUWQ7Bol0IqAY5tvH9Ry2Nw== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--0.696700-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25520.003 X-MDID: 1593873363-GMHWIjRlnzIZ Subject: [dpdk-dev] [PATCH] service: fix wrong lcore indexes 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: Igor Romanov The service core list is populated, but not used. Incorrect lcore states are examined for a service. Use the populated list to iterate over service cores. Fixes: e30dd31847d2 ("service: add mechanism for quiescing") Cc: stable@dpdk.org Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- lib/librte_eal/common/rte_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index 6123a2124d..e2795f857e 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -422,7 +422,7 @@ rte_service_may_be_active(uint32_t id) return -EINVAL; for (i = 0; i < lcore_count; i++) { - if (lcore_states[i].service_active_on_lcore[id]) + if (lcore_states[ids[i]].service_active_on_lcore[id]) return 1; } From patchwork Tue Jul 7 10:45:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 73419 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 28BEAA00BE; Tue, 7 Jul 2020 12:45:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AE12A1DDD6; Tue, 7 Jul 2020 12:45:34 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 174011DDD5 for ; Tue, 7 Jul 2020 12:45:33 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.150]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 85A0220087; Tue, 7 Jul 2020 10:45:32 +0000 (UTC) Received: from us4-mdac16-44.at1.mdlocal (unknown [10.110.48.15]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 83983800A3; Tue, 7 Jul 2020 10:45:32 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.49.106]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 17BE3100052; Tue, 7 Jul 2020 10:45:32 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id D414EB40066; Tue, 7 Jul 2020 10:45:31 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 7 Jul 2020 11:45:28 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 7 Jul 2020 11:45:28 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 067AjSaH013633; Tue, 7 Jul 2020 11:45:28 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 67A7D1626E9; Tue, 7 Jul 2020 11:45:28 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov , Harry van Haaren Date: Tue, 7 Jul 2020 11:45:25 +0100 Message-ID: <1594118726-8421-2-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594118726-8421-1-git-send-email-arybchenko@solarflare.com> References: <1593873347-13686-1-git-send-email-arybchenko@solarflare.com> <1594118726-8421-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25526.003 X-TM-AS-Result: No-7.886200-8.000000-10 X-TMASE-MatchedRID: sgT35vMqibO09I1RF1swcOIfK/Jd5eHmjotcmj+7SkE4XREg9Ki10xd2 WyReW5ebcKLnwjXEZ1ayUescqeUMprYX2Zbb0Huy6fUfELqFUH9KRaXN2yYjHjsUTbqaO707QBz oPKhLasjFG6rPbKnpuvD8CGDYfAZ9FUPnz5fE4uPylEfNwb6iLVF5adRR2Ej1kaEC8FJraL/cru +PSMhej/bCvJzBrCnffuf8ioYS+7Gg2YoJMKNlEYNraaMEw/Vakos2tunL8DQrC/kbp8twD9IQa SugOFswNWlqv3euRjUYGmTiWQlQQpilmT/yOYwxlchF+IvkllOi8D/o42y/Sj1KWk8zZw5Fo8WM kQWv6iXBcIE78YqRWo6HM5rqDwqtHDoAauuBleM+fM8D35G8fb0MhOynrKQ48uLQ3wCtP7NiH+Z jIy/leEMMprcbiest X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.886200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25526.003 X-MDID: 1594118732-xZXEK_HXckZ4 Subject: [dpdk-dev] [PATCH v3 2/2] test/service: add test for service active on two lcores 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: Igor Romanov The test checks that the service may be active API works when there are two cores: a non-service lcore and a service one. The API notes to take care when checking the status of a running service, but the test setup allows for a safe usage in that case. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko Acked-by: Harry van Haaren Reviewed-by: Honnappa Nagarahalli --- v3: - skip the test if number of cores is insufficient app/test/test_service_cores.c | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index 981e212130..4f003ed1af 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -910,6 +910,59 @@ service_may_be_active(void) return unregister_all(); } +/* check service may be active when service is running on a second lcore */ +static int +service_active_two_cores(void) +{ + if (!rte_lcore_is_enabled(0) || !rte_lcore_is_enabled(1) || + !rte_lcore_is_enabled(2)) + return TEST_SKIPPED; + + const uint32_t sid = 0; + int i; + + uint32_t lcore = rte_get_next_lcore(/* start core */ -1, + /* skip master */ 1, + /* wrap */ 0); + uint32_t slcore = rte_get_next_lcore(/* start core */ lcore, + /* skip master */ 1, + /* wrap */ 0); + + /* start the service on the second available lcore */ + TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1), + "Starting valid service failed"); + TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore), + "Add service core failed when not in use before"); + TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore, 1), + "Enabling valid service on valid core failed"); + TEST_ASSERT_EQUAL(0, rte_service_lcore_start(slcore), + "Service core start after add failed"); + + /* ensures core really is running the service function */ + TEST_ASSERT_EQUAL(1, service_lcore_running_check(), + "Service core expected to poll service but it didn't"); + + /* ensures that service may be active reports running state */ + TEST_ASSERT_EQUAL(1, rte_service_may_be_active(sid), + "Service may be active did not report running state"); + + /* stop the service */ + TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0), + "Error: Service stop returned non-zero"); + + /* give the service 100ms to stop running */ + for (i = 0; i < 100; i++) { + if (!rte_service_may_be_active(sid)) + break; + rte_delay_ms(SERVICE_DELAY); + } + + TEST_ASSERT_EQUAL(0, rte_service_may_be_active(sid), + "Error: Service not stopped after 100ms"); + + return unregister_all(); +} + static struct unit_test_suite service_tests = { .suite_name = "service core test suite", .setup = testsuite_setup, @@ -931,6 +984,7 @@ static struct unit_test_suite service_tests = { TEST_CASE_ST(dummy_register, NULL, service_app_lcore_mt_safe), TEST_CASE_ST(dummy_register, NULL, service_app_lcore_mt_unsafe), TEST_CASE_ST(dummy_register, NULL, service_may_be_active), + TEST_CASE_ST(dummy_register, NULL, service_active_two_cores), TEST_CASES_END() /**< NULL terminate unit test array */ } };