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 531FD45A7B; Sun, 6 Oct 2024 19:06:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0318E40613; Sun, 6 Oct 2024 19:06:24 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 8AE364025D for ; Sun, 6 Oct 2024 19:06:22 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 496FwQbY029816; Sun, 6 Oct 2024 10:06:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=P uynKz4twBR6jiSs+fuJtAnqdxU7v5pDgk45TF0yuNg=; b=L0BaQC0ylVl62Q+FL yPU+yPO5kOiv/owBJHo/58zJKhuK3DbelLPrGrINaU3P6vtJb/Zb1f9PlKm77eqw /f9XA6yCOzHTrgJOpjmwP6nhNL/V4UHqf/Bw5eq0zzPXuVqZE2fOg+AqO6JnnKLP 0j63XJicNVCks81O1FXIPOm83AsAIelkXTwo8s7zrRYW9kW0cH/gDjD24jIf7Lco p7O5zKukj5U1qA8h46njGxnaaqrclkfAjkwUC2HpeujSMzeeow6NiGxmab+Plqob EsKoMRUXpXiYQ0J2gE65C/M8rXBCdhF/N6/ivfGrKiF/TOa8WuicZQzlS/UTGw/X OdHZg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 4234yg1rar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 06 Oct 2024 10:06:21 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sun, 6 Oct 2024 10:06:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Sun, 6 Oct 2024 10:06:20 -0700 Received: from MININT-80QBFE8.corp.innovium.com (MININT-80QBFE8.marvell.com [10.28.164.106]) by maili.marvell.com (Postfix) with ESMTP id 25F7D3F704C; Sun, 6 Oct 2024 10:06:15 -0700 (PDT) From: To: , , , , , , , , , CC: , Pavan Nikhilesh Subject: [PATCH v8 1/6] eventdev: introduce event pre-scheduling Date: Sun, 6 Oct 2024 22:36:03 +0530 Message-ID: <20241006170608.14182-2-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241006170608.14182-1-pbhagavatula@marvell.com> References: <20241005080001.8681-1-pbhagavatula@marvell.com> <20241006170608.14182-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: cgM2EQW7lYLN0KWYoKeXo64srdvh8wQy X-Proofpoint-ORIG-GUID: cgM2EQW7lYLN0KWYoKeXo64srdvh8wQy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 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 From: Pavan Nikhilesh Event pre-scheduling improves scheduling performance by assigning events to event ports in advance when dequeues are issued. The dequeue operation initiates the pre-schedule operation, which completes in parallel without affecting the dequeued event flow contexts and dequeue latency. Event devices can indicate pre-scheduling capabilities using `RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE` and `RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE` via the event device info function `info.event_dev_cap`. Applications can select the pre-schedule type and configure it through `rte_event_dev_config.preschedule_type` during `rte_event_dev_configure`. The supported pre-schedule types are: * `RTE_EVENT_PRESCHEDULE_NONE` - No pre-scheduling. * `RTE_EVENT_PRESCHEDULE` - Always issue a pre-schedule on dequeue. * `RTE_EVENT_PRESCHEDULE_ADAPTIVE` - Delay issuing pre-schedule until there are no forward progress constraints with the held flow contexts. Signed-off-by: Pavan Nikhilesh --- app/test/test_eventdev.c | 108 ++++++++++++++++++++ doc/guides/eventdevs/features/default.ini | 1 + doc/guides/prog_guide/eventdev/eventdev.rst | 23 +++++ doc/guides/rel_notes/release_24_11.rst | 10 ++ lib/eventdev/rte_eventdev.h | 49 +++++++++ 5 files changed, 191 insertions(+) diff --git a/app/test/test_eventdev.c b/app/test/test_eventdev.c index 9a6c8f470c..a45d1396d7 100644 --- a/app/test/test_eventdev.c +++ b/app/test/test_eventdev.c @@ -1251,6 +1251,112 @@ test_eventdev_profile_switch(void) return TEST_SUCCESS; } +static int +preschedule_test(enum rte_event_dev_preschedule_type preschedule_type, const char *preschedule_name) +{ +#define NB_EVENTS 1024 + uint64_t start, total; + struct rte_event ev; + int rc, cnt; + + ev.event_type = RTE_EVENT_TYPE_CPU; + ev.queue_id = 0; + ev.op = RTE_EVENT_OP_NEW; + ev.u64 = 0xBADF00D0; + + for (cnt = 0; cnt < NB_EVENTS; cnt++) { + ev.flow_id = cnt; + rc = rte_event_enqueue_burst(TEST_DEV_ID, 0, &ev, 1); + TEST_ASSERT(rc == 1, "Failed to enqueue event"); + } + + RTE_SET_USED(preschedule_type); + total = 0; + while (cnt) { + start = rte_rdtsc_precise(); + rc = rte_event_dequeue_burst(TEST_DEV_ID, 0, &ev, 1, 0); + if (rc) { + total += rte_rdtsc_precise() - start; + cnt--; + } + } + printf("Preschedule type : %s, avg cycles %" PRIu64 "\n", preschedule_name, + total / NB_EVENTS); + + return TEST_SUCCESS; +} + +static int +preschedule_configure(enum rte_event_dev_preschedule_type type, struct rte_event_dev_info *info) +{ + struct rte_event_dev_config dev_conf; + struct rte_event_queue_conf qcfg; + struct rte_event_port_conf pcfg; + int rc; + + devconf_set_default_sane_values(&dev_conf, info); + dev_conf.nb_event_ports = 1; + dev_conf.nb_event_queues = 1; + dev_conf.preschedule_type = type; + + rc = rte_event_dev_configure(TEST_DEV_ID, &dev_conf); + TEST_ASSERT_SUCCESS(rc, "Failed to configure eventdev"); + + rc = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pcfg); + TEST_ASSERT_SUCCESS(rc, "Failed to get port0 default config"); + rc = rte_event_port_setup(TEST_DEV_ID, 0, &pcfg); + TEST_ASSERT_SUCCESS(rc, "Failed to setup port0"); + + rc = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qcfg); + TEST_ASSERT_SUCCESS(rc, "Failed to get queue0 default config"); + rc = rte_event_queue_setup(TEST_DEV_ID, 0, &qcfg); + TEST_ASSERT_SUCCESS(rc, "Failed to setup queue0"); + + rc = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); + TEST_ASSERT(rc == (int)dev_conf.nb_event_queues, "Failed to link port, device %d", + TEST_DEV_ID); + + rc = rte_event_dev_start(TEST_DEV_ID); + TEST_ASSERT_SUCCESS(rc, "Failed to start event device"); + + return 0; +} + +static int +test_eventdev_preschedule_configure(void) +{ + struct rte_event_dev_info info; + int rc; + + rte_event_dev_info_get(TEST_DEV_ID, &info); + + if ((info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE) == 0) + return TEST_SKIPPED; + + rc = preschedule_configure(RTE_EVENT_PRESCHEDULE_NONE, &info); + TEST_ASSERT_SUCCESS(rc, "Failed to configure eventdev"); + rc = preschedule_test(RTE_EVENT_PRESCHEDULE_NONE, "RTE_EVENT_PRESCHEDULE_NONE"); + TEST_ASSERT_SUCCESS(rc, "Failed to test preschedule RTE_EVENT_PRESCHEDULE_NONE"); + + rte_event_dev_stop(TEST_DEV_ID); + rc = preschedule_configure(RTE_EVENT_PRESCHEDULE, &info); + TEST_ASSERT_SUCCESS(rc, "Failed to configure eventdev"); + rc = preschedule_test(RTE_EVENT_PRESCHEDULE, "RTE_EVENT_PRESCHEDULE"); + TEST_ASSERT_SUCCESS(rc, "Failed to test preschedule RTE_EVENT_PRESCHEDULE"); + + if (info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE) { + rte_event_dev_stop(TEST_DEV_ID); + rc = preschedule_configure(RTE_EVENT_PRESCHEDULE_ADAPTIVE, &info); + TEST_ASSERT_SUCCESS(rc, "Failed to configure eventdev"); + rc = preschedule_test(RTE_EVENT_PRESCHEDULE_ADAPTIVE, + "RTE_EVENT_PRESCHEDULE_ADAPTIVE"); + TEST_ASSERT_SUCCESS(rc, + "Failed to test preschedule RTE_EVENT_PRESCHEDULE_ADAPTIVE"); + } + + return TEST_SUCCESS; +} + static int test_eventdev_close(void) { @@ -1311,6 +1417,8 @@ static struct unit_test_suite eventdev_common_testsuite = { test_eventdev_start_stop), TEST_CASE_ST(eventdev_configure_setup, eventdev_stop_device, test_eventdev_profile_switch), + TEST_CASE_ST(eventdev_configure_setup, NULL, + test_eventdev_preschedule_configure), TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device, test_eventdev_link), TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device, diff --git a/doc/guides/eventdevs/features/default.ini b/doc/guides/eventdevs/features/default.ini index 1cc4303fe5..c8d5ed2d74 100644 --- a/doc/guides/eventdevs/features/default.ini +++ b/doc/guides/eventdevs/features/default.ini @@ -22,6 +22,7 @@ carry_flow_id = maintenance_free = runtime_queue_attr = profile_links = +preschedule = ; ; Features of a default Ethernet Rx adapter. diff --git a/doc/guides/prog_guide/eventdev/eventdev.rst b/doc/guides/prog_guide/eventdev/eventdev.rst index fb6dfce102..9da5531859 100644 --- a/doc/guides/prog_guide/eventdev/eventdev.rst +++ b/doc/guides/prog_guide/eventdev/eventdev.rst @@ -357,6 +357,29 @@ Worker path: // Process the event received. } +Event Pre-scheduling +~~~~~~~~~~~~~~~~~~~~ + +Event pre-scheduling improves scheduling performance by assigning events to event ports in advance +when dequeues are issued. +The `rte_event_dequeue_burst` operation initiates the pre-schedule operation, which completes +in parallel without affecting the dequeued event flow contexts and dequeue latency. +On the next dequeue operation, the pre-scheduled events are dequeued and pre-schedule is initiated +again. + +An application can use event pre-scheduling if the event device supports it at either device +level or at a individual port level. +The application must check pre-schedule capability by checking if ``rte_event_dev_info.event_dev_cap`` +has the bit ``RTE_EVENT_DEV_CAP_PRESCHEDULE`` or ``RTE_EVENT_DEV_CAP_PRESCHEDULE_ADAPTIVE`` set, if +present pre-scheduling can be enabled at device +configuration time by setting appropriate pre-schedule type in ``rte_event_dev_config.preschedule``. + +The following pre-schedule types are supported: + * ``RTE_EVENT_PRESCHEDULE_NONE`` - No pre-scheduling. + * ``RTE_EVENT_PRESCHEDULE`` - Always issue a pre-schedule when dequeue is issued. + * ``RTE_EVENT_PRESCHEDULE_ADAPTIVE`` - Issue pre-schedule when dequeue is issued and there are + no forward progress constraints. + Starting the EventDev ~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index e0a9aa55a1..a294a753e7 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -67,6 +67,14 @@ New Features The new statistics are useful for debugging and profiling. +* **Added event device pre-scheduling support.** + + Added support for pre-scheduling of events to event ports to improve + scheduling performance and latency. + + * Added ``rte_event_dev_config::preschedule_type`` to configure the device + level pre-scheduling type. + Removed Items ------------- @@ -112,6 +120,8 @@ ABI Changes Also, make sure to start the actual text at the margin. ======================================================= +* eventdev: Added ``preschedule_type`` field to ``rte_event_dev_config`` + structure. Known Issues ------------ diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h index 08e5f9320b..4b69e74577 100644 --- a/lib/eventdev/rte_eventdev.h +++ b/lib/eventdev/rte_eventdev.h @@ -446,6 +446,30 @@ struct rte_event; * @see RTE_SCHED_TYPE_PARALLEL */ +#define RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE (1ULL << 16) +/**< Event device supports event pre-scheduling. + * + * When this capability is available, the application can enable event pre-scheduling on the event + * device to pre-schedule events to a event port when `rte_event_dequeue_burst()` + * is issued. + * The pre-schedule process starts with the `rte_event_dequeue_burst()` call and the + * pre-scheduled events are returned on the next `rte_event_dequeue_burst()` call. + * + * @see rte_event_dev_configure() + */ + +#define RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE (1ULL << 17) +/**< Event device supports adaptive event pre-scheduling. + * + * When this capability is available, the application can enable adaptive pre-scheduling + * on the event device where the events are pre-scheduled when there are no forward + * progress constraints with the currently held flow contexts. + * The pre-schedule process starts with the `rte_event_dequeue_burst()` call and the + * pre-scheduled events are returned on the next `rte_event_dequeue_burst()` call. + * + * @see rte_event_dev_configure() + */ + /* Event device priority levels */ #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0 /**< Highest priority level for events and queues. @@ -680,6 +704,26 @@ rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, * @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst() */ +/** Event device pre-schedule type enumeration. */ +enum rte_event_dev_preschedule_type { + RTE_EVENT_PRESCHEDULE_NONE, + /**< Disable pre-schedule across the event device or on a given event port. + * @ref rte_event_dev_config.preschedule_type + */ + RTE_EVENT_PRESCHEDULE, + /**< Enable pre-schedule always across the event device or a given event port. + * @ref rte_event_dev_config.preschedule_type + * @see RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE + */ + RTE_EVENT_PRESCHEDULE_ADAPTIVE, + /**< Enable adaptive pre-schedule across the event device or a given event port. + * Delay issuing pre-schedule until there are no forward progress constraints with + * the held flow contexts. + * @ref rte_event_dev_config.preschedule_type + * @see RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE + */ +}; + /** Event device configuration structure */ struct rte_event_dev_config { uint32_t dequeue_timeout_ns; @@ -752,6 +796,11 @@ struct rte_event_dev_config { * optimized for single-link usage, this field is a hint for how many * to allocate; otherwise, regular event ports and queues will be used. */ + enum rte_event_dev_preschedule_type preschedule_type; + /**< Event pre-schedule type to use across the event device, if supported. + * @see RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE + * @see RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE + */ }; /** -- 2.25.1