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 B0D7D42588; Wed, 13 Sep 2023 13:45:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B7DF409FA; Wed, 13 Sep 2023 13:45:56 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 5CCB040A6F for ; Wed, 13 Sep 2023 13:45:54 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EA8F33200919; Wed, 13 Sep 2023 07:45:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 13 Sep 2023 07:45:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694605552; x=1694691952; bh=yAqhi5WcODEXLT25jJCPVZkr3LmIozel/Ly duQuyWpA=; b=FAU2IoS0xKff3JwIm05PKcgtV4vUwASI/jAcV7oNmf0RDkEOzD5 4vgWmoxrzmbrKwlpk3r4zm56f4tC0KSoPiyiKocphrHF+2zCV7MMQRvOTyTa9Oci eUxyE5hWzJGqV8rPr0jHzm/vXIk1o/5t/709bncy5CFS78vmUty0s13iide9tHGp xqfwgTu2XLi24bLsNBxs5qTguYFJ+JWPJ8UXAoHsUyhNmnbY66cEOUI2Un8TuQFx HztBZClZ3yDDDnxy9g1RWh+7e+ZYlHNQK7Xk15qqZN23YCLN9p8Clsr+/3ZqwZ5C nGtYNMVuMN9wbqlufsBBoKL2pDDw5GBeE6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694605552; x=1694691952; bh=yAqhi5WcODEXLT25jJCPVZkr3LmIozel/Ly duQuyWpA=; b=gTQkxR4SJt6kxlE5mUs315zCQ9HuPFpsZlCyTz8bQxtx/ATxYlh +pBX1pdi342KCt14DddhQJsBkG82UXsLBSVeNFcFATpCZURcOiGTu62gHbmOgh19 0VTzg8iGZj8aCdoEbcfwUZCjKJffZdQf7cvjMFBDp0IhodFDrBAKpDzZaj7Ovz0C yJRwouL920Flt1vJF/LstlbhopVGyZnn/t3N0HhEdcXnn+H+oDTm1t80uLHARRwY uO/q1DmyAUyVkLzsNcqCqhIJKSZjz3ATW0+kLulqtzE9N8yoGKTWL06RMZL/5QzB TAVwXP6Xo2CpGqaFM0SNxfRh4W/lruCCTHg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 07:45:51 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Maxime Coquelin , Chenbo Xia Subject: [PATCH v3 08/11] examples: convert to normal control threads Date: Wed, 13 Sep 2023 13:28:21 +0200 Message-ID: <20230913114351.1940459-9-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913114351.1940459-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913114351.1940459-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Calls to rte_ctrl_thread_create() are replaced with rte_thread_create_control(). In vhost_blk, the control thread is not forced to be scheduled on core 0 anymore. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- examples/vhost/main.c | 9 +++++---- examples/vhost_blk/vhost_blk.c | 21 ++++++--------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 9ff2c1f31b..ce5c1efddf 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "main.h" @@ -1807,7 +1808,7 @@ static const struct rte_vhost_device_ops virtio_net_device_ops = * This is a thread will wake up after a period to print stats if the user has * enabled them. */ -static void * +static uint32_t print_stats(__rte_unused void *arg) { struct vhost_dev *vdev; @@ -1852,7 +1853,7 @@ print_stats(__rte_unused void *arg) fflush(stdout); } - return NULL; + return 0; } static void @@ -1907,7 +1908,7 @@ main(int argc, char *argv[]) unsigned nb_ports, valid_num_ports; int ret, i; uint16_t portid; - static pthread_t tid; + rte_thread_t tid; uint64_t flags = RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS; signal(SIGINT, sigint_handler); @@ -1986,7 +1987,7 @@ main(int argc, char *argv[]) /* Enable stats if the user option is set. */ if (enable_stats) { - ret = rte_ctrl_thread_create(&tid, "dpdk-vhost-stat", NULL, + ret = rte_thread_create_control(&tid, "dpdk-vhost-stat", print_stats, NULL); if (ret < 0) rte_exit(EXIT_FAILURE, diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c index 45699eb0b3..376f7b89a7 100644 --- a/examples/vhost_blk/vhost_blk.c +++ b/examples/vhost_blk/vhost_blk.c @@ -5,8 +5,6 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#include -#include #include #include @@ -529,12 +527,10 @@ process_vq(struct vhost_blk_queue *vq) } } -static void * +static uint32_t ctrlr_worker(void *arg) { struct vhost_blk_ctrlr *ctrlr = (struct vhost_blk_ctrlr *)arg; - cpu_set_t cpuset; - pthread_t thread; int i; fprintf(stdout, "Ctrlr Worker Thread start\n"); @@ -546,11 +542,6 @@ ctrlr_worker(void *arg) exit(0); } - thread = pthread_self(); - CPU_ZERO(&cpuset); - CPU_SET(0, &cpuset); - pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset); - for (i = 0; i < NUM_OF_BLK_QUEUES; i++) submit_inflight_vq(&ctrlr->queues[i]); @@ -560,7 +551,7 @@ ctrlr_worker(void *arg) fprintf(stdout, "Ctrlr Worker Thread Exiting\n"); sem_post(&exit_sem); - return NULL; + return 0; } static int @@ -605,7 +596,7 @@ new_device(int vid) struct vhost_blk_queue *vq; char path[PATH_MAX]; uint64_t features, protocol_features; - pthread_t tid; + rte_thread_t tid; int i, ret; bool packed_ring, inflight_shmfd; @@ -686,15 +677,15 @@ new_device(int vid) /* start polling vring */ worker_thread_status = WORKER_STATE_START; fprintf(stdout, "New Device %s, Device ID %d\n", path, vid); - if (rte_ctrl_thread_create(&tid, "dpdk-vhost-blk", NULL, - &ctrlr_worker, ctrlr) != 0) { + if (rte_thread_create_control(&tid, "dpdk-vhost-blk", + &ctrlr_worker, ctrlr) != 0) { fprintf(stderr, "Worker Thread Started Failed\n"); return -1; } /* device has been started */ ctrlr->started = 1; - pthread_detach(tid); + rte_thread_detach(tid); return 0; } -- 2.42.0