get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/115382/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 115382,
    "url": "http://patches.dpdk.org/api/patches/115382/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220824162442.631456-2-kevin.laatz@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20220824162442.631456-2-kevin.laatz@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220824162442.631456-2-kevin.laatz@intel.com",
    "date": "2022-08-24T16:24:40",
    "name": "[v2,1/3] eal: add lcore poll busyness telemetry",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8317286083d443024af7b5a7f0aa9bc20262c45e",
    "submitter": {
        "id": 921,
        "url": "http://patches.dpdk.org/api/people/921/?format=api",
        "name": "Kevin Laatz",
        "email": "kevin.laatz@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20220824162442.631456-2-kevin.laatz@intel.com/mbox/",
    "series": [
        {
            "id": 24401,
            "url": "http://patches.dpdk.org/api/series/24401/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=24401",
            "date": "2022-08-24T16:24:39",
            "name": "Add lcore poll busyness telemetry",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/24401/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/115382/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/115382/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 54859A0543;\n\tWed, 24 Aug 2022 18:23:07 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7BB20410F2;\n\tWed, 24 Aug 2022 18:23:06 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n by mails.dpdk.org (Postfix) with ESMTP id 211D74067B\n for <dev@dpdk.org>; Wed, 24 Aug 2022 18:23:02 +0200 (CEST)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 24 Aug 2022 09:21:53 -0700",
            "from silpixa00401122.ir.intel.com ([10.237.213.42])\n by FMSMGA003.fm.intel.com with ESMTP; 24 Aug 2022 09:21:48 -0700"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1661358183; x=1692894183;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=tiyRsbJIz0twmY7XhHXFONmfhpt6Ga0vT0VK04UynUo=;\n b=k3jEWW6Yw9YdUU+afOD4WfgrPXkV43qAtFFA+7LbtxGcp/TjGe4OvPSh\n WQiFxJju9U2/aQ/xiZlJNDCuPpCkx0tXRDIZe3LUqD+Ip6+RIbzRrA7gk\n fi+Cm/ih4LWC+C4QToqDBw98DMAx5RuShr3833NPmS3FJjyQLoeazA2mT\n JHgC8bUiB+EA2qHh13RtNj6cewzADM52W5TQ+wX6fNmBa2N3deiZO3HCG\n WbCqf7shiVhx8jwoAFd+5OBXHqJObAbBgI3ATB/C274mHakGEZagXjcWM\n v5xL89UpW2jTtBBkKTVpoI9/MwJD3hz3VlReJhaHVY3XHwnowPI0AXMjY Q==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10449\"; a=\"292755989\"",
            "E=Sophos;i=\"5.93,260,1654585200\"; d=\"scan'208\";a=\"292755989\"",
            "E=Sophos;i=\"5.93,260,1654585200\"; d=\"scan'208\";a=\"699128507\""
        ],
        "X-ExtLoop1": "1",
        "From": "Kevin Laatz <kevin.laatz@intel.com>",
        "To": "dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>,\n Nicolas Chautru <nicolas.chautru@intel.com>,\n Fan Zhang <roy.fan.zhang@intel.com>,\n Ashish Gupta <ashish.gupta@marvell.com>, Akhil Goyal <gakhil@marvell.com>,\n David Hunt <david.hunt@intel.com>, Chengwen Feng <fengchengwen@huawei.com>,\n Kevin Laatz <kevin.laatz@intel.com>, Ray Kinsella <mdr@ashroe.eu>,\n Thomas Monjalon <thomas@monjalon.net>,\n Ferruh Yigit <ferruh.yigit@xilinx.com>,\n Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,\n Jerin Jacob <jerinj@marvell.com>,\n Sachin Saxena <sachin.saxena@oss.nxp.com>,\n Hemant Agrawal <hemant.agrawal@nxp.com>, Ori Kam <orika@nvidia.com>,\n Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,\n Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>",
        "Cc": "anatoly.burakov@intel.com,\n\tConor Walsh <conor.walsh@intel.com>",
        "Subject": "[PATCH v2 1/3] eal: add lcore poll busyness telemetry",
        "Date": "Wed, 24 Aug 2022 17:24:40 +0100",
        "Message-Id": "<20220824162442.631456-2-kevin.laatz@intel.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20220824162442.631456-1-kevin.laatz@intel.com>",
        "References": "\n <24c49429394294cfbf0d9c506b205029bac77c8b.1657890378.git.anatoly.burakov@intel.com>\n <20220824162442.631456-1-kevin.laatz@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "From: Anatoly Burakov <anatoly.burakov@intel.com>\n\nCurrently, there is no way to measure lcore busyness in a passive way,\nwithout any modifications to the application. This patch adds a new EAL\nAPI that will be able to passively track core busyness.\n\nThe busyness is calculated by relying on the fact that most DPDK API's\nwill poll for packets. Empty polls can be counted as \"idle\", while\nnon-empty polls can be counted as busy. To measure lcore busyness, we\nsimply call the telemetry timestamping function with the number of polls\na particular code section has processed, and count the number of cycles\nwe've spent processing empty bursts. The more empty bursts we encounter,\nthe less cycles we spend in \"busy\" state, and the less core busyness\nwill be reported.\n\nIn order for all of the above to work without modifications to the\napplication, the library code needs to be instrumented with calls to\nthe lcore telemetry busyness timestamping function. The following parts\nof DPDK are instrumented with lcore telemetry calls:\n\n- All major driver API's:\n  - ethdev\n  - cryptodev\n  - compressdev\n  - regexdev\n  - bbdev\n  - rawdev\n  - eventdev\n  - dmadev\n- Some additional libraries:\n  - ring\n  - distributor\n\nTo avoid performance impact from having lcore telemetry support, a\nglobal variable is exported by EAL, and a call to timestamping function\nis wrapped into a macro, so that whenever telemetry is disabled, it only\ntakes one additional branch and no function calls are performed. It is\nalso possible to disable it at compile time by commenting out\nRTE_LCORE_BUSYNESS from build config.\n\nThis patch also adds a telemetry endpoint to report lcore busyness, as\nwell as telemetry endpoints to enable/disable lcore telemetry.\n\nSigned-off-by: Kevin Laatz <kevin.laatz@intel.com>\nSigned-off-by: Conor Walsh <conor.walsh@intel.com>\nSigned-off-by: David Hunt <david.hunt@intel.com>\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n\n---\nv2:\n  * Use rte_get_tsc_hz() to adjust the telemetry period\n  * Rename to reflect polling busyness vs general busyness\n  * Fix segfault when calling telemetry timestamp from an unregistered\n    non-EAL thread.\n  * Minor cleanup\n---\n config/meson.build                          |   1 +\n config/rte_config.h                         |   1 +\n lib/bbdev/rte_bbdev.h                       |  17 +-\n lib/compressdev/rte_compressdev.c           |   2 +\n lib/cryptodev/rte_cryptodev.h               |   2 +\n lib/distributor/rte_distributor.c           |  21 +-\n lib/distributor/rte_distributor_single.c    |  14 +-\n lib/dmadev/rte_dmadev.h                     |  15 +-\n lib/eal/common/eal_common_lcore_telemetry.c | 293 ++++++++++++++++++++\n lib/eal/common/meson.build                  |   1 +\n lib/eal/include/rte_lcore.h                 |  80 ++++++\n lib/eal/meson.build                         |   3 +\n lib/eal/version.map                         |   7 +\n lib/ethdev/rte_ethdev.h                     |   2 +\n lib/eventdev/rte_eventdev.h                 |  10 +-\n lib/rawdev/rte_rawdev.c                     |   5 +-\n lib/regexdev/rte_regexdev.h                 |   5 +-\n lib/ring/rte_ring_elem_pvt.h                |   1 +\n meson_options.txt                           |   2 +\n 19 files changed, 458 insertions(+), 24 deletions(-)\n create mode 100644 lib/eal/common/eal_common_lcore_telemetry.c",
    "diff": "diff --git a/config/meson.build b/config/meson.build\nindex 7f7b6c92fd..d5954a059c 100644\n--- a/config/meson.build\n+++ b/config/meson.build\n@@ -297,6 +297,7 @@ endforeach\n dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))\n dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))\n dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))\n+dpdk_conf.set('RTE_LCORE_POLL_BUSYNESS', get_option('enable_lcore_poll_busyness'))\n # values which have defaults which may be overridden\n dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64)\n dpdk_conf.set('RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB', 64)\ndiff --git a/config/rte_config.h b/config/rte_config.h\nindex 46549cb062..498702c9c7 100644\n--- a/config/rte_config.h\n+++ b/config/rte_config.h\n@@ -39,6 +39,7 @@\n #define RTE_LOG_DP_LEVEL RTE_LOG_INFO\n #define RTE_BACKTRACE 1\n #define RTE_MAX_VFIO_CONTAINERS 64\n+#define RTE_LCORE_POLL_BUSYNESS_PERIOD_MS 2\n \n /* bsd module defines */\n #define RTE_CONTIGMEM_MAX_NUM_BUFS 64\ndiff --git a/lib/bbdev/rte_bbdev.h b/lib/bbdev/rte_bbdev.h\nindex b88c88167e..d6ed176cce 100644\n--- a/lib/bbdev/rte_bbdev.h\n+++ b/lib/bbdev/rte_bbdev.h\n@@ -28,6 +28,7 @@ extern \"C\" {\n #include <stdbool.h>\n \n #include <rte_cpuflags.h>\n+#include <rte_lcore.h>\n \n #include \"rte_bbdev_op.h\"\n \n@@ -599,7 +600,9 @@ rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,\n {\n \tstruct rte_bbdev *dev = &rte_bbdev_devices[dev_id];\n \tstruct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];\n-\treturn dev->dequeue_enc_ops(q_data, ops, num_ops);\n+\tconst uint16_t nb_ops = dev->dequeue_enc_ops(q_data, ops, num_ops);\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n+\treturn nb_ops;\n }\n \n /**\n@@ -631,7 +634,9 @@ rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,\n {\n \tstruct rte_bbdev *dev = &rte_bbdev_devices[dev_id];\n \tstruct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];\n-\treturn dev->dequeue_dec_ops(q_data, ops, num_ops);\n+\tconst uint16_t nb_ops = dev->dequeue_dec_ops(q_data, ops, num_ops);\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n+\treturn nb_ops;\n }\n \n \n@@ -662,7 +667,9 @@ rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,\n {\n \tstruct rte_bbdev *dev = &rte_bbdev_devices[dev_id];\n \tstruct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];\n-\treturn dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);\n+\tconst uint16_t nb_ops = dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n+\treturn nb_ops;\n }\n \n /**\n@@ -692,7 +699,9 @@ rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,\n {\n \tstruct rte_bbdev *dev = &rte_bbdev_devices[dev_id];\n \tstruct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];\n-\treturn dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);\n+\tconst uint16_t nb_ops = dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n+\treturn nb_ops;\n }\n \n /** Definitions of device event types */\ndiff --git a/lib/compressdev/rte_compressdev.c b/lib/compressdev/rte_compressdev.c\nindex 22c438f2dd..912cee9a16 100644\n--- a/lib/compressdev/rte_compressdev.c\n+++ b/lib/compressdev/rte_compressdev.c\n@@ -580,6 +580,8 @@ rte_compressdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,\n \tnb_ops = (*dev->dequeue_burst)\n \t\t\t(dev->data->queue_pairs[qp_id], ops, nb_ops);\n \n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n+\n \treturn nb_ops;\n }\n \ndiff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h\nindex 56f459c6a0..072874020d 100644\n--- a/lib/cryptodev/rte_cryptodev.h\n+++ b/lib/cryptodev/rte_cryptodev.h\n@@ -1915,6 +1915,8 @@ rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,\n \t\trte_rcu_qsbr_thread_offline(list->qsbr, 0);\n \t}\n #endif\n+\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n \treturn nb_ops;\n }\n \ndiff --git a/lib/distributor/rte_distributor.c b/lib/distributor/rte_distributor.c\nindex 3035b7a999..35b0d8d36b 100644\n--- a/lib/distributor/rte_distributor.c\n+++ b/lib/distributor/rte_distributor.c\n@@ -56,6 +56,8 @@ rte_distributor_request_pkt(struct rte_distributor *d,\n \n \t\twhile (rte_rdtsc() < t)\n \t\t\trte_pause();\n+\t\t/* this was an empty poll */\n+\t\tRTE_LCORE_TELEMETRY_TIMESTAMP(0);\n \t}\n \n \t/*\n@@ -134,24 +136,29 @@ rte_distributor_get_pkt(struct rte_distributor *d,\n \n \tif (unlikely(d->alg_type == RTE_DIST_ALG_SINGLE)) {\n \t\tif (return_count <= 1) {\n+\t\t\tuint16_t cnt;\n \t\t\tpkts[0] = rte_distributor_get_pkt_single(d->d_single,\n-\t\t\t\tworker_id, return_count ? oldpkt[0] : NULL);\n-\t\t\treturn (pkts[0]) ? 1 : 0;\n-\t\t} else\n-\t\t\treturn -EINVAL;\n+\t\t\t\t\t\t\t\t worker_id,\n+\t\t\t\t\t\t\t\t return_count ? oldpkt[0] : NULL);\n+\t\t\tcnt = (pkts[0] != NULL) ? 1 : 0;\n+\t\t\tRTE_LCORE_TELEMETRY_TIMESTAMP(cnt);\n+\t\t\treturn cnt;\n+\t\t}\n+\t\treturn -EINVAL;\n \t}\n \n \trte_distributor_request_pkt(d, worker_id, oldpkt, return_count);\n \n-\tcount = rte_distributor_poll_pkt(d, worker_id, pkts);\n-\twhile (count == -1) {\n+\twhile ((count = rte_distributor_poll_pkt(d, worker_id, pkts)) == -1) {\n \t\tuint64_t t = rte_rdtsc() + 100;\n \n \t\twhile (rte_rdtsc() < t)\n \t\t\trte_pause();\n \n-\t\tcount = rte_distributor_poll_pkt(d, worker_id, pkts);\n+\t\t/* this was an empty poll */\n+\t\tRTE_LCORE_TELEMETRY_TIMESTAMP(0);\n \t}\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(count);\n \treturn count;\n }\n \ndiff --git a/lib/distributor/rte_distributor_single.c b/lib/distributor/rte_distributor_single.c\nindex 2c77ac454a..dc58791bf4 100644\n--- a/lib/distributor/rte_distributor_single.c\n+++ b/lib/distributor/rte_distributor_single.c\n@@ -31,8 +31,13 @@ rte_distributor_request_pkt_single(struct rte_distributor_single *d,\n \tunion rte_distributor_buffer_single *buf = &d->bufs[worker_id];\n \tint64_t req = (((int64_t)(uintptr_t)oldpkt) << RTE_DISTRIB_FLAG_BITS)\n \t\t\t| RTE_DISTRIB_GET_BUF;\n-\tRTE_WAIT_UNTIL_MASKED(&buf->bufptr64, RTE_DISTRIB_FLAGS_MASK,\n-\t\t==, 0, __ATOMIC_RELAXED);\n+\n+\twhile (!(__atomic_load_n(&buf->bufptr64, __ATOMIC_RELAXED)\n+\t\t\t& RTE_DISTRIB_FLAGS_MASK) == 0) {\n+\t\trte_pause();\n+\t\t/* this was an empty poll */\n+\t\tRTE_LCORE_TELEMETRY_TIMESTAMP(0);\n+\t}\n \n \t/* Sync with distributor on GET_BUF flag. */\n \t__atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE);\n@@ -59,8 +64,11 @@ rte_distributor_get_pkt_single(struct rte_distributor_single *d,\n {\n \tstruct rte_mbuf *ret;\n \trte_distributor_request_pkt_single(d, worker_id, oldpkt);\n-\twhile ((ret = rte_distributor_poll_pkt_single(d, worker_id)) == NULL)\n+\twhile ((ret = rte_distributor_poll_pkt_single(d, worker_id)) == NULL) {\n \t\trte_pause();\n+\t\t/* this was an empty poll */\n+\t\tRTE_LCORE_TELEMETRY_TIMESTAMP(0);\n+\t}\n \treturn ret;\n }\n \ndiff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h\nindex e7f992b734..98176a6a7a 100644\n--- a/lib/dmadev/rte_dmadev.h\n+++ b/lib/dmadev/rte_dmadev.h\n@@ -149,6 +149,7 @@\n #include <rte_bitops.h>\n #include <rte_common.h>\n #include <rte_compat.h>\n+#include <rte_lcore.h>\n \n #ifdef __cplusplus\n extern \"C\" {\n@@ -1027,7 +1028,7 @@ rte_dma_completed(int16_t dev_id, uint16_t vchan, const uint16_t nb_cpls,\n \t\t  uint16_t *last_idx, bool *has_error)\n {\n \tstruct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id];\n-\tuint16_t idx;\n+\tuint16_t idx, nb_ops;\n \tbool err;\n \n #ifdef RTE_DMADEV_DEBUG\n@@ -1050,8 +1051,10 @@ rte_dma_completed(int16_t dev_id, uint16_t vchan, const uint16_t nb_cpls,\n \t\thas_error = &err;\n \n \t*has_error = false;\n-\treturn (*obj->completed)(obj->dev_private, vchan, nb_cpls, last_idx,\n-\t\t\t\t has_error);\n+\tnb_ops = (*obj->completed)(obj->dev_private, vchan, nb_cpls, last_idx,\n+\t\t\t\t   has_error);\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n+\treturn nb_ops;\n }\n \n /**\n@@ -1090,7 +1093,7 @@ rte_dma_completed_status(int16_t dev_id, uint16_t vchan,\n \t\t\t enum rte_dma_status_code *status)\n {\n \tstruct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id];\n-\tuint16_t idx;\n+\tuint16_t idx, nb_ops;\n \n #ifdef RTE_DMADEV_DEBUG\n \tif (!rte_dma_is_valid(dev_id) || nb_cpls == 0 || status == NULL)\n@@ -1101,8 +1104,10 @@ rte_dma_completed_status(int16_t dev_id, uint16_t vchan,\n \tif (last_idx == NULL)\n \t\tlast_idx = &idx;\n \n-\treturn (*obj->completed_status)(obj->dev_private, vchan, nb_cpls,\n+\tnb_ops = (*obj->completed_status)(obj->dev_private, vchan, nb_cpls,\n \t\t\t\t\tlast_idx, status);\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n+\treturn nb_ops;\n }\n \n /**\ndiff --git a/lib/eal/common/eal_common_lcore_telemetry.c b/lib/eal/common/eal_common_lcore_telemetry.c\nnew file mode 100644\nindex 0000000000..e6b58788c8\n--- /dev/null\n+++ b/lib/eal/common/eal_common_lcore_telemetry.c\n@@ -0,0 +1,293 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2014 Intel Corporation\n+ */\n+\n+#include <unistd.h>\n+#include <limits.h>\n+#include <string.h>\n+\n+#include <rte_common.h>\n+#include <rte_cycles.h>\n+#include <rte_errno.h>\n+#include <rte_lcore.h>\n+\n+#ifdef RTE_LCORE_POLL_BUSYNESS\n+#include <rte_telemetry.h>\n+#endif\n+\n+int __rte_lcore_telemetry_enabled;\n+\n+#ifdef RTE_LCORE_POLL_BUSYNESS\n+\n+struct lcore_telemetry {\n+\tint busyness;\n+\t/**< Calculated busyness (gets set/returned by the API) */\n+\tint raw_busyness;\n+\t/**< Calculated busyness times 100. */\n+\tuint64_t interval_ts;\n+\t/**< when previous telemetry interval started */\n+\tuint64_t empty_cycles;\n+\t/**< empty cycle count since last interval */\n+\tuint64_t last_poll_ts;\n+\t/**< last poll timestamp */\n+\tbool last_empty;\n+\t/**< if last poll was empty */\n+\tunsigned int contig_poll_cnt;\n+\t/**< contiguous (always empty/non empty) poll counter */\n+} __rte_cache_aligned;\n+\n+static struct lcore_telemetry *telemetry_data;\n+\n+#define LCORE_POLL_BUSYNESS_MAX 100\n+#define LCORE_POLL_BUSYNESS_NOT_SET -1\n+#define LCORE_POLL_BUSYNESS_MIN 0\n+\n+#define SMOOTH_COEFF 5\n+#define STATE_CHANGE_OPT 32\n+\n+static void lcore_config_init(void)\n+{\n+\tint lcore_id;\n+\n+\ttelemetry_data = calloc(RTE_MAX_LCORE, sizeof(telemetry_data[0]));\n+\tif (telemetry_data == NULL)\n+\t\trte_panic(\"Could not init lcore telemetry data: Out of memory\\n\");\n+\n+\tRTE_LCORE_FOREACH(lcore_id) {\n+\t\tstruct lcore_telemetry *td = &telemetry_data[lcore_id];\n+\n+\t\ttd->interval_ts = 0;\n+\t\ttd->last_poll_ts = 0;\n+\t\ttd->empty_cycles = 0;\n+\t\ttd->last_empty = true;\n+\t\ttd->contig_poll_cnt = 0;\n+\t\ttd->busyness = LCORE_POLL_BUSYNESS_NOT_SET;\n+\t\ttd->raw_busyness = 0;\n+\t}\n+}\n+\n+int rte_lcore_poll_busyness(unsigned int lcore_id)\n+{\n+\tconst uint64_t active_thresh = rte_get_tsc_hz() * RTE_LCORE_POLL_BUSYNESS_PERIOD_MS;\n+\tstruct lcore_telemetry *tdata;\n+\n+\tif (lcore_id >= RTE_MAX_LCORE)\n+\t\treturn -EINVAL;\n+\ttdata = &telemetry_data[lcore_id];\n+\n+\t/* if the lcore is not active */\n+\tif (tdata->interval_ts == 0)\n+\t\treturn LCORE_POLL_BUSYNESS_NOT_SET;\n+\t/* if the core hasn't been active in a while */\n+\telse if ((rte_rdtsc() - tdata->interval_ts) > active_thresh)\n+\t\treturn LCORE_POLL_BUSYNESS_NOT_SET;\n+\n+\t/* this core is active, report its busyness */\n+\treturn telemetry_data[lcore_id].busyness;\n+}\n+\n+int rte_lcore_poll_busyness_enabled(void)\n+{\n+\treturn __rte_lcore_telemetry_enabled;\n+}\n+\n+void rte_lcore_poll_busyness_enabled_set(int enable)\n+{\n+\t__rte_lcore_telemetry_enabled = !!enable;\n+\n+\tif (!enable)\n+\t\tlcore_config_init();\n+}\n+\n+static inline int calc_raw_busyness(const struct lcore_telemetry *tdata,\n+\t\t\t\t    const uint64_t empty, const uint64_t total)\n+{\n+\t/*\n+\t * we don't want to use floating point math here, but we want for our\n+\t * busyness to react smoothly to sudden changes, while still keeping the\n+\t * accuracy and making sure that over time the average follows busyness\n+\t * as measured just-in-time. therefore, we will calculate the average\n+\t * busyness using integer math, but shift the decimal point two places\n+\t * to the right, so that 100.0 becomes 10000. this allows us to report\n+\t * integer values (0..100) while still allowing ourselves to follow the\n+\t * just-in-time measurements when we calculate our averages.\n+\t */\n+\tconst int max_raw_idle = LCORE_POLL_BUSYNESS_MAX * 100;\n+\n+\t/*\n+\t * at upper end of the busyness scale, going up from 90->100 will take\n+\t * longer than going from 10->20 because of the averaging. to address\n+\t * this, we invert the scale when doing calculations: that is, we\n+\t * effectively calculate average *idle* cycle percentage, not average\n+\t * *busy* cycle percentage. this means that the scale is naturally\n+\t * biased towards fast scaling up, and slow scaling down.\n+\t */\n+\tconst int prev_raw_idle = max_raw_idle - tdata->raw_busyness;\n+\n+\t/* calculate rate of idle cycles, times 100 */\n+\tconst int cur_raw_idle = (int)((empty * max_raw_idle) / total);\n+\n+\t/* smoothen the idleness */\n+\tconst int smoothened_idle =\n+\t\t\t(cur_raw_idle + prev_raw_idle * (SMOOTH_COEFF - 1)) / SMOOTH_COEFF;\n+\n+\t/* convert idleness back to busyness */\n+\treturn max_raw_idle - smoothened_idle;\n+}\n+\n+void __rte_lcore_telemetry_timestamp(uint16_t nb_rx)\n+{\n+\tconst unsigned int lcore_id = rte_lcore_id();\n+\tuint64_t interval_ts, empty_cycles, cur_tsc, last_poll_ts;\n+\tstruct lcore_telemetry *tdata;\n+\tconst bool empty = nb_rx == 0;\n+\tuint64_t diff_int, diff_last;\n+\tbool last_empty;\n+\n+\t/* This telemetry is not supported for unregistered non-EAL threads */\n+\tif (lcore_id >= RTE_MAX_LCORE)\n+\t\treturn;\n+\n+\ttdata = &telemetry_data[lcore_id];\n+\tlast_empty = tdata->last_empty;\n+\n+\t/* optimization: don't do anything if status hasn't changed */\n+\tif (last_empty == empty && tdata->contig_poll_cnt++ < STATE_CHANGE_OPT)\n+\t\treturn;\n+\t/* status changed or we're waiting for too long, reset counter */\n+\ttdata->contig_poll_cnt = 0;\n+\n+\tcur_tsc = rte_rdtsc();\n+\n+\tinterval_ts = tdata->interval_ts;\n+\tempty_cycles = tdata->empty_cycles;\n+\tlast_poll_ts = tdata->last_poll_ts;\n+\n+\tdiff_int = cur_tsc - interval_ts;\n+\tdiff_last = cur_tsc - last_poll_ts;\n+\n+\t/* is this the first time we're here? */\n+\tif (interval_ts == 0) {\n+\t\ttdata->busyness = LCORE_POLL_BUSYNESS_MIN;\n+\t\ttdata->raw_busyness = 0;\n+\t\ttdata->interval_ts = cur_tsc;\n+\t\ttdata->empty_cycles = 0;\n+\t\ttdata->contig_poll_cnt = 0;\n+\t\tgoto end;\n+\t}\n+\n+\t/* update the empty counter if we got an empty poll earlier */\n+\tif (last_empty)\n+\t\tempty_cycles += diff_last;\n+\n+\t/* have we passed the interval? */\n+\tuint64_t interval = ((rte_get_tsc_hz() / MS_PER_S) * RTE_LCORE_POLL_BUSYNESS_PERIOD_MS);\n+\tif (diff_int > interval) {\n+\t\tint raw_busyness;\n+\n+\t\t/* get updated busyness value */\n+\t\traw_busyness = calc_raw_busyness(tdata, empty_cycles, diff_int);\n+\n+\t\t/* set a new interval, reset empty counter */\n+\t\ttdata->interval_ts = cur_tsc;\n+\t\ttdata->empty_cycles = 0;\n+\t\ttdata->raw_busyness = raw_busyness;\n+\t\t/* bring busyness back to 0..100 range, biased to round up */\n+\t\ttdata->busyness = (raw_busyness + 50) / 100;\n+\t} else\n+\t\t/* we may have updated empty counter */\n+\t\ttdata->empty_cycles = empty_cycles;\n+\n+end:\n+\t/* update status for next poll */\n+\ttdata->last_poll_ts = cur_tsc;\n+\ttdata->last_empty = empty;\n+}\n+\n+static int\n+lcore_poll_busyness_enable(const char *cmd __rte_unused,\n+\t\t      const char *params __rte_unused,\n+\t\t      struct rte_tel_data *d)\n+{\n+\trte_lcore_poll_busyness_enabled_set(1);\n+\n+\trte_tel_data_start_dict(d);\n+\n+\trte_tel_data_add_dict_int(d, \"poll_busyness_enabled\", 1);\n+\n+\treturn 0;\n+}\n+\n+static int\n+lcore_poll_busyness_disable(const char *cmd __rte_unused,\n+\t\t       const char *params __rte_unused,\n+\t\t       struct rte_tel_data *d)\n+{\n+\trte_lcore_poll_busyness_enabled_set(0);\n+\n+\trte_tel_data_start_dict(d);\n+\n+\trte_tel_data_add_dict_int(d, \"poll_busyness_enabled\", 0);\n+\n+\tif (telemetry_data != NULL)\n+\t\tfree(telemetry_data);\n+\n+\treturn 0;\n+}\n+\n+static int\n+lcore_handle_poll_busyness(const char *cmd __rte_unused,\n+\t\t      const char *params __rte_unused, struct rte_tel_data *d)\n+{\n+\tchar corenum[64];\n+\tint i;\n+\n+\trte_tel_data_start_dict(d);\n+\n+\tRTE_LCORE_FOREACH(i) {\n+\t\tif (!rte_lcore_is_enabled(i))\n+\t\t\tcontinue;\n+\t\tsnprintf(corenum, sizeof(corenum), \"%d\", i);\n+\t\trte_tel_data_add_dict_int(d, corenum, rte_lcore_poll_busyness(i));\n+\t}\n+\n+\treturn 0;\n+}\n+\n+RTE_INIT(lcore_init_telemetry)\n+{\n+\t__rte_lcore_telemetry_enabled = true;\n+\n+\tlcore_config_init();\n+\n+\trte_telemetry_register_cmd(\"/eal/lcore/busyness\", lcore_handle_poll_busyness,\n+\t\t\t\t   \"return percentage poll busyness of cores\");\n+\n+\trte_telemetry_register_cmd(\"/eal/lcore/busyness_enable\", lcore_poll_busyness_enable,\n+\t\t\t\t   \"enable lcore poll busyness measurement\");\n+\n+\trte_telemetry_register_cmd(\"/eal/lcore/busyness_disable\", lcore_poll_busyness_disable,\n+\t\t\t\t   \"disable lcore poll busyness measurement\");\n+}\n+\n+#else\n+\n+int rte_lcore_poll_busyness(unsigned int lcore_id __rte_unused)\n+{\n+\treturn -ENOTSUP;\n+}\n+\n+int rte_lcore_poll_busyness_enabled(void)\n+{\n+\treturn -ENOTSUP;\n+}\n+\n+void rte_lcore_poll_busyness_enabled_set(int enable __rte_unused)\n+{\n+}\n+\n+void __rte_lcore_telemetry_timestamp(uint16_t nb_rx __rte_unused)\n+{\n+}\n+\n+#endif\ndiff --git a/lib/eal/common/meson.build b/lib/eal/common/meson.build\nindex 917758cc65..a743e66a7d 100644\n--- a/lib/eal/common/meson.build\n+++ b/lib/eal/common/meson.build\n@@ -17,6 +17,7 @@ sources += files(\n         'eal_common_hexdump.c',\n         'eal_common_interrupts.c',\n         'eal_common_launch.c',\n+        'eal_common_lcore_telemetry.c',\n         'eal_common_lcore.c',\n         'eal_common_log.c',\n         'eal_common_mcfg.c',\ndiff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h\nindex b598e1b9ec..75c1f874cb 100644\n--- a/lib/eal/include/rte_lcore.h\n+++ b/lib/eal/include/rte_lcore.h\n@@ -415,6 +415,86 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,\n \t\tconst pthread_attr_t *attr,\n \t\tvoid *(*start_routine)(void *), void *arg);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Read poll busyness value corresponding to an lcore.\n+ *\n+ * @param lcore_id\n+ *   Lcore to read poll busyness value for.\n+ * @return\n+ *   - value between 0 and 100 on success\n+ *   - -1 if lcore is not active\n+ *   - -EINVAL if lcore is invalid\n+ *   - -ENOMEM if not enough memory available\n+ *   - -ENOTSUP if not supported\n+ */\n+__rte_experimental\n+int\n+rte_lcore_poll_busyness(unsigned int lcore_id);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Check if lcore poll busyness telemetry is enabled.\n+ *\n+ * @return\n+ *   - 1 if lcore telemetry is enabled\n+ *   - 0 if lcore telemetry is disabled\n+ *   - -ENOTSUP if not lcore telemetry supported\n+ */\n+__rte_experimental\n+int\n+rte_lcore_poll_busyness_enabled(void);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Enable or disable poll busyness telemetry.\n+ *\n+ * @param enable\n+ *   1 to enable, 0 to disable\n+ */\n+__rte_experimental\n+void\n+rte_lcore_poll_busyness_enabled_set(int enable);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Lcore telemetry timestamping function.\n+ *\n+ * @param nb_rx\n+ *   Number of buffers processed by lcore.\n+ */\n+__rte_experimental\n+void\n+__rte_lcore_telemetry_timestamp(uint16_t nb_rx);\n+\n+/** @internal lcore telemetry enabled status */\n+extern int __rte_lcore_telemetry_enabled;\n+\n+/**\n+ * Call lcore telemetry timestamp function.\n+ *\n+ * @param nb_rx\n+ *   Number of buffers processed by lcore.\n+ */\n+#ifdef RTE_LCORE_POLL_BUSYNESS\n+#define RTE_LCORE_TELEMETRY_TIMESTAMP(nb_rx)                    \\\n+\tdo {                                                    \\\n+\t\tif (__rte_lcore_telemetry_enabled)              \\\n+\t\t\t__rte_lcore_telemetry_timestamp(nb_rx); \\\n+\t} while (0)\n+#else\n+#define RTE_LCORE_TELEMETRY_TIMESTAMP(nb_rx) \\\n+\twhile (0)\n+#endif\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/eal/meson.build b/lib/eal/meson.build\nindex 056beb9461..7199aa03c2 100644\n--- a/lib/eal/meson.build\n+++ b/lib/eal/meson.build\n@@ -25,6 +25,9 @@ subdir(arch_subdir)\n deps += ['kvargs']\n if not is_windows\n     deps += ['telemetry']\n+else\n+\t# core busyness telemetry depends on telemetry library\n+\tdpdk_conf.set('RTE_LCORE_BUSYNESS', false)\n endif\n if dpdk_conf.has('RTE_USE_LIBBSD')\n     ext_deps += libbsd\ndiff --git a/lib/eal/version.map b/lib/eal/version.map\nindex c2a2cebf69..8a4af7e937 100644\n--- a/lib/eal/version.map\n+++ b/lib/eal/version.map\n@@ -424,6 +424,13 @@ EXPERIMENTAL {\n \trte_thread_self;\n \trte_thread_set_affinity_by_id;\n \trte_thread_set_priority;\n+\n+\t# added in 22.11\n+\t__rte_lcore_telemetry_timestamp;\n+\t__rte_lcore_telemetry_enabled;\n+\trte_lcore_poll_busyness;\n+\trte_lcore_poll_busyness_enabled;\n+\trte_lcore_poll_busyness_enabled_set;\n };\n \n INTERNAL {\ndiff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h\nindex de9e970d4d..1caecd5a11 100644\n--- a/lib/ethdev/rte_ethdev.h\n+++ b/lib/ethdev/rte_ethdev.h\n@@ -5675,6 +5675,8 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,\n #endif\n \n \trte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);\n+\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_rx);\n \treturn nb_rx;\n }\n \ndiff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h\nindex 6a6f6ea4c1..a1d42d9214 100644\n--- a/lib/eventdev/rte_eventdev.h\n+++ b/lib/eventdev/rte_eventdev.h\n@@ -2153,6 +2153,7 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],\n \t\t\tuint16_t nb_events, uint64_t timeout_ticks)\n {\n \tconst struct rte_event_fp_ops *fp_ops;\n+\tuint16_t nb_evts;\n \tvoid *port;\n \n \tfp_ops = &rte_event_fp_ops[dev_id];\n@@ -2175,10 +2176,13 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],\n \t * requests nb_events as const one\n \t */\n \tif (nb_events == 1)\n-\t\treturn (fp_ops->dequeue)(port, ev, timeout_ticks);\n+\t\tnb_evts = (fp_ops->dequeue)(port, ev, timeout_ticks);\n \telse\n-\t\treturn (fp_ops->dequeue_burst)(port, ev, nb_events,\n-\t\t\t\t\t       timeout_ticks);\n+\t\tnb_evts = (fp_ops->dequeue_burst)(port, ev, nb_events,\n+\t\t\t\t\ttimeout_ticks);\n+\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_evts);\n+\treturn nb_evts;\n }\n \n #define RTE_EVENT_DEV_MAINT_OP_FLUSH          (1 << 0)\ndiff --git a/lib/rawdev/rte_rawdev.c b/lib/rawdev/rte_rawdev.c\nindex 2f0a4f132e..27163e87cb 100644\n--- a/lib/rawdev/rte_rawdev.c\n+++ b/lib/rawdev/rte_rawdev.c\n@@ -226,12 +226,15 @@ rte_rawdev_dequeue_buffers(uint16_t dev_id,\n \t\t\t   rte_rawdev_obj_t context)\n {\n \tstruct rte_rawdev *dev;\n+\tint nb_ops;\n \n \tRTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);\n \tdev = &rte_rawdevs[dev_id];\n \n \tRTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dequeue_bufs, -ENOTSUP);\n-\treturn (*dev->dev_ops->dequeue_bufs)(dev, buffers, count, context);\n+\tnb_ops = (*dev->dev_ops->dequeue_bufs)(dev, buffers, count, context);\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(nb_ops);\n+\treturn nb_ops;\n }\n \n int\ndiff --git a/lib/regexdev/rte_regexdev.h b/lib/regexdev/rte_regexdev.h\nindex 3bce8090f6..781055b4eb 100644\n--- a/lib/regexdev/rte_regexdev.h\n+++ b/lib/regexdev/rte_regexdev.h\n@@ -1530,6 +1530,7 @@ rte_regexdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,\n \t\t\t   struct rte_regex_ops **ops, uint16_t nb_ops)\n {\n \tstruct rte_regexdev *dev = &rte_regex_devices[dev_id];\n+\tuint16_t deq_ops;\n #ifdef RTE_LIBRTE_REGEXDEV_DEBUG\n \tRTE_REGEXDEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);\n \tRTE_FUNC_PTR_OR_ERR_RET(*dev->dequeue, -ENOTSUP);\n@@ -1538,7 +1539,9 @@ rte_regexdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,\n \t\treturn -EINVAL;\n \t}\n #endif\n-\treturn (*dev->dequeue)(dev, qp_id, ops, nb_ops);\n+\tdeq_ops = (*dev->dequeue)(dev, qp_id, ops, nb_ops);\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(deq_ops);\n+\treturn deq_ops;\n }\n \n #ifdef __cplusplus\ndiff --git a/lib/ring/rte_ring_elem_pvt.h b/lib/ring/rte_ring_elem_pvt.h\nindex 83788c56e6..6db09d4291 100644\n--- a/lib/ring/rte_ring_elem_pvt.h\n+++ b/lib/ring/rte_ring_elem_pvt.h\n@@ -379,6 +379,7 @@ __rte_ring_do_dequeue_elem(struct rte_ring *r, void *obj_table,\n end:\n \tif (available != NULL)\n \t\t*available = entries - n;\n+\tRTE_LCORE_TELEMETRY_TIMESTAMP(n);\n \treturn n;\n }\n \ndiff --git a/meson_options.txt b/meson_options.txt\nindex 7c220ad68d..725b851f69 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -20,6 +20,8 @@ option('enable_driver_sdk', type: 'boolean', value: false, description:\n        'Install headers to build drivers.')\n option('enable_kmods', type: 'boolean', value: false, description:\n        'build kernel modules')\n+option('enable_lcore_poll_busyness', type: 'boolean', value: true, description:\n+       'enable collection of lcore poll busyness telemetry')\n option('examples', type: 'string', value: '', description:\n        'Comma-separated list of examples to build by default')\n option('flexran_sdk', type: 'string', value: '', description:\n",
    "prefixes": [
        "v2",
        "1/3"
    ]
}