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 354A445954; Tue, 10 Sep 2024 10:31:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C7A8427B3; Tue, 10 Sep 2024 10:31:38 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 2C502427AD for ; Tue, 10 Sep 2024 10:31:36 +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 489Kq7fp007328; Tue, 10 Sep 2024 01:31:35 -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=u dbc2B0n7R81gTbWD6/anvmo4KHVI44XlUx8rkaVyTs=; b=jW6g8NIfhHaT5VAGb LsMW3vdy39h7N/tGIM8ak1sGYyLA0Yn3s/G3A/6Rtk6JI1w3u//MatlHUwmH7BT/ bkU92CnRUAXl4X0Gsjibq+Q28sro8gjhrRQvZQmvG7sbDATpw87mQZWHdPT8NUQp l9wBmaYX2GUvm9Dv5QCnlE8AueQFK+ffrd7JuFTnKjMnwd9+GzfAZah7in1HaBTQ cw9XWfD11ryWucj1OrSccVWTGZLJiRhYc2AEM9/hBNqSUc4/iAVVbpTJFMerxHSb 56oAuowtLZXnp0rET0aLa5lC9MSh16EoJSOW+G/Lrh30hPsqHjJo2hIsLekOsWpd 6V2dg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41gyc08196-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Sep 2024 01:31:34 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 10 Sep 2024 01:31:33 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 10 Sep 2024 01:31:33 -0700 Received: from MININT-80QBFE8.corp.innovium.com (MININT-80QBFE8.marvell.com [10.28.164.106]) by maili.marvell.com (Postfix) with ESMTP id C869F3F709E; Tue, 10 Sep 2024 01:31:29 -0700 (PDT) From: To: , , , , , , , , CC: , Pavan Nikhilesh Subject: [RFC 1/3] eventdev: introduce event prefetching Date: Tue, 10 Sep 2024 14:01:15 +0530 Message-ID: <20240910083117.4281-2-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910083117.4281-1-pbhagavatula@marvell.com> References: <20240910083117.4281-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: aBlU26bW9zMxeSk6zSJjua4P6C7ZKJpa X-Proofpoint-GUID: aBlU26bW9zMxeSk6zSJjua4P6C7ZKJpa 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 prefetching enhances scheduling performance by pre-scheduling events to event ports when dequeues are issued. The dequeue operation initiates the prefetch operation, which completes in parallel without affecting the dequeued event flow contexts and dequeue latency. Event devices can indicate prefetching capabilities using `RTE_EVENT_DEV_CAP_EVENT_PREFETCH` and `RTE_EVENT_DEV_CAP_EVENT_INTELLIGENT_PREFETCH` via the event device info function `info.event_dev_cap`. Applications can select the prefetch type and configure it via `rte_event_dev_config.prefetch_type` in the `rte_event_dev_configure` API. The supported prefetch types are: * `RTE_EVENT_DEV_PREFETCH_NONE` - No prefetching. * `RTE_EVENT_DEV_PREFETCH` - Always issue a prefetch on dequeue. * `RTE_EVENT_DEV_PREFETCH_INTELLIGENT` - Delay issuing prefetch until there are no forward progress constraints with the held flow contexts. Signed-off-by: Pavan Nikhilesh --- app/test/test_eventdev.c | 62 +++++++++++++++++++++ doc/guides/prog_guide/eventdev/eventdev.rst | 22 ++++++++ lib/eventdev/rte_eventdev.h | 48 ++++++++++++++++ 3 files changed, 132 insertions(+) diff --git a/app/test/test_eventdev.c b/app/test/test_eventdev.c index e4e234dc98..1fd3d1fa69 100644 --- a/app/test/test_eventdev.c +++ b/app/test/test_eventdev.c @@ -1250,6 +1250,66 @@ test_eventdev_profile_switch(void) return TEST_SUCCESS; } +static int +prefetch_test(rte_event_dev_prefetch_type_t prefetch_type, const char *prefetch_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(prefetch_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("Prefetch type : %s, avg cycles %" PRIu64 "\n", prefetch_name, total / NB_EVENTS); + + return TEST_SUCCESS; +} + +static int +test_eventdev_prefetch_configure(void) +{ + struct rte_event_dev_config dev_conf; + 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_PREFETCH) == 0) + return TEST_SKIPPED; + + devconf_set_default_sane_values(&dev_conf, &info); + dev_conf.prefetch_type = RTE_EVENT_DEV_PREFETCH; + rc = rte_event_dev_configure(TEST_DEV_ID, &dev_conf); + TEST_ASSERT_SUCCESS(rc, "Failed to configure eventdev"); + + rc = prefetch_test(RTE_EVENT_DEV_PREFETCH_NONE, "RTE_EVENT_DEV_PREFETCH_NONE"); + rc |= prefetch_test(RTE_EVENT_DEV_PREFETCH, "RTE_EVENT_DEV_PREFETCH"); + if (info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_INTELLIGENT_PREFETCH) + rc |= prefetch_test(RTE_EVENT_DEV_PREFETCH_INTELLIGENT, + "RTE_EVENT_DEV_PREFETCH_INTELLIGENT"); + + return rc; +} + static int test_eventdev_close(void) { @@ -1310,6 +1370,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_prefetch_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/prog_guide/eventdev/eventdev.rst b/doc/guides/prog_guide/eventdev/eventdev.rst index fb6dfce102..89064883b7 100644 --- a/doc/guides/prog_guide/eventdev/eventdev.rst +++ b/doc/guides/prog_guide/eventdev/eventdev.rst @@ -357,6 +357,28 @@ Worker path: // Process the event received. } +Event Prefetching +~~~~~~~~~~~~~~~~~ + +Event prefetching enhances scheduling performance by pre-scheduling events to event ports +when dequeues are issued. +The `rte_event_dequeue_burst` operation initiates the prefetch operation, which completes +in parallel without affecting the dequeued event flow contexts and dequeue latency. +On the next dequeue operation, the prefetched events are dequeued and prefetch is initiated +again. + +An application can use event prefetching if the event device supports it at either device +level or at a individual port level. +The application can check prefetch capability by checking if ``rte_event_dev_info.event_dev_cap`` +has the bit ``RTE_EVENT_DEV_CAP_PREFETCH`` set, if present prefetching can be enabled at device +configuration time by setting appropriate prefetch type in ``rte_event_dev_config.prefetch``. + +Currently, the following prefetch types are supported: + * ``RTE_EVENT_DEV_PREFETCH_NONE`` - No prefetching. + * ``RTE_EVENT_DEV_PREFETCH`` - Always issue a prefetch when dequeue is issued. + * ``RTE_EVENT_DEV_PREFETCH_INTELLIGENT`` - Issue prefetch when dequeue is issued and there are + no forward progress constraints. + Starting the EventDev ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h index 08e5f9320b..59c323c8ee 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_PREFETCH (1ULL << 16) +/**< Event device supports event prefetching. + * + * When this capability is available, the application can enable event prefetching on the event + * device to prefetch/pre-schedule events to a event port when `rte_event_dequeue_burst()` + * is issued. + * The prefetch process starts with the `rte_event_dequeue_burst()` call and the + * prefetched events are returned on the next `rte_event_dequeue_burst()` call. + * + * @see rte_event_dev_configure() + */ + +#define RTE_EVENT_DEV_CAP_EVENT_INTELLIGENT_PREFETCH (1ULL << 17) +/**< Event device supports intelligent event prefetching. + * + * When this capability is available, the application can enable intelligent prefetching + * on the event device where the events are prefetched/pre-scheduled when + * there are no forward progress constraints with the currently held flow contexts. + * The prefetch process starts with the `rte_event_dequeue_burst()` call and the + * prefetched 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,25 @@ rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, * @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst() */ +typedef enum { + RTE_EVENT_DEV_PREFETCH_NONE = 0, + /* Disable prefetch across the event device or on a given event port. + * @ref rte_event_dev_config.prefetch_type + */ + RTE_EVENT_DEV_PREFETCH, + /* Enable prefetch always across the event device or a given event port. + * @ref rte_event_dev_config.prefetch_type + * @see RTE_EVENT_DEV_CAP_EVENT_PREFETCH + */ + RTE_EVENT_DEV_PREFETCH_INTELLIGENT, + /* Enable intelligent prefetch across the event device or a given event port. + * Delay issuing prefetch until there are no forward progress constraints with + * the held flow contexts. + * @ref rte_event_dev_config.prefetch_type + * @see RTE_EVENT_DEV_CAP_EVENT_INTELLIGENT_PREFETCH + */ +} rte_event_dev_prefetch_type_t; + /** Event device configuration structure */ struct rte_event_dev_config { uint32_t dequeue_timeout_ns; @@ -752,6 +795,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. */ + rte_event_dev_prefetch_type_t prefetch_type; + /**< Event prefetch type to use across the event device, if supported. + * @see RTE_EVENT_DEV_CAP_EVENT_PREFETCH + * @see RTE_EVENT_DEV_CAP_EVENT_INTELLIGENT_PREFETCH + */ }; /** -- 2.25.1