From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id RFD2AWBBnmrXAzMAWB0awg (envelope-from ) for ; Mon, 07 Sep 2026 00:45:20 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NZcyut3s; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E7B141E09E; Mon, 07 Sep 2026 00:45:19 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C26B11E091 for ; Mon, 07 Sep 2026 00:45:18 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B9F394BB3BDA for ; Mon, 7 Sep 2026 04:45:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9F394BB3BDA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NZcyut3s Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by sourceware.org (Postfix) with ESMTPS id 1E47B4BCA402 for ; Mon, 7 Sep 2026 04:44:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E47B4BCA402 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1E47B4BCA402 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788756288; cv=none; b=osK77im9anY6wcvgs7TwQweevjZJjr7W+qG8KEHXiPxeUTbtoUSYgDu9tlKUTLZ6YDbOZxaBUFs4a3+5A3c77yaK2RLdaw3PY6X9hje2Nds6vL/CZLz7g4yLXWLU1rJT+dVsi+sg6n/PnyjZIPnoSHrEoqCrSO5HR5LuHqgp0NU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788756288; c=relaxed/simple; bh=bgb4KSetK4SVJ5pkRVkRVHh/ilujAGIq7hLpfFQcO/A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lmJvYehXx7oEjKOq6LwgqAjR/Qs7jwI6wKxNPXl/2C/hnG2vp7aIuxqzIsV9XnzCPSnz2ucG3oJYVKkmE5Ov0+j/l2pBp8EpBcNdIOu7YO10UBjGvLfRSRTj7qzEx/Uia9Dof0FBfFJ+nRNIsaHGVn/83sKF4refbY2QPYfJ1NU= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NZcyut3s DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E47B4BCA402 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-8565d77c277so35941907b3.0 for ; Sun, 06 Sep 2026 21:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1788756287; x=1789361087; darn=sourceware.org; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=moSPpoCybzdjfDxolQFEWwfSArnhAIhXCtup8zVhUZ4=; b=NZcyut3sTzvYK46RanWppXw3TR24JbJ3TG8zRIPPlR1BlLSKhjZ8pwccpeaXnM7exu ZgKQxZkWv6uMPWnx3X8UBEHJ//GlQ++Gy6F/KSoUkEORM6fVmv8GWBrvvhWgkNAt8ZD5 9Bb/8e4OD8d551UVjU+TssQwkexY++cXJ+wYu3XB/8iGoPj4JbYXFW7DgviZ4nAY2GQU 05yw0LeF1ldGlmwC4V1vOCEVgCw7mIXnRny/JmzNJSX0Nm3TXopTYOpcw5Yd7FR1olzy P2rXvbjfAICPNCer3DjYkZKTEj73nYVRLmRREeKGxbB6DrSSG4ld2Xnzydl6S46bJbXP I5rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788756287; x=1789361087; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=moSPpoCybzdjfDxolQFEWwfSArnhAIhXCtup8zVhUZ4=; b=UUXBZq1dc6Kbd8Pui9aHPxaCLXLi15qK/CbEi4XSfAoqGS9JWanpmeVG1vyLidQPeI u4T88QNk9IOFDTNeB3B4cM7FI6BU0QJuuEDochHLpt1HvDVA0pGQtwVzGTAldVxQFX37 ZtqCccja0uUMO5n+MQBytn9m5iLb94Nc40KXEboaBIrETZpDQbB/0l3dhq/YOZyLpwcw sgdWnvZ3plKUXpIek+34HG6FNbKkjkyxKGn+FaQBt6Ui3ar2n+SN+mld6A6VrZVuyfKC vKioQd0NIFVh/W9hQZrUQywzwPtKqzPO9FApWEAchMZe/2aos1vHJNhoS69gH4ClMRrM jd9g== X-Gm-Message-State: AFuF++nAJkFAIH30iwqSCfB7gnuGjNa1yLT7LS27sZpX1JyD1fb2F4Y8 U/yg2wQpqX+c42L2xSB8PkY3d61FQTfyxG1q4Nlncjnd+3uqXdwvAXKyzjALD+rk/AD69Ww9NmD 79vVK X-Gm-Gg: AYBFou1MfsypFw8dwa9DsUcPyvJGabKKx8A+DXlfPvKfGuBkyTbegu3u6o0i54L4FH2 lTz+o/5Y1v5lXuvny3p0R4voAi4GI61si3iFROqHRXjLDBuPC0aO95VWIa5esXimDLo1rR5G0Ej h3Cjp866UmhTihMBaYlkXSgbcqu3280Tq/mHJZEjXu13iq6XdVpH4ZRfvI7VLpxvE3qq4sB54UB uJ5ktV69SEPmR+3ntHuAtPdVaQSYEXo4Qdf8RlXCZJoT2qwW/z3TzbMCSeLpGztgAu5dU75nXP9 0LbFD7Cz7OeaYsn14i9iNIxnU0qcgOzNplN4zMomnU20Va/DF+cS/H3Pj7HWe9m06QcBbwJaRlK hKJ+lTu9w63yPyft5i41QJv+fenTXtEeUp6PrhXdIbWQ0ebDNxWOR0SDvYtbAI2wLA0oS/FpcG0 HGke1zq0QtDv00DgUPFi9evdCH2mHfnHpO4nTTV/1zu5+0TG5ak9k/sAYlc2V7nMXsHBK/0wk= X-Received: by 2002:a05:690c:6910:b0:873:5c6b:a313 with SMTP id 00721157ae682-8735c6ba5a9mr42116597b3.65.1788756287172; Sun, 06 Sep 2026 21:44:47 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 00721157ae682-87149316347sm66751087b3.15.2026.09.06.21.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2026 21:44:46 -0700 (PDT) From: Thiago Jung Bauermann To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] [gdb] Exclude unavailable hardware threads in default worker-threads In-Reply-To: <20260906154838.139837-2-tdevries@suse.de> (Tom de Vries's message of "Sun, 6 Sep 2026 17:48:38 +0200") References: <20260906154838.139837-1-tdevries@suse.de> <20260906154838.139837-2-tdevries@suse.de> User-Agent: mu4e 1.14.3; emacs 30.2 Date: Mon, 07 Sep 2026 04:44:44 +0000 Message-ID: <87tso1n003.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Tom de Vries writes: > The default worker-threads is set to the number of hardware threads: > ... > $ gdb -q -batch -ex "maint show worker-thread" > The number of worker threads GDB can use is the default (currently 8). > ... > but does not take into account how many of those are actually available. > > If we reduce the amount of available threads to 1, we get the same answer: > ... > $ taskset -c 0 gdb -q -batch -ex "maint show worker-thread" > The number of worker threads GDB can use is the default (currently 8). > ... > > Fix this on linux using sched_getaffinity: > ... > $ taskset -c 0 gdb -q -batch -ex "maint show worker-thread" > The number of worker threads GDB can use is the default (currently 1). > $ gdb -q -batch -ex "maint show worker-thread" > The number of worker threads GDB can use is the default (currently 8). > ... > --- > gdb/maint.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) This is a nice improvement. At least some good came out of my red herring. Thanks! One comment, but: Reviewed-by: Thiago Jung Bauermann > diff --git a/gdb/maint.c b/gdb/maint.c > index 1daa6ce1d2e..fbddfe15591 100644 > --- a/gdb/maint.c > +++ b/gdb/maint.c > @@ -47,6 +47,10 @@ > #include "cli/cli-style.h" > #include "cli/cli-cmds.h" > > +#ifdef __linux__ > +#include The sched_getaffinity(2) man page mentions that one should define _GNU_SOURCE before including > +#endif > + > static void maintenance_do_deprecate (const char *, int); > > #ifndef _WIN32 > @@ -882,6 +886,20 @@ update_thread_pool_size () > systems. */ > const int max_thread_count = 8; > n_threads = std::min (hardware_threads, max_thread_count); > + > + if (n_threads > 1) > + { > + /* Exclude unavailable hardware threads (for instance made > + unavailable using taskset). */ > +#ifdef __linux__ > + cpu_set_t cpus; > + int res = sched_getaffinity (getpid (), sizeof (cpu_set_t), &cpus); > + if (res == 0) > + n_threads = std::min (n_threads, CPU_COUNT (&cpus)); > +#else > + /* Todo: handle other platforms. */ > +#endif > + } > } > > gdb::thread_pool::g_thread_pool->set_thread_count (n_threads); -- Thiago (he/him)