From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E6CDF4594B; Mon, 9 Sep 2024 21:20:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A9E0840E64; Mon, 9 Sep 2024 21:20:34 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2045.outbound.protection.outlook.com [40.107.20.45]) by mails.dpdk.org (Postfix) with ESMTP id 9BA934021F for ; Mon, 9 Sep 2024 21:20:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rrpu3a6URNNf1m4V9E6CRSW9zG0SpCQp+YOQvPw3Ei9jduyR9bIWn4R+jqGMggeK49drbWxE4xKlMWBS1nVJ3ktaH+Iio8n6WhMLvh7Qiehf/prD8JlVcHiaRZs8Sld4C99zddFDTEJfHuM1nCsA8nNfpH46HaXFeriBP8HyY91aqDhRHYa2H8MLIgAOkmzye4AKUSRvPofrcLrUF39pDTKpXwUZckFKd4ewbavBH8HyGW2obRCENB5bZIe7QU9NwtOcK9I6LVak+Ergqzj2Psbz5i6T76ljKLyhADPAIE8WDNYhWgsmPC6AGplth7M5Oy0CO6dJkNhWc4k3dp6FJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=avULEv01UOs37mAqdVEj56pIVuGrZdzJ794OpygMGA0=; b=dsfUWrJxhVc3Z1h0/OCWB6DbcVeHEBH3mxE/IvcVbI0AWiPjSLuOyeThPre6OpkxW6L498uw4OdDTiX2oTwuw7Q5fMXexbSCebKr3rHVmHPbIa6QUIbp/UM5z9Y7+x1JgrgxIfMq5/JMB6G0nw/Rh9qal7Zo5sAjxfXcDGsuGwb/v7lK7qSTXk4YZ6xyVU8B0TQtvYVvnOzavBHD6IqyG44KRlAMMVASvjrPhgvsgJ7BzZWcx/m8lBa9970OaEnfRDRxoIfL5fp8WG8Zp2D37aVvBNfM5TewMSEBLN1kMBHYNkF/rkXQ70vjmbU4JcAFNnOsQx3rNjhGqPbonVdHTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=avULEv01UOs37mAqdVEj56pIVuGrZdzJ794OpygMGA0=; b=RPMwJ7kBayA3WQw9s81dr1Ndqb7fRdyBV1EbIoNei0IoCoHj08dFaRj6tWOvhpEbsI816zgTNmpjhqoJpJkSGRKLcxBGAZbXioBQuKDcM6LYSgAZzbstkjKs2hCWymLkcXKNU8rT9q/4SaGukyB4k3sxY008qrI+ZAZJ3IY0ffHdwRp38p6RjOrpQqMQvh8PVcY/2h8Fx+JpWAog3XZmH52MxNcoYFRWafzSTdC+bBC2skErf9kl9f0F/n5ZvNbX86qqixqtt4X/VC9TNyqIYGEE+R3oVr00tbquV9dbhHHLFahrNYhvt8BjCFvyukIW2RytFvOs1R9g5GMfHeEWiw== Received: from AS9PR07CA0036.eurprd07.prod.outlook.com (2603:10a6:20b:46b::10) by AS5PR07MB9748.eurprd07.prod.outlook.com (2603:10a6:20b:678::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Mon, 9 Sep 2024 19:20:28 +0000 Received: from AM2PEPF0001C70F.eurprd05.prod.outlook.com (2603:10a6:20b:46b:cafe::c4) by AS9PR07CA0036.outlook.office365.com (2603:10a6:20b:46b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Mon, 9 Sep 2024 19:20:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by AM2PEPF0001C70F.mail.protection.outlook.com (10.167.16.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Mon, 9 Sep 2024 19:20:28 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.60) with Microsoft SMTP Server id 15.2.1544.11; Mon, 9 Sep 2024 21:20:27 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 7F1A8380061; Mon, 9 Sep 2024 21:20:27 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , , Stefan Sundkvist , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH v2] service: extend service function call statistics Date: Mon, 9 Sep 2024 21:11:03 +0200 Message-ID: <20240909191103.697554-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809202539.590510-1-mattias.ronnblom@ericsson.com> References: <20240809202539.590510-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM2PEPF0001C70F:EE_|AS5PR07MB9748:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fbfa5ed-3fa6-43f8-5fba-08dcd10476ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?SitmUEVGVWxZRTFRNk1xZG1HaGJqL2k2ZzhVT0dvMnc1ZVN4OVFGMzFrT1Z1?= =?utf-8?B?cXpaSWc0ZGM2UDU1ZjJvcEV2NUcwdko3YUdXbFZJYlhuT01QU1RheitKcDcw?= =?utf-8?B?aEhpZnQxSHRSYnNwaVQxcUdmRGo3YlFxdWVkNnM0dTZGeVgzOHJMdGlleFk0?= =?utf-8?B?SXZWYmsyZkd6eFg3aksxZ2wrS3JMaVhhb08xV25wZUh4eDIxZm9VM0FxVUtV?= =?utf-8?B?enVvZVdhM09ZcVc1aDVnWlJsb204TXFuN2Vpajg3VlVzOWhHdzk5NUhObzZ1?= =?utf-8?B?T3BQb25JK0Y4MktJZm4rOVdMdjBJcW9NRUt3ZXpXdFQ4RXNncmFTSzU4YkhL?= =?utf-8?B?OEdIVE9OV3RTaUZhVjhEc2RPdFZqajIrL1g5eXljQWJnVThsbFRqVHNXK1Z4?= =?utf-8?B?eVBBUjVWd2xEQjQzSFovR3lQSEdPU252enVLWDlCcXpWTVhOZDB6eHZzNi9v?= =?utf-8?B?UkV2aWlMNUNhY3dYMDRpM1VkK2x4RVJYdmpKQnNYQ0IzR3ZQeXJSQklRUHN1?= =?utf-8?B?V0pTb2gwaGRxSmtFRDdFbUl6Ky9ySzRwa3hPTTRhNC9rWW5ZaE1MVitkRXFG?= =?utf-8?B?d01VZkh4dFpuS0NwdnBybXI0OUVoT0dCMU5CMWV3anNVakt3RloyOFoyNjlK?= =?utf-8?B?QTRPUXBaS25MYWhqR1YyTnBBVjhGRzd0akMrT1lDOHJ2RmhwWFVpMFdmZFFs?= =?utf-8?B?L0ZFd1hFZXZjYTRIN2VTaThkU2tTOEFVZlFpTm9CS0ZCTWl0TzRZV2NNR0Nx?= =?utf-8?B?L3dRckZrcVRjTU52YjNpMytsaGtIUm5CT2g1QVhxRUh0RFNtRk1wYVd3WHJl?= =?utf-8?B?bDFUQXJVS1ZXY2ljdWJGQnRYNnRkd1FoWklxOUUwYS80bnV3bTJsaGQxNXJO?= =?utf-8?B?QVYxZHBKSGt3Ujh3N1RyVTZDSFNwM05KU2liMFVUZTJwWmh5L213M25QUnpu?= =?utf-8?B?ZXZQeW1yNHRFYXlrTHVXSXovMy9McXJVdHJkWnVCd09TK2dyODlNSnBLR2t1?= =?utf-8?B?UWFib2ROb09jVnhaVjJzSm1JWXU2RnBWSFl0RlNtUU5VcU1IWGFrS08zVE9E?= =?utf-8?B?VUx2M0xEemVyQW94K3RZT203RjZLdTdNNmN5MnQ2VU5CcjVxRzg1Q3oydG1X?= =?utf-8?B?SnhINkwzeGVuYUxOUzl4aGRORTZ6QjZJRkdrRUQyaHJ1Smo0MTRqT2VibnYz?= =?utf-8?B?Z05LR1N4OHdSaFdHTXdyMjh6a2E2STZUakFhTWl5QWVrcFNwRjhGUkxNb0FD?= =?utf-8?B?RWduOFA0L21tbUErN2NXQkt5S3UyUGRJbUFqTUp5WVNWWTdVVC9EOGhmTzRp?= =?utf-8?B?OGRQS2RIdTBXU2R6VUJuMjMxeWg5T3pXRE1xNk5UZUx2dU9QSDIxb0syYnVO?= =?utf-8?B?UUtmbWtldm9zOHFpOWczOXBlSGp2MFNHaWl3eDdXVnBBd3o2OXR3UlZKcUdN?= =?utf-8?B?N0NYS2dHSlNjR0t1dkxHaHp2dE0wK3RCdFZ1enpmd25lUnFpUmRGYmdwbnhi?= =?utf-8?B?UjVuMFVRWkVhazhOSnZmRGh5R0RoWGRoYUo3ZVZrNnhtK2QxeUpxMmpJWWxK?= =?utf-8?B?WGxKS3pXWmlybENlYTZ6N1ArTG1KZjdvOWI3T1dsYWcra2ZITTN1VHRhSWE3?= =?utf-8?B?emIwU2FhcWQrcnhiS2huSEU3NjNSSGptU09VaUNONDhSZWQ4aTdQK0wwdXRq?= =?utf-8?B?VnM4c00wTWJ6QWMxeHdVV0p3Q1RLV1hxWmlNT1l0ZDJSSVBaajhpaFFzQW9x?= =?utf-8?B?cnZtWlVjdVNRT0R0QUR5OXZsQmI2c2dzSTdZU3ZtU29RbC9IL2FXYkkvbUhM?= =?utf-8?B?T0JjdnpqZzdjOWJNWk5FcjRpTVhHVlZpN3FIanVRTTNoMkpoUWJMSjdQUVRi?= =?utf-8?B?Z2MzaTlycHBabjFFU3llWU9rMVp3b2ZOVWhoSTl3Yk13REJSOWFoaXR5MFh2?= =?utf-8?Q?OB4eV0EF0KcpGzzGzRsbpUVIWVh7xBFB?= X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230040)(1800799024)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2024 19:20:28.0381 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fbfa5ed-3fa6-43f8-5fba-08dcd10476ac X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C70F.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR07MB9748 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add two new per-service counters. RTE_SERVICE_ATTR_IDLE_CALL_COUNT tracks the number of service function invocations where no work was performed. RTE_SERVICE_ATTR_ERROR_CALL_COUNT tracks the number invocations resulting in an error. The semantics of RTE_SERVICE_ATTR_CALL_COUNT remains the same (i.e., counting all invocations, regardless of return value). The new statistics may be useful for both debugging and profiling (e.g., calculate the average per-call processing latency for non-idle service calls). Service core tests are extended to cover the new counters, and coverage for RTE_SERVICE_ATTR_CALL_COUNT is improved. The documentation for the CYCLES attributes are updated to reflect their actual semantics. Signed-off-by: Mattias Rönnblom -- PATCH v2: * Fix build issue for enable_stdatomic=true. PATCH: * Update release notes. --- app/test/test_service_cores.c | 70 ++++++++++++++++++------ doc/guides/rel_notes/release_24_11.rst | 11 ++++ lib/eal/common/rte_service.c | 75 +++++++++++++++++++++----- lib/eal/include/rte_service.h | 24 +++++++-- 4 files changed, 147 insertions(+), 33 deletions(-) diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index 010ab82893..7ae6bbb179 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -3,11 +3,12 @@ */ #include +#include #include -#include #include +#include #include -#include +#include #include #include @@ -16,8 +17,10 @@ /* used as the service core ID */ static uint32_t slcore_id; -/* used as timestamp to detect if a service core is running */ -static uint64_t service_tick; +/* track service call count */ +static uint64_t service_calls; +static uint64_t service_idle_calls; +static uint64_t service_error_calls; /* used as a flag to check if a function was run */ static uint32_t service_remote_launch_flag; @@ -46,9 +49,21 @@ testsuite_teardown(void) static int32_t dummy_cb(void *args) { RTE_SET_USED(args); - service_tick++; + + service_calls++; + + switch (rte_rand_max(3)) { + case 0: + return 0; + case 1: + service_idle_calls++; + return -EAGAIN; + default: + service_error_calls++; + return -ENOENT; + } + rte_delay_ms(SERVICE_DELAY); - return 0; } static int32_t dummy_mt_unsafe_cb(void *args) @@ -121,6 +136,10 @@ unregister_all(void) rte_service_lcore_reset_all(); rte_eal_mp_wait_lcore(); + service_calls = 0; + service_idle_calls = 0; + service_error_calls = 0; + return TEST_SUCCESS; } @@ -295,12 +314,19 @@ service_attr_get(void) "Valid attr_get() call didn't return success"); TEST_ASSERT_EQUAL(0, attr_value, "attr_get() call didn't set correct cycles (zero)"); - /* check correct call count */ + /* check correct call counts */ const int attr_calls = RTE_SERVICE_ATTR_CALL_COUNT; TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_calls, &attr_value), "Valid attr_get() call didn't return success"); - TEST_ASSERT_EQUAL(0, attr_value, - "attr_get() call didn't get call count (zero)"); + TEST_ASSERT_EQUAL(0, attr_value, "Call count was not zero"); + const int attr_idle_calls = RTE_SERVICE_ATTR_IDLE_CALL_COUNT; + TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_idle_calls, &attr_value), + "Valid attr_get() call didn't return success"); + TEST_ASSERT_EQUAL(0, attr_value, "Idle call count was not zero"); + const int attr_error_calls = RTE_SERVICE_ATTR_ERROR_CALL_COUNT; + TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_error_calls, &attr_value), + "Valid attr_get() call didn't return success"); + TEST_ASSERT_EQUAL(0, attr_value, "Error call count was not zero"); /* Call service to increment cycle count */ TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id), @@ -331,8 +357,13 @@ service_attr_get(void) TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_calls, &attr_value), "Valid attr_get() call didn't return success"); - TEST_ASSERT_EQUAL(1, (attr_value > 0), - "attr_get() call didn't get call count (zero)"); + TEST_ASSERT_EQUAL(service_calls, attr_value, "Unexpected call count"); + TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_idle_calls, &attr_value), + "Valid attr_get() call didn't return success"); + TEST_ASSERT_EQUAL(service_idle_calls, attr_value, "Unexpected idle call count"); + TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_error_calls, &attr_value), + "Valid attr_get() call didn't return success"); + TEST_ASSERT_EQUAL(service_error_calls, attr_value, "Unexpected error call count"); TEST_ASSERT_EQUAL(0, rte_service_attr_reset_all(id), "Valid attr_reset_all() return success"); @@ -341,11 +372,16 @@ service_attr_get(void) "Valid attr_get() call didn't return success"); TEST_ASSERT_EQUAL(0, attr_value, "attr_get() call didn't set correct cycles (zero)"); - /* ensure call count > zero */ + /* ensure call counts are zero */ TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_calls, &attr_value), "Valid attr_get() call didn't return success"); - TEST_ASSERT_EQUAL(0, (attr_value > 0), - "attr_get() call didn't get call count (zero)"); + TEST_ASSERT_EQUAL(0, attr_value, "Call count was not reset"); + TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_idle_calls, &attr_value), + "Valid attr_get() call didn't return success"); + TEST_ASSERT_EQUAL(0, attr_value, "Idle call count was not reset"); + TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_error_calls, &attr_value), + "Valid attr_get() call didn't return success"); + TEST_ASSERT_EQUAL(0, attr_value, "Error call count was not reset"); return unregister_all(); } @@ -533,10 +569,10 @@ service_lcore_en_dis_able(void) static int service_lcore_running_check(void) { - uint64_t tick = service_tick; + uint64_t calls = service_calls; rte_delay_ms(SERVICE_DELAY * 100); - /* if (tick != service_tick) we know the lcore as polled the service */ - return tick != service_tick; + bool service_polled = calls != service_calls; + return service_polled; } static int diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index 0ff70d9057..eb3a1070e4 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -55,6 +55,17 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Extended service cores statistics.** + + Two new per-service counters are added to the service cores framework. + + `RTE_SERVICE_ATTR_IDLE_CALL_COUNT` tracks the number of service function + invocations where no actual work was performed. + + `RTE_SERVICE_ATTR_ERROR_CALL_COUNT` tracks the number invocations + resulting in an error. + + The new statistics are useful for debugging and profiling. Removed Items ------------- diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c index 56379930b6..a38c594ce4 100644 --- a/lib/eal/common/rte_service.c +++ b/lib/eal/common/rte_service.c @@ -57,6 +57,8 @@ struct __rte_cache_aligned rte_service_spec_impl { struct service_stats { RTE_ATOMIC(uint64_t) calls; + RTE_ATOMIC(uint64_t) idle_calls; + RTE_ATOMIC(uint64_t) error_calls; RTE_ATOMIC(uint64_t) cycles; }; @@ -369,6 +371,21 @@ rte_service_runstate_get(uint32_t id) } +static void +service_counter_add(RTE_ATOMIC(uint64_t) *counter, uint64_t operand) +{ + /* The lcore service worker thread is the only writer, and + * thus only a non-atomic load and an atomic store is needed, + * and not the more expensive atomic add. + */ + uint64_t value; + + value = rte_atomic_load_explicit(counter, rte_memory_order_relaxed); + + rte_atomic_store_explicit(counter, value + operand, + rte_memory_order_relaxed); +} + static inline void service_runner_do_callback(struct rte_service_spec_impl *s, struct core_state *cs, uint32_t service_idx) @@ -380,27 +397,23 @@ service_runner_do_callback(struct rte_service_spec_impl *s, uint64_t start = rte_rdtsc(); int rc = s->spec.callback(userdata); - /* The lcore service worker thread is the only writer, - * and thus only a non-atomic load and an atomic store - * is needed, and not the more expensive atomic - * add. - */ struct service_stats *service_stats = &cs->service_stats[service_idx]; + service_counter_add(&service_stats->calls, 1); + + if (rc == -EAGAIN) + service_counter_add(&service_stats->idle_calls, 1); + else if (rc != 0) + service_counter_add(&service_stats->error_calls, 1); + if (likely(rc != -EAGAIN)) { uint64_t end = rte_rdtsc(); uint64_t cycles = end - start; - rte_atomic_store_explicit(&cs->cycles, cs->cycles + cycles, - rte_memory_order_relaxed); - rte_atomic_store_explicit(&service_stats->cycles, - service_stats->cycles + cycles, - rte_memory_order_relaxed); + service_counter_add(&cs->cycles, cycles); + service_counter_add(&service_stats->cycles, cycles); } - - rte_atomic_store_explicit(&service_stats->calls, - service_stats->calls + 1, rte_memory_order_relaxed); } else { s->spec.callback(userdata); } @@ -867,6 +880,24 @@ lcore_attr_get_service_calls(uint32_t service_id, unsigned int lcore) rte_memory_order_relaxed); } +static uint64_t +lcore_attr_get_service_idle_calls(uint32_t service_id, unsigned int lcore) +{ + struct core_state *cs = &lcore_states[lcore]; + + return rte_atomic_load_explicit(&cs->service_stats[service_id].idle_calls, + rte_memory_order_relaxed); +} + +static uint64_t +lcore_attr_get_service_error_calls(uint32_t service_id, unsigned int lcore) +{ + struct core_state *cs = &lcore_states[lcore]; + + return rte_atomic_load_explicit(&cs->service_stats[service_id].error_calls, + rte_memory_order_relaxed); +} + static uint64_t lcore_attr_get_service_cycles(uint32_t service_id, unsigned int lcore) { @@ -899,6 +930,18 @@ attr_get_service_calls(uint32_t service_id) return attr_get(service_id, lcore_attr_get_service_calls); } +static uint64_t +attr_get_service_idle_calls(uint32_t service_id) +{ + return attr_get(service_id, lcore_attr_get_service_idle_calls); +} + +static uint64_t +attr_get_service_error_calls(uint32_t service_id) +{ + return attr_get(service_id, lcore_attr_get_service_error_calls); +} + static uint64_t attr_get_service_cycles(uint32_t service_id) { @@ -918,6 +961,12 @@ rte_service_attr_get(uint32_t id, uint32_t attr_id, uint64_t *attr_value) case RTE_SERVICE_ATTR_CALL_COUNT: *attr_value = attr_get_service_calls(id); return 0; + case RTE_SERVICE_ATTR_IDLE_CALL_COUNT: + *attr_value = attr_get_service_idle_calls(id); + return 0; + case RTE_SERVICE_ATTR_ERROR_CALL_COUNT: + *attr_value = attr_get_service_error_calls(id); + return 0; case RTE_SERVICE_ATTR_CYCLES: *attr_value = attr_get_service_cycles(id); return 0; diff --git a/lib/eal/include/rte_service.h b/lib/eal/include/rte_service.h index e49a7a877e..89057df585 100644 --- a/lib/eal/include/rte_service.h +++ b/lib/eal/include/rte_service.h @@ -374,15 +374,32 @@ int32_t rte_service_lcore_count_services(uint32_t lcore); int32_t rte_service_dump(FILE *f, uint32_t id); /** - * Returns the number of cycles that this service has consumed + * Returns the number of cycles that this service has consumed. Only + * cycles spent in non-idle calls (i.e., calls not returning -EAGAIN) + * count. */ #define RTE_SERVICE_ATTR_CYCLES 0 /** - * Returns the count of invocations of this service function + * Returns the total number of invocations of this service function + * (regardless of return value). */ #define RTE_SERVICE_ATTR_CALL_COUNT 1 +/** + * Returns the number of invocations of this service function where the + * service reported having not performed any useful work (i.e., + * returned -EAGAIN). + */ +#define RTE_SERVICE_ATTR_IDLE_CALL_COUNT 2 + +/** + * Returns the number of invocations of this service function where the + * service reported an error (i.e., the return value was neither 0 nor + * -EAGAIN). + */ +#define RTE_SERVICE_ATTR_ERROR_CALL_COUNT 3 + /** * Get an attribute from a service. * @@ -408,7 +425,8 @@ int32_t rte_service_attr_reset_all(uint32_t id); /** * Returns the total number of cycles that the lcore has spent on - * running services. + * running services. Only non-idle calls (i.e., calls not returning + * -EAGAIN) count toward this total. */ #define RTE_SERVICE_LCORE_ATTR_CYCLES 1 -- 2.34.1