From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4ZpFMHuLnWroazEAWB0awg (envelope-from ) for ; Sun, 06 Sep 2026 11:49:15 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dgvT9Kqa; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yDsC9+K2; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VHFN4LOq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1YfzUdAO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BEDA51E09E; Sun, 06 Sep 2026 11:49:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 0B22D1E033 for ; Sun, 06 Sep 2026 11:49:14 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C170D4BB8F55 for ; Sun, 6 Sep 2026 15:49:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C170D4BB8F55 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dgvT9Kqa; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yDsC9+K2; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VHFN4LOq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1YfzUdAO Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 429794BB3B94 for ; Sun, 6 Sep 2026 15:48:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 429794BB3B94 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 429794BB3B94 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788709729; cv=none; b=Yhdg2/WR45ibIobsZkq8QAjFOdbgqGHpJDJv+A9g28d5bPI4csX6c/kXQSf0giYFBdoyBHpizqJQ2pm3t06c11CGmS8r+HFsuj/5idQqLrFBXAx3Ywku/sI45TyGr4oIMbAxV9mtzDD6J4OPDClgBWUH2jwJiCKQQ8OZD1KDRog= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788709729; c=relaxed/simple; bh=cEjXcEA1Tp4UUPWVCCpdRl0cUgJUIJ7L72HirK71uYk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=cDxABXBpA+Y3VPDEltz8xNtXXdip0pAroKH0eFCISi4mh3okfS4uBmrMWkkYNWTTAUt/6dstkL2lYoNWzouT02pIV0AhJLbiE3vrChHOW+eQz/O/b5VaBWNGNyovtLTxLnx2LuD3y3UDsN7PF4kf4r2CZn9t/ts+iv87Ly21ICk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dgvT9Kqa; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yDsC9+K2; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VHFN4LOq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1YfzUdAO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 429794BB3B94 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B583121985 for ; Sun, 6 Sep 2026 15:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788709723; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0QJj0rd0gDd/Rr9MvKi6Zk3guT4nQ7+CgXBiAk4bSIE=; b=dgvT9KqaJG+RHctc2DJEAXSIXt9mPp/TutTff3EkVp4G+2+glhQQdfdwJzKNr2Q28V4+Ef G0PG2USokFTOkIxJBD94r6ujzr7eymHbuU7k8FR2J2zsaI9HMMHyJxEgbjhqlt4J8/wntK eWSzOBzQ2+h2nNr7uNI5eDmlXk+cn8k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788709723; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0QJj0rd0gDd/Rr9MvKi6Zk3guT4nQ7+CgXBiAk4bSIE=; b=yDsC9+K2QNawyxIe8BHkitdPMMDR5dWorlscpBp+p0EXtgAXmvdMuulTER3r+u5XsEQ/i6 Q1EyrxwQoogHxiCg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=VHFN4LOq; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1YfzUdAO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788709719; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0QJj0rd0gDd/Rr9MvKi6Zk3guT4nQ7+CgXBiAk4bSIE=; b=VHFN4LOqFh6ENWaoDniJGrX3d7PReKUY6TdJ4TGJtw9EK5d8Rbd3ysGRdX2M0VjNaJe3FY yGQebp9XX1d6k1WqgJOaIU9ZcqTKXfglFovJH7QMycSgvICjUakbkQEYj8elEWj+FpRoKR 2qXc7PqzxcYLspIENiMrriumQRUBkLA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788709719; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0QJj0rd0gDd/Rr9MvKi6Zk3guT4nQ7+CgXBiAk4bSIE=; b=1YfzUdAO90/i0nWHPVUybfba+LDQx2tHO2OyDm9GPLPUcrScgtibl3n7mH0wHdZKG8mx7O EFCwd9a+gHxOf4Dw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 88E5B1368D for ; Sun, 6 Sep 2026 15:48:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MF8UIFeLnWqvNAAAD6G6ig (envelope-from ) for ; Sun, 06 Sep 2026 15:48:39 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 2/2] [gdb] Exclude unavailable hardware threads in default worker-threads Date: Sun, 6 Sep 2026 17:48:38 +0200 Message-ID: <20260906154838.139837-2-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260906154838.139837-1-tdevries@suse.de> References: <20260906154838.139837-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: B583121985 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_TLS_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] 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 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(+) 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 +#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); -- 2.51.0