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 6CFEFA0562; Fri, 19 Mar 2021 15:59:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 477C3140FB0; Fri, 19 Mar 2021 15:58:09 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id D4D84140F70; Fri, 19 Mar 2021 15:58:05 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 617AE5C0198; Fri, 19 Mar 2021 10:58:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 19 Mar 2021 10:58:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=YAtp25nt5or0k Nw8KTqrdY8W6qDzYkwRPti1hj6eko0=; b=buOF09xcbd7c0z7APYFrnlwIYasiE smLjy71cV16C/2jaIARwgid/sJUtfGahTtsNUk6P0WHmfYaiUAoLmHC4Mhj31eKt xtuVjDxD2wF6pl2P1ZcgA0v+ZW48qOh7w0tndRsJoZB3P8bySXiCoVURFbCZoAmK Eu8LDfA6voUHHrfuxE7SdBmdBd+vBpFeBmgJPbjz/Fc8p+PZ+AggNNgGGP9yGAOI CuFxg7sGKqmIg6tCkpAa5AQksxuT7B1uxFfy/g6g4sWad8wWiEZ7BFtfaRZuH9XO 18kIS4VEOlsVIDlB2vFtj4rmkBM5YwWL0/kvKreVdbpEHfoN8zutG/YDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=YAtp25nt5or0kNw8KTqrdY8W6qDzYkwRPti1hj6eko0=; b=NP8HElc1 70ftAC9mdCstbggtZwkRH67bxALz76wEa41GfVYfEKy0arQe54timpBb3Xx2JrKa lTSAorupOZrDbVn6j3mQDc0F6eEHAD43d3OfRbROfENaZ7SUFj2tlRCXs6QkZjCX sDyUer0qPIxuxK83HSfuzbcOO5pI2rcRQRQhPxfL7YgI/J9zTPk9EhMPxt3sxT03 3nBaBH2OrH1jVudGtZz6PRxgKar8P8vN13KHxmmbAR+tJcbEt/pygjQpDlkE2PuL EG0TYF1FKjFi/YTRyq108VKm6jQSit3SyU6b/3DH0uOunwDGQZNShFKlf+yh6ktT ZbmZmmJIqZEICA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefkedgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpeeinecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 4C9D9240069; Fri, 19 Mar 2021 10:58:04 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ncopa@alpinelinux.org, stable@dpdk.org, Matan Azrad , Andrew Rybchenko , David Marchand , Viacheslav Ovsiienko , Xueming Li , Maxime Coquelin Date: Fri, 19 Mar 2021 15:57:27 +0100 Message-Id: <20210319145730.3555384-15-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210319145730.3555384-1-thomas@monjalon.net> References: <20190313170657.16688-1-ncopa@alpinelinux.org> <20210319145730.3555384-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 14/17] vdpa/mlx5: replace pthread functions unavailable in musl 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 Sender: "dev" 1/ The function pthread_yield() does not exist in musl libc, and can be replaced with sched_yield() after including sched.h. 2/ The function pthread_attr_setaffinity_np() does not exist in musl libc, and can be replaced with pthread_setaffinity_np() after pthread_create(). Fixes: b7fa0bf4d5c6 ("vdpa/mlx5: fix polling threads scheduling") Fixes: 5cf3fd3af4df ("vdpa/mlx5: add CPU core parameter to bind polling thread") Cc: stable@dpdk.org Signed-off-by: Thomas Monjalon Acked-by: Matan Azrad Acked-by: Andrew Rybchenko Acked-by: David Marchand --- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c index 86adc864f5..49632dfaa7 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c @@ -3,6 +3,7 @@ */ #include #include +#include #include #include @@ -234,7 +235,7 @@ mlx5_vdpa_timer_sleep(struct mlx5_vdpa_priv *priv, uint32_t max) usleep(priv->timer_delay_us); else /* Give-up CPU to improve polling threads scheduling. */ - pthread_yield(); + sched_yield(); } static void * @@ -515,17 +516,6 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv) pthread_cond_init(&priv->timer_cond, NULL); priv->timer_on = 0; pthread_attr_init(&attr); - CPU_ZERO(&cpuset); - if (priv->event_core != -1) - CPU_SET(priv->event_core, &cpuset); - else - cpuset = rte_lcore_cpuset(rte_get_main_lcore()); - ret = pthread_attr_setaffinity_np(&attr, sizeof(cpuset), - &cpuset); - if (ret) { - DRV_LOG(ERR, "Failed to set thread affinity."); - return -1; - } ret = pthread_attr_setschedpolicy(&attr, SCHED_RR); if (ret) { DRV_LOG(ERR, "Failed to set thread sched policy = RR."); @@ -542,6 +532,17 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv) DRV_LOG(ERR, "Failed to create timer thread."); return -1; } + CPU_ZERO(&cpuset); + if (priv->event_core != -1) + CPU_SET(priv->event_core, &cpuset); + else + cpuset = rte_lcore_cpuset(rte_get_main_lcore()); + ret = pthread_setaffinity_np(priv->timer_tid, + sizeof(cpuset), &cpuset); + if (ret) { + DRV_LOG(ERR, "Failed to set thread affinity."); + goto error; + } snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid); ret = pthread_setname_np(priv->timer_tid, name); if (ret) { -- 2.30.1