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 014DA431FD; Wed, 25 Oct 2023 20:07:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A12584067B; Wed, 25 Oct 2023 20:07:20 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 818B640042 for ; Wed, 25 Oct 2023 20:07:19 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 4AAD5206D9; Wed, 25 Oct 2023 20:07:19 +0200 (CEST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v3 1/2] eal: add thread yield functions X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Wed, 25 Oct 2023 20:07:15 +0200 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9EF8C@smartserver.smartshare.dk> In-Reply-To: <20231025163352.1076755-2-thomas@monjalon.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v3 1/2] eal: add thread yield functions Thread-Index: AdoHYRbx4s3/hReSTgyhGBF2JzjAxgADGIIw References: <20231024125416.798897-1-thomas@monjalon.net> <20231025163352.1076755-1-thomas@monjalon.net> <20231025163352.1076755-2-thomas@monjalon.net> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Thomas Monjalon" , Cc: "David Marchand" , "Dmitry Kozlyuk" , "Narcisa Ana Maria Vasile" , "Dmitry Malloy" , "Pallavi Kadam" , "Bruce Richardson" 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: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Wednesday, 25 October 2023 18.31 >=20 > When running real-time threads, we may need to force scheduling > kernel threads or other real-time threads. > New functions are added to address these cases. >=20 > The yield functions should not have any interest for normal threads. > Note: other purposes may be addressed with rte_pause() or = rte_delay_*(). >=20 > Signed-off-by: Thomas Monjalon > --- > lib/eal/include/rte_thread.h | 22 ++++++++++++++++++++++ > lib/eal/unix/rte_thread.c | 16 ++++++++++++++++ > lib/eal/version.map | 4 ++++ > lib/eal/windows/rte_thread.c | 15 +++++++++++++++ > 4 files changed, 57 insertions(+) >=20 > diff --git a/lib/eal/include/rte_thread.h = b/lib/eal/include/rte_thread.h > index 8da9d4d3fb..139cafac96 100644 > --- a/lib/eal/include/rte_thread.h > +++ b/lib/eal/include/rte_thread.h > @@ -183,6 +183,28 @@ int rte_thread_join(rte_thread_t thread_id, > uint32_t *value_ptr); > */ > int rte_thread_detach(rte_thread_t thread_id); >=20 > +/** > + * Allow another thread to run on the same CPU core. > + * > + * Lower priority threads may not be scheduled. > + * > + * Especially useful in real-time thread priority > + * to schedule other real-time threads. > + * @see RTE_THREAD_PRIORITY_REALTIME_CRITICAL > + */ > +__rte_experimental > +void rte_thread_yield(void); > + > +/** > + * Unblock a CPU core running busy in a real-time thread. > + * > + * Especially useful in real-time thread priority > + * to avoid a busy loop blocking vital threads on a core. > + * @see RTE_THREAD_PRIORITY_REALTIME_CRITICAL > + */ > +__rte_experimental > +void rte_thread_yield_realtime(void); > + If an application really needs to use real-time priority, the behavior = of any DPDK yield functions must be documented in much more detail than = this - especially in regard to expected latency. [...] > diff --git a/lib/eal/windows/rte_thread.c = b/lib/eal/windows/rte_thread.c > index acf648456c..1e031eca40 100644 > --- a/lib/eal/windows/rte_thread.c > +++ b/lib/eal/windows/rte_thread.c > @@ -304,6 +304,21 @@ rte_thread_detach(rte_thread_t thread_id) > return 0; > } >=20 > +void > +rte_thread_yield(void) > +{ > + Sleep(0); > +} > + > +void > +rte_thread_yield_realtime(void) > +{ > + /* Real-time threads are not causing problems on Windows. > + * A normal yield should be fine. Back in the days, the Windows API had a Yield() function; make sure your = comment can't be misunderstood as referring to that. > + */ > + Sleep(0); > +}