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 B4C0D45C61; Sat, 2 Nov 2024 20:58:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A4D22402A3; Sat, 2 Nov 2024 20:58:50 +0100 (CET) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id DAE6D400D7 for ; Sat, 2 Nov 2024 20:58:49 +0100 (CET) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20c7ee8fe6bso27838655ad.2 for ; Sat, 02 Nov 2024 12:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1730577529; x=1731182329; darn=dpdk.org; 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=OhySsIDsKV/kV9Iii4KjLbCFs+ZZ6mBJVl0QLTy0MN0=; b=IPcX/2HbKJgZHPIN0fUT5VIGYDqXxmqd9FC+FypXaORHZfXd6qegSdYmdbdxYGsR4B HU5C+zHWbG3OYYzrhp9YCFfo7ZWMPHxZ+lSa7XytTaD43OpC9PUTa0GQKBdxDtJPbgw+ q6s9za/OlEtwcS4AR5FADkmo4FWcpup3hqH3z7Hfqadun7NNFGkO17TitdRZBfnEnlyk nQ40tHEzdT0INar15yrWDWY6gkxl5vgU3I0lQGgMN62/3U0tHHp6fOMV+AlP4INrNkws 7UMezB6labSQvL3htm24Erq96HicYs86787OgBfepSN+oThUQsiwb7VsctktCJij/Luk mByQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730577529; x=1731182329; 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=OhySsIDsKV/kV9Iii4KjLbCFs+ZZ6mBJVl0QLTy0MN0=; b=bhoV9m8PLtK1l85qCaEDr699vClnvvvl2yQAVbRSlyK6phzTG3lj11J3QV5x3qKFS6 KJybc0OibUeniiNyMolifo7ouz8PJWiXFFtVIFAN3ghYMpMF2HTcp1JQ6tloSLbZ6/c7 QQDL0cqCmiGEuo6CPHJD+yjwR6oUDeWyYS05vM6vC0JQW/NnI1n9vlOdJzuqOdFsjXy+ UKHrVw+O4KkO0iEZ3mTfIGNeU/aAmCZ4pcKIKbhPTEsc8vLYJglBK/KuLmUD4+ly8w1U 5n+njwY58LTxPkHR/xkYPZ1sCwn2IR7s1t+0zdkzyGRWaQ5l40Iyk1SEL3Z02bLaAXz8 GnyA== X-Gm-Message-State: AOJu0YxoXrMAoAPX33DkvbYlbySRrMpfCgozriHLgECXz1en+GQXxp4h Rb3mo268bn/lwnuHfQihCsaF7uCuLB71Q5Fo1vthAYUOars1pF0sE6PRcNd3OZ8= X-Google-Smtp-Source: AGHT+IHqkq8veckEhq6cNjZ+KpkXntdiIIFqtlfBqE8Ndoc01Id26flE/uO92q8RcXi/5DuSBeio5A== X-Received: by 2002:a17:902:f68d:b0:205:8bad:171c with SMTP id d9443c01a7336-210c6878621mr389564685ad.12.1730577528842; Sat, 02 Nov 2024 12:58:48 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057c4e95sm37001675ad.225.2024.11.02.12.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Nov 2024 12:58:48 -0700 (PDT) Date: Sat, 2 Nov 2024 12:58:46 -0700 From: Stephen Hemminger To: David Marchand Cc: dev@dpdk.org, thomas@monjalon.net, luca.boccassi@gmail.com, stable@dpdk.org, Tyler Retzlaff Subject: Re: [PATCH] eal/unix: optimize thread creation with glibc Message-ID: <20241102125846.2d206e3a@hermes.local> In-Reply-To: <20241102100839.2325651-1-david.marchand@redhat.com> References: <20241102100839.2325651-1-david.marchand@redhat.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 Sat, 2 Nov 2024 11:08:39 +0100 David Marchand wrote: > Setting the cpu affinity of the child thread from the parent thread is > racy when using pthread_setaffinity_np, as the child thread may start > running and initialize before affinity is set. > > On the other hand, setting the cpu affinity from the child thread itself > may fail, so the parent thread waits for the child thread to report > whether this call succeeded. > > This synchronisation point resulted in a significant slow down of > rte_thread_create() (as seen in the lcores_autotest unit tests, in OBS > for some ARM systems). > > Another option for setting cpu affinity is to use the not portable > pthread_attr_setaffinity_np, but it is not available with musl. > Assume availability by relying on __USE_GNU that is not set with musl. > > Fixes: b28c6196b132 ("eal/unix: fix thread creation") > Cc: stable@dpdk.org > > Signed-off-by: David Marchand > --- Seems like a reasonable way forward but not sure. What about FreeBSD (which shares this code)? Looking inside glibc, what it does is have the parent call sched_setaffinty() after the clone system call with the thread id. So using attributes is just as racy as the original code.