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 F3C3241C30; Tue, 7 Feb 2023 14:12:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77CA54021F; Tue, 7 Feb 2023 14:12:36 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 474ED40042 for ; Tue, 7 Feb 2023 14:12:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675775554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KS7La64Z2XjlK7uOiMB/hXONwbVlGkBvWXonqBLUlf4=; b=ayrSckAlYEsM6KEHrIKT02lQVz9k5yce/5SqSgBXZZ+O8+fBZHKVh7608ug5X1Cned+CKY sHoTOKDkqMHeSNyZ5TAACExaxOrJVDZFIMdX6aauuJ8GOonLYExEqAHZp24r058i0t9N5S omUKdOoaBeV6MuJXZ7FpDnq99djbHWg= Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-643-07clavARN1-_fq2S3gUMUQ-1; Tue, 07 Feb 2023 08:12:31 -0500 X-MC-Unique: 07clavARN1-_fq2S3gUMUQ-1 Received: by mail-pg1-f198.google.com with SMTP id q130-20020a632a88000000b004a03cfb3ac6so6664783pgq.6 for ; Tue, 07 Feb 2023 05:12:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KS7La64Z2XjlK7uOiMB/hXONwbVlGkBvWXonqBLUlf4=; b=M/+EIgdtVuAHstgaDXixtMKgPAspmyfXi0Q8fPiCCbtmCWWb2TyJEJoGs7niwUyuRD xTTNQrNpxk5ZIUoRuy5dMxKq5o1detYwE9dPVqgj2k/czacojfyorHoKpUyUkPsudG6A 5NVWlC3Ibh3XFYK6t8MA93pvF9mCUcVWRSxWdx4npcljVST+hnTnQl7cEke1DsB3H6rf VA9A/t8ZKRBYvyK+AiHgAQlJR24JErZwtiLnwdVYeZdh8q+iwGhXn2dSKMlo+v5wO1BE MZZYwK+fTVMEV8CnNJcTE7+U8m9Rj8vBopM/lhVz89EoLsm2mGoRMN5dfaJYzxVjG0bE 1fjg== X-Gm-Message-State: AO0yUKUxXpd+6lwSdHkQX2HFuSZP2jAzWlkU7TGI0HObnvqbLXW+I7xQ +DGN37Wpjl1FaUnhLLshOVga+x+SA6Q8RZ0W7WreB/MRuTJe3Dmuldj1fUbJQSRj4DookEJ29KO LcioCVjST6U8zpw3pbd0= X-Received: by 2002:a17:90a:9f91:b0:230:b57f:5229 with SMTP id o17-20020a17090a9f9100b00230b57f5229mr1813045pjp.68.1675775550496; Tue, 07 Feb 2023 05:12:30 -0800 (PST) X-Google-Smtp-Source: AK7set8YJAZSzYNjOGl4w99QriNHHzipvHzABdWMX/zoG48OQvQgfnpxSICvbjQa/MWcINhcx291/mBjygBxEd8QazI= X-Received: by 2002:a17:90a:9f91:b0:230:b57f:5229 with SMTP id o17-20020a17090a9f9100b00230b57f5229mr1813026pjp.68.1675775550028; Tue, 07 Feb 2023 05:12:30 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <1675197017-11287-2-git-send-email-roretzla@linux.microsoft.com> From: David Marchand Date: Tue, 7 Feb 2023 14:12:18 +0100 Message-ID: Subject: Re: [PATCH v5 1/3] eal: add rte control thread create API To: Tyler Retzlaff Cc: dev@dpdk.org, thomas@monjalon.net, olivier.matz@6wind.com, stephen@networkplumber.org, mb@smartsharesystems.com, hofors@lysator.liu.se X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, 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=C3=B8rup > Reviewed-by: Mattias R=C3=B6nnblom > --- > 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 =3D arg; > + > + printf("Control thread running successfully\n"); > + > + /* Set the thread state to DONE */ > + t->state =3D 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 =3D &ctrl_thread_context; > + t->state =3D Thread_INIT; > + if (rte_control_thread_create(&t->id, "test_control_threads", > + NULL, control_thread_loop, t) != =3D 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 !=3D Thread_DONE) > + return -1; > + > + return 0; > +} > + > +static int > test_lcores(void) > { > unsigned int eal_threads_count =3D 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. 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. 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 =3D 0; + RTE_TEST_ASSERT(rte_control_thread_create(&thread_id, "test_control_threads", NULL, + thread_main, &thread_main_id) =3D=3D 0, + "Failed to create thread."); + + while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) =3D=3D 0= ) + ; + + RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) !=3D 0, + "Unexpected thread id."); + + __atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE); + + RTE_TEST_ASSERT(rte_thread_join(thread_id, NULL) =3D=3D 0, + "Failed to join thread."); + + return 0; +} + static struct unit_test_suite threads_test_suite =3D { .suite_name =3D "threads autotest", .setup =3D NULL, @@ -243,6 +268,7 @@ static struct unit_test_suite threads_test_suite =3D { 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() } }; --=20 David Marchand