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 CC3D8A055D for ; Sun, 28 Feb 2021 13:54:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41B8722A2DE; Sun, 28 Feb 2021 13:54:30 +0100 (CET) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 4FBB922A2B9; Sun, 28 Feb 2021 13:54:27 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 147145DB; Sun, 28 Feb 2021 07:54:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 28 Feb 2021 07:54:26 -0500 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=x0sjAmwEHobre 5Wb/pLeyfeXRaZJn3qbMF4ORYFQo7I=; b=TrC5L0zvEClUqF+RY3lwMaiSSWshb z+cV2bHwfgpSSyeSGdloxVgfrMmlar76QI7K6cHHJIff2oVYKwHeBwQcmZiQ/rNN w/hg9CkMIhxS+0bpGsf3JrNdDhRdUED4myl1Gvi9cy9U86ufEv/EUHkt/8JOsrY4 nfjrsvCArWzry/KrAGdJSXkbdeYUjhvq6fAorl/k4uj9diN+bw578XEPRAC7r8Uk FCQ5gUY2olDnXRHjHuyCWa0SsaM6J4Lj19BLU8oOABIFWQAWOmrbFbQDXuGepWMs OLDeROID4zlZePMMpMnM9scIpJnCXflD4FT0JWxLZfXuvZzgXrFdHbgcg== 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=x0sjAmwEHobre5Wb/pLeyfeXRaZJn3qbMF4ORYFQo7I=; b=L9KU4FhY qi3mNFtUTYyOfZhKgu2V0cnhg8VQt02qWiqGO+oCQsH+QLpJttqDJ67Y1gNWjb6w KcJu1XxiWsmgNckzln44wFlb8DZME5vRAMF4DJ0MEiAqEny2n6fiYHmimL7+W7LD s/mbrxx5OSGlPN1QjuypPpYtz+m90OCEhUSo5FUc7vLsXAokHZZM5A9VZ08eETdV aBGCePBEkP2Cu55lMrWCyNxvc3nCQ8W33jU3m0b6+0XjzUa4YFV63Ty2oklsII0Y bWvN3lxyPIk7uug5vK3ZN1Qm+4PeBHjrztXYfypKl7ttSRT641VEs52A45eH8X0K GRJG5uuNJCN/qQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrleeigdegkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepieenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth 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 D6C65108005F; Sun, 28 Feb 2021 07:54:24 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: ncopa@alpinelinux.org, stable@dpdk.org, Matan Azrad , Viacheslav Ovsiienko , Xueming Li , Maxime Coquelin Date: Sun, 28 Feb 2021 13:53:50 +0100 Message-Id: <20210228125353.2436562-16-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210228125353.2436562-1-thomas@monjalon.net> References: <20190313170657.16688-1-ncopa@alpinelinux.org> <20210228125353.2436562-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v6 15/17] vdpa/mlx5: replace pthread functions unavailable in musl X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- 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