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 AFEC745C60 for ; 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 A812840651; Sat, 2 Nov 2024 20:58:51 +0100 (CET) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id 03311402A3 for ; Sat, 2 Nov 2024 20:58:49 +0100 (CET) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-720b2d8bcd3so2352791b3a.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=T1sNuKO5RjO1UNUy+XTIBiEBRLqrw+WKtYwh+lr1HLOtnx/Zhg2lKFSJaz/nZgo1kl DSjUmCciqSQkJqeSelO6M+U9VDA/Vr8xSgVyAv4D8vovm/RGS43IoJYt3hF+0+46D2hd 2giN1Zy+CCsKf8sapXj+E5k3tge/FVE368866gG1rvDwKElCEoXz9HlS4lyD2no+xNMX 344KzeTS3xy7eInm0IAZPUTg7fOT10cLnMO1oCW5NihCLnxOjRJlXiQY/Qw18A7r5fCT TC+JqaQAQ7XlHdarKyBC2u4v8zi9QTKMtOmdNKJgcJAl8qPq7M1YfRp+AMcaoGEl4EDh eU2w== X-Forwarded-Encrypted: i=1; AJvYcCWSRNcwFTKF1wIJQet9hK6nFie++WeNuPmpTGFhyVh2LU/PexvIVKI0nk4EfbWLHFI9uqvQUiA=@dpdk.org X-Gm-Message-State: AOJu0YxBQDnNxY2ExNfC8TdNLr/KTdAMNGQQp4tKNZv9KwzsDUhfztvD nQYxNZuZ/B8Qo6EhchtjcqTvD7KoMucOAOJvHBi4sBHGCwF37lQaQ3LxZmGosrw= 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: 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 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.