From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 105B845C5A;
	Sat,  2 Nov 2024 13:37:11 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id D143A402B8;
	Sat,  2 Nov 2024 13:37:10 +0100 (CET)
Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com
 [209.85.128.171])
 by mails.dpdk.org (Postfix) with ESMTP id E377B402B7;
 Sat,  2 Nov 2024 13:37:08 +0100 (CET)
Received: by mail-yw1-f171.google.com with SMTP id
 00721157ae682-6e38fc62b9fso24129637b3.2; 
 Sat, 02 Nov 2024 05:37:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1730551028; x=1731155828; darn=dpdk.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=xgVLw/cEd0H+w2bBBnkkua6jgv30qkjuQH27iPoc8WA=;
 b=Eu9Ys0WMxd2XLHQ6461EAgAsZTxNnkbTtMnc/R7+s7igaDx8H0u/cTY/0j3Rn2C2CI
 UsXg56YC4N5wjnBRk1h00tnK1hfIu9SW7mnA6EwDYCnPQ9IcjPJ+Y3IXr4CG0Lj88CKT
 ZQVD4LDYc7slbn/O9OA0Rmrcpx3tltaK9cYbZnhP2kTniqOp7KhZXx6XMw4TP0PkI1Po
 GgDfD9YiPKkK61aq/of0SRa9R9VSpM+gyukVkM6IM36aI+noOpv2tFUu1WxqWLgoMKV0
 EpbRFST2ccKnq+2zBcdYueYx307ru2aApSX2sisNC+jsPou7mgpd02gu+ZNwMf7GQpzh
 i74g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1730551028; x=1731155828;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=xgVLw/cEd0H+w2bBBnkkua6jgv30qkjuQH27iPoc8WA=;
 b=FV9rc1F+zWkGE0eHBAYjXCWMJgxTUj1mNa4UiVZL0Dj7BsnA3k2ZXwQRDd+sLN0Hl8
 zhP5GMykIut1LRkfkxB8MpJQF7IW3mK1Jfl1nA9V0VncyIMyFyLWlFhdMAoq4x8r8UB3
 YrkSHFGRihx7++uzEppopHaXh1C4+GPFOQd6bsN9aag5EPNK4j4zEqdr7LKEJX9KtGWP
 QkCn9OXEeE3DwIIftW4OGVgHd47nDyraI/a0dRAXXfcY7wGy3vmmpwFt8kV58eLjfG/I
 bO9Mnrge8n9qn0/HTyVBJiBlToLUS+V0CNlsHnaTY9vk9nn/UIxsY1IHeE93ScBsecLT
 hjKQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCUEhgwICWf9jxXT5vX+pvWcMKCcDJE1JaYR+8DPAPxGqRQpheGOKpY2LE5HiLQiWnq7yd/U278=@dpdk.org
X-Gm-Message-State: AOJu0Yy9/gQllkSYJJu6wYrzNLX62qV3JpkOS5Y3JxaJz8ErZHb8K7M/
 KnghAXKF4yvOX+HdhrSsFQ2denJhiDclqggWgPAidzgEYAJqeeBZQWiUWfFxBzNt3haYFye2q7T
 pDGW0mwYC5NknPpXYmSQa0m8kO7s=
X-Google-Smtp-Source: AGHT+IHNaFed2NQAlIYLf4S7BCdCGtbPPh81vgsEQNCtsBjOlEiTDZuG3PYPPkreRuTjOS9l9oSjfwn8rdaIJjfm0yY=
X-Received: by 2002:a05:690c:7482:b0:6ea:4e1f:2b42 with SMTP id
 00721157ae682-6ea64a8d5e4mr75489447b3.8.1730551028132; Sat, 02 Nov 2024
 05:37:08 -0700 (PDT)
MIME-Version: 1.0
References: <20241102100839.2325651-1-david.marchand@redhat.com>
 <20241102113232.2333703-1-david.marchand@redhat.com>
In-Reply-To: <20241102113232.2333703-1-david.marchand@redhat.com>
From: Luca Boccassi <luca.boccassi@gmail.com>
Date: Sat, 2 Nov 2024 12:36:56 +0000
Message-ID: <CAMw=ZnQ9FxWAFA-YUbc8KcyJ-vev_4OsS8WcLvYgpY1KMULK=A@mail.gmail.com>
Subject: Re: [PATCH v2] eal/unix: optimize thread creation with glibc
To: David Marchand <david.marchand@redhat.com>
Cc: dev@dpdk.org, thomas@monjalon.net, stephen@networkplumber.org, 
 stable@dpdk.org, Tyler Retzlaff <roretzla@linux.microsoft.com>
Content-Type: text/plain; charset="UTF-8"
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Sat, 2 Nov 2024 at 11:32, David Marchand <david.marchand@redhat.com> 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 set with glibc.
>
> Fixes: b28c6196b132 ("eal/unix: fix thread creation")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> Changes since v1:
> - fixed build with FreeBSD,
>
> ---
>  lib/eal/unix/rte_thread.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)

The test now completes in 1.19 seconds, so this fixes the issue with glibc:

[  438s] 36/82 DPDK:fast-tests / lcores_autotest             OK
      1.19s

I do not use musl, so this is good enough for me. Thanks!

Acked-by: Luca Boccassi <bluca@debian.org>