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 66AA145C6E; Sun, 3 Nov 2024 17:10:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA1C340678; Sun, 3 Nov 2024 17:10:35 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id 69D584021F for ; Sun, 3 Nov 2024 17:10:34 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2110a622d76so25463995ad.3 for ; Sun, 03 Nov 2024 08:10:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1730650233; x=1731255033; 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=oRUsT/9hs+IWyfWoRhofREiZbj2Z7RYkCfbmO3a5WLo=; b=GZuQ3Q56lQTbtU7BS3EMKbktL3PETGqlw3E6P5kYLN80sxDrA907zgv6ABCQbmngC/ R31QetcwP9xVDN7JChTaoiwnTdnoiqhdhOWG4qSN/UELNmwcSTRWyfgNoXWU6OFCeUE5 strMryo4Fv0j4P9Zk/lXXEPWb9Rw3boM2V/YvbQcDAM/XL0HVtD1PqZmKD4HvBqbICI4 8ggsuPb5zuRFZIi5pgG38kWw5zyU+9yPpnsOfIthsiF+eYuIpSinz5wx4sGax228MOLD xNzGx4Z6EvZPjD4YM11YKwjdT/R1MD+qLOqD4EBWRkamSIgUwwLlb2Dkebk6xTLYhcDx ZC9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730650233; x=1731255033; 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=oRUsT/9hs+IWyfWoRhofREiZbj2Z7RYkCfbmO3a5WLo=; b=ktEiPMv8e7TGBaeOkuI6l6JPDCCdhGwnnxcVVWCANI3hoQfXxiYbfEu7x2WWKaRnwp y1FeV/We9iua1P60n1KpakpI9eKJOnnoojr1ft801yMF0/NP/LZS4jiMw/l5f+u7zWJA mbascJ9AUgcOn9Fbfs/AvXIvmnwz+o3mThCvCNaQ9W1oHSMN85baMpMXisYiZUcli6+Q pli0NbkdgGfMW2MU/yd0Wqf+I4nrxKlOj1DaFZiyE3naeO52lsD931PKXHJM6lPXwRY6 /M9cDYY4bjVvQ5bA5JAJRHtdw3O7IN8FerYiwZdLdrS88+PggeB0Q9wmTgFTfnF2rP9G 44MA== X-Gm-Message-State: AOJu0YxeNbCe9NHJF/Eag9Tg6aUmNbx4s41mTRhEmlnYrQ3jomhqZ9/d CgxGOfl1nKG0VxnMtGYxa3MNb9DbsXO0cGmhcDtXmZGtvJQP9PgF7A9Bum7ltVE= X-Google-Smtp-Source: AGHT+IE4JVNbZdZVfpcB8daogamINABgo8dVCNmObAK0DK6vOQ3cCidT2BmthEoACGmzbXX/CGV5rQ== X-Received: by 2002:a17:902:e80f:b0:20c:5a64:9bc6 with SMTP id d9443c01a7336-210c6c92b66mr356393115ad.50.1730650233438; Sun, 03 Nov 2024 08:10:33 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057a2f18sm46427825ad.126.2024.11.03.08.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 08:10:32 -0800 (PST) Date: Sun, 3 Nov 2024 08:10:27 -0800 From: Stephen Hemminger To: David Marchand Cc: dev@dpdk.org, thomas@monjalon.net, luca.boccassi@gmail.com, stable@dpdk.org, Luca Boccassi , Tyler Retzlaff Subject: Re: [PATCH v3] eal/unix: optimize thread creation with glibc Message-ID: <20241103081027.4366454e@hermes.local> In-Reply-To: <20241103112519.2972691-1-david.marchand@redhat.com> References: <20241102100839.2325651-1-david.marchand@redhat.com> <20241103112519.2972691-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 Sun, 3 Nov 2024 12:25:19 +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. > > Fixes: b28c6196b132 ("eal/unix: fix thread creation") > Cc: stable@dpdk.org > > Signed-off-by: David Marchand > Acked-by: Luca Boccassi > --- > Changes since v2: > - added pthread_attr_setaffinity_np() detection, > > Changes since v1: > - fixed build with FreeBSD, Looks good, reading the glibc source there are internal flags to deal with all the states new threads have to deal with. Glibc is complex there, but comments are worth reading. I wonder if part of the reason this is more of a problem for DPDK is that by default new thread inherits cpuset of the parent. So the child thread will get stuck on same CPU as the main thread. Acked-by: Stephen Hemminger