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 6AD0AA0547; Mon, 5 Dec 2022 22:11:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 572F040156; Mon, 5 Dec 2022 22:11:20 +0100 (CET) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id 5250B40151 for ; Mon, 5 Dec 2022 22:11:19 +0100 (CET) Received: by mail-pf1-f170.google.com with SMTP id g1so4588654pfk.2 for ; Mon, 05 Dec 2022 13:11:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=lSLNNWep08u0V2Af4BK+Bq5e4Okk2pCYSWXw8ax/74A=; b=WTbKyQuXSeyjJqi2tshJ0AQ889D+DyNVRkePKXd5IYSrGTFD1yX/kPBMUiC2pFRd0R Iir9BnJcxfzkHa+u2M3g4+wWw4D32rf2YPdITuCrq6NFRxdv+8RDGbIb2Ab36F7OtNCm ZgmPjjHOjWGd3f0JLNDV5pA53bU7Q6uBFbf5iQ2saeQXYAN+B6WR/MTHuHvCbBTRsNim cB5mIUyfJaNxMwJ0pC8nWE1gdbppOEVYsg8ouCaUKXudqWXedkVMgQ/pgAX8AZOlBVId kvhw6+KbnaKFQ0h8cebgM20BwhuvTgTxaxc6a9pWik8fia+5UZMW2BbK7+bzk2hMRRXW c98w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lSLNNWep08u0V2Af4BK+Bq5e4Okk2pCYSWXw8ax/74A=; b=tw/KUsWb9+HkdvWzK6w0pT99XduC9ru3j0BK+a8sbwnt3k6ayGRSVvpy7ZR5rzkUS7 jTdVhtRcx/xay7UELmllPJCYcnyCTSxoGL4lY/AYJ3/6br1+scH5eyCA724LGpO/1cwT xoF0aMHgCQqllkgrkYjGTidHmTIwcBCkuHU5bR6jsYTdXXn+jo/uSuKik3yb4UlMHSn/ Djm3AdDdBF+SjuIEp/wO6u68XYe+cdlYhNpncp0MUXY8Gn5T7E64eritM1D8fRBx38eV 3j2RLogfstpOsFpnYDhaaJUtrn7BKQ0pbI09CbLJOdzLj3pOwYH6dpqgcpYra0weVPx/ QkmA== X-Gm-Message-State: ANoB5pncZXlUciEjp/ofoyr+vJBAdBZItaXhQeTcNGrw/rfJodJb7Ocv 6f/aEZLtorVkpJsdCI0h0mXpTw== X-Google-Smtp-Source: AA0mqf4CYG97NE9n5o6X2luDvSlIqwFIbgPdln/Dy2fwfWo8XPmyRBVSYFdDWte5bVNbr0haUKopKw== X-Received: by 2002:a63:eb4b:0:b0:477:a350:2172 with SMTP id b11-20020a63eb4b000000b00477a3502172mr55916872pgk.167.1670274678224; Mon, 05 Dec 2022 13:11:18 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id v15-20020a17090ad58f00b002086ac07041sm9504047pju.44.2022.12.05.13.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 13:11:18 -0800 (PST) Date: Mon, 5 Dec 2022 13:11:16 -0800 From: Stephen Hemminger To: Tyler Retzlaff 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: <20221205131116.3c75a337@hermes.local> In-Reply-To: <1670271868-11364-2-git-send-email-roretzla@linux.microsoft.com> References: <1670271868-11364-1-git-send-email-roretzla@linux.microsoft.com> <1670271868-11364-2-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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, 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