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 E7F3DA0550; Tue, 6 Dec 2022 01:21:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB06640156; Tue, 6 Dec 2022 01:21:43 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1A12F40151 for ; Tue, 6 Dec 2022 01:21:42 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 6E95A20B83CB; Mon, 5 Dec 2022 16:21:41 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6E95A20B83CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670286101; bh=MNTPISjKuFonVIFBzfFIfpKAw2+He3lkDX49ab40kRQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ifc9O91AX3GKxy4Pk8/Yvm/FtgkE8FYIcrQ229g9/j8kgWQXYE2Mch+FMmKx38iVI 1fxaiYsGi1YCU5xb9M7SQ+uWvh/uqOPFZekebRSsizzxBPXTSG68KiCy9+k5ZnB75z fB+yWSS58CjxApcQRMFwqD2lqM89aaNm10m6mTbM= Date: Mon, 5 Dec 2022 16:21:41 -0800 From: Tyler Retzlaff To: Stephen Hemminger Cc: dev@dpdk.org, thomas@monjalon.net, david.marchand@redhat.com, olivier.matz@6wind.com Subject: Re: [PATCH 1/3] eal: add rte control thread create API Message-ID: <20221206002141.GA11609@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1670271868-11364-1-git-send-email-roretzla@linux.microsoft.com> <1670271868-11364-2-git-send-email-roretzla@linux.microsoft.com> <20221205131116.3c75a337@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221205131116.3c75a337@hermes.local> 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 Mon, Dec 05, 2022 at 01:11:16PM -0800, Stephen Hemminger wrote: > On Mon, 5 Dec 2022 12:24:26 -0800 > Tyler Retzlaff wrote: > > > Signed-off-by: Tyler Retzlaff > > --- > > lib/eal/common/eal_common_thread.c | 93 ++++++++++++++++++++++++++++++++++---- > > lib/eal/include/rte_thread.h | 29 ++++++++++++ > > lib/eal/version.map | 3 ++ > > 3 files changed, 117 insertions(+), 8 deletions(-) > > > > diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c > > index c5d8b43..ca85c51 100644 > > --- a/lib/eal/common/eal_common_thread.c > > +++ b/lib/eal/common/eal_common_thread.c > > @@ -234,7 +234,10 @@ enum __rte_ctrl_thread_status { > > }; > > > > struct rte_thread_ctrl_params { > > - void *(*start_routine)(void *); > > + union { > > + void * (*start_routine)(void *); > > + rte_thread_func thread_func; > > + } u; > > Why not just use rte_thread_func, this in internal. > > > void *arg; > > int ret; > > /* Control thread status. > > @@ -243,14 +246,12 @@ struct rte_thread_ctrl_params { > > enum __rte_ctrl_thread_status ctrl_thread_status; > > }; > > > > -static void *ctrl_thread_init(void *arg) > > +static int ctrl_thread_init(void *arg) > > { > > struct internal_config *internal_conf = > > eal_get_internal_configuration(); > > rte_cpuset_t *cpuset = &internal_conf->ctrl_cpuset; > > struct rte_thread_ctrl_params *params = arg; > > - void *(*start_routine)(void *) = params->start_routine; > > - void *routine_arg = params->arg; > > > > __rte_thread_init(rte_lcore_id(), cpuset); > > params->ret = pthread_setaffinity_np(pthread_self(), sizeof(*cpuset), > > @@ -258,13 +259,35 @@ static void *ctrl_thread_init(void *arg) > > if (params->ret != 0) { > > __atomic_store_n(¶ms->ctrl_thread_status, > > CTRL_THREAD_ERROR, __ATOMIC_RELEASE); > > - return NULL; > > + return params->ret; > > } > > > > __atomic_store_n(¶ms->ctrl_thread_status, > > CTRL_THREAD_RUNNING, __ATOMIC_RELEASE); > > > > - return start_routine(routine_arg); > > + return 0; > > +} > > + > > +static void *ctrl_thread_start(void *arg) > > +{ > > + struct rte_thread_ctrl_params *params = arg; > > + void *(*start_routine)(void *) = params->u.start_routine; > > + > > + if (0 != ctrl_thread_init(arg)) > > + return NULL; > > DPDK uses the Linux not Windows coding style. > Windows uses the constant on left side of comparison because of the common > programming error of putting assignment where conditional was intended. > Linux uses a compiler that puts out a warning, so the more natural > style is action != result yes, of course. i will fix this along with another minor style problem picked up by the CI. thanks.