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 B16BE41C34; Tue, 7 Feb 2023 22:41:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 42E1B40A84; Tue, 7 Feb 2023 22:41:57 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8FA5B40151 for ; Tue, 7 Feb 2023 22:41:55 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id A852920C7E35; Tue, 7 Feb 2023 13:41:54 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A852920C7E35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1675806114; bh=yFqOQ9D/4bTC5zenb7Q7xvLRl2YNYnSGNQ9ULG5Crcw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LiH/g+0ppArHav6s9OBvSGZgyHg4g05q8/lBwpFzWEUFiCF7FhgCP/lYy3yEnlcBn GUMGMYdt5E9gAUFZRu3LU0EKbxnw9YCPs/KzjaotlHDsnIwXooD7TaBCYwzLXHxdxJ JXzDZrSpDlBtYH/cyTtVydqfmVwySLv77VswP/Ec= Date: Tue, 7 Feb 2023 13:41:54 -0800 From: Tyler Retzlaff To: David Marchand Cc: dev@dpdk.org, thomas@monjalon.net, olivier.matz@6wind.com, stephen@networkplumber.org, mb@smartsharesystems.com, hofors@lysator.liu.se Subject: Re: [PATCH v5 1/3] eal: add rte control thread create API Message-ID: <20230207214154.GB30628@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1670271868-11364-1-git-send-email-roretzla@linux.microsoft.com> <1675197017-11287-1-git-send-email-roretzla@linux.microsoft.com> <1675197017-11287-2-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Tue, Feb 07, 2023 at 02:12:18PM +0100, David Marchand wrote: > On Tue, Jan 31, 2023 at 9:30 PM Tyler Retzlaff > wrote: > > > > Add rte_control_thread_create API as a replacement for > > rte_ctrl_thread_create to allow deprecation of the use of platform > > specific types in DPDK public API. > > > > Duplicate the rte_ctrl_thread_create test adapted to use > > rte_control_thread create to keep both APIs under test until > > rte_ctrl_thread_create is removed. > > > > Signed-off-by: Tyler Retzlaff > > Acked-by: Morten Brørup > > Reviewed-by: Mattias Rönnblom > > --- > > app/test/test_lcores.c | 41 ++++++++++++++++++ > > lib/eal/common/eal_common_thread.c | 85 ++++++++++++++++++++++++++++++++++---- > > lib/eal/include/rte_thread.h | 33 +++++++++++++++ > > lib/eal/version.map | 1 + > > 4 files changed, 152 insertions(+), 8 deletions(-) > > > > diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c > > index 5b43aa5..9766f78 100644 > > --- a/app/test/test_lcores.c > > +++ b/app/test/test_lcores.c > > @@ -353,6 +353,18 @@ static void *ctrl_thread_loop(void *arg) > > return NULL; > > } > > > > +static uint32_t control_thread_loop(void *arg) > > +{ > > + struct thread_context *t = arg; > > + > > + printf("Control thread running successfully\n"); > > + > > + /* Set the thread state to DONE */ > > + t->state = Thread_DONE; > > + > > + return 0; > > +} > > + > > static int > > test_ctrl_thread(void) > > { > > @@ -380,6 +392,32 @@ static void *ctrl_thread_loop(void *arg) > > } > > > > static int > > +test_control_thread(void) > > +{ > > + struct thread_context ctrl_thread_context; > > + struct thread_context *t; > > + > > + /* Create one control thread */ > > + t = &ctrl_thread_context; > > + t->state = Thread_INIT; > > + if (rte_control_thread_create(&t->id, "test_control_threads", > > + NULL, control_thread_loop, t) != 0) > > + return -1; > > + > > + /* Wait till the control thread exits. > > + * This also acts as the barrier such that the memory operations > > + * in control thread are visible to this thread. > > + */ > > + rte_thread_join(t->id, NULL); > > + > > + /* Check if the control thread set the correct state */ > > + if (t->state != Thread_DONE) > > + return -1; > > + > > + return 0; > > +} > > + > > +static int > > test_lcores(void) > > { > > unsigned int eal_threads_count = 0; > > @@ -409,6 +447,9 @@ static void *ctrl_thread_loop(void *arg) > > if (test_ctrl_thread() < 0) > > return TEST_FAILED; > > > > + if (test_control_thread() < 0) > > + return TEST_FAILED; > > + > > return TEST_SUCCESS; > > } > > > > Afair, the "legacy" API test being in test_lcores.c is mainly a side > effect of the API being defined in rte_lcore.h. > > The new API is genuinely located in rte_thread.h and there is no > consideration over lcores: control thread are just "specialised" > rte_thread objects. > I'd rather see this test in app/test/test_threads.c with other > rte_thread API tests. no problem, i wondered if i should retain the original location or not. i'll move it to test_threads.c i kind of wonder if the function should be named rte_thread_create_ctrl or something now so that all the functions from rte_thread have a consistent naming prefix? let me know if this is desired. if it is i'll submit a new version otherwise you can apply the series as is with your suggested test moved to test_threads.c below. > > I think something like below would be enough, wdyt? > If you are fine with it and there is no other comment on this patch, I > plan to do this change before applying. no problem with this, sounds good. > > > diff --git a/app/test/test_threads.c b/app/test/test_threads.c > index e0f18e4329..cc0bb69190 100644 > --- a/app/test/test_threads.c > +++ b/app/test/test_threads.c > @@ -232,6 +232,31 @@ test_thread_attributes_priority(void) > return 0; > } > > +static int > +test_control_thread_create_join(void) > +{ > + rte_thread_t thread_id; > + rte_thread_t thread_main_id; > + > + thread_id_ready = 0; > + RTE_TEST_ASSERT(rte_control_thread_create(&thread_id, > "test_control_threads", NULL, > + thread_main, &thread_main_id) == 0, > + "Failed to create thread."); > + > + while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0) > + ; > + > + RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0, > + "Unexpected thread id."); > + > + __atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE); > + > + RTE_TEST_ASSERT(rte_thread_join(thread_id, NULL) == 0, > + "Failed to join thread."); > + > + return 0; > +} > + > static struct unit_test_suite threads_test_suite = { > .suite_name = "threads autotest", > .setup = NULL, > @@ -243,6 +268,7 @@ static struct unit_test_suite threads_test_suite = { > TEST_CASE(test_thread_priority), > TEST_CASE(test_thread_attributes_affinity), > TEST_CASE(test_thread_attributes_priority), > + TEST_CASE(test_control_thread_create_join), > TEST_CASES_END() > } > }; > > > -- > David Marchand