* [PATCH] [gdb] Check for sched_getaffinity in configure
@ 2026-09-17 12:40 Tom de Vries
2026-09-29 11:01 ` Andrew Burgess
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-09-17 12:40 UTC (permalink / raw)
To: gdb-patches
A post-commit review comment [1] on commit 8ea833b7067 ("[gdb] Exclude
unavailable hardware threads in default worker-threads") mentioned that we
should:
- check for the presence of sched_getaffinity in configure
- remove the todo comment.
Implement these two.
[1] https://sourceware.org/pipermail/gdb-patches/2026-September/230415.html
---
gdb/config.in | 3 +++
gdb/configure | 1 +
gdb/configure.ac | 1 +
gdb/maint.c | 6 ++----
4 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/gdb/config.in b/gdb/config.in
index 74745665d4d..0e5a6637c2b 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -430,6 +430,9 @@
/* Define to 1 if you have the `sbrk' function. */
#undef HAVE_SBRK
+/* Define to 1 if you have the `sched_getaffinity' function. */
+#undef HAVE_SCHED_GETAFFINITY
+
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
diff --git a/gdb/configure b/gdb/configure
index f411113ea66..810e9ed7a37 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -30161,6 +30161,7 @@ for ac_func in \
pread64 \
pwrite \
resize_term \
+ sched_getaffinity \
setlocale \
setrlimit \
setsid \
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 5d8e2d6628f..0d88a280b16 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1542,6 +1542,7 @@ AC_CHECK_FUNCS([ \
pread64 \
pwrite \
resize_term \
+ sched_getaffinity \
setlocale \
setrlimit \
setsid \
diff --git a/gdb/maint.c b/gdb/maint.c
index 800cf7e0cda..ed57b34eab5 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -47,7 +47,7 @@
#include "cli/cli-style.h"
#include "cli/cli-cmds.h"
-#if defined (__linux__) || defined (__CYGWIN__)
+#if HAVE_SCHED_GETAFFINITY
#include <sched.h>
#endif
@@ -891,13 +891,11 @@ update_thread_pool_size ()
{
/* Exclude unavailable hardware threads (for instance made
unavailable using taskset). */
-#if (defined (__linux__) || defined (__CYGWIN__)) && defined (_GNU_SOURCE)
+#if HAVE_SCHED_GETAFFINITY
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
}
}
base-commit: 4c733e49e3da1eab7991ab64c5bb75c7a56bf48a
--
2.51.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [gdb] Check for sched_getaffinity in configure
2026-09-17 12:40 [PATCH] [gdb] Check for sched_getaffinity in configure Tom de Vries
@ 2026-09-29 11:01 ` Andrew Burgess
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2026-09-29 11:01 UTC (permalink / raw)
To: Tom de Vries, gdb-patches
Tom de Vries <tdevries@suse.de> writes:
> A post-commit review comment [1] on commit 8ea833b7067 ("[gdb] Exclude
> unavailable hardware threads in default worker-threads") mentioned that we
> should:
> - check for the presence of sched_getaffinity in configure
> - remove the todo comment.
>
> Implement these two.
Makes sense to me.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Andrew
>
> [1] https://sourceware.org/pipermail/gdb-patches/2026-September/230415.html
> ---
> gdb/config.in | 3 +++
> gdb/configure | 1 +
> gdb/configure.ac | 1 +
> gdb/maint.c | 6 ++----
> 4 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/config.in b/gdb/config.in
> index 74745665d4d..0e5a6637c2b 100644
> --- a/gdb/config.in
> +++ b/gdb/config.in
> @@ -430,6 +430,9 @@
> /* Define to 1 if you have the `sbrk' function. */
> #undef HAVE_SBRK
>
> +/* Define to 1 if you have the `sched_getaffinity' function. */
> +#undef HAVE_SCHED_GETAFFINITY
> +
> /* Define to 1 if you have the `setlocale' function. */
> #undef HAVE_SETLOCALE
>
> diff --git a/gdb/configure b/gdb/configure
> index f411113ea66..810e9ed7a37 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -30161,6 +30161,7 @@ for ac_func in \
> pread64 \
> pwrite \
> resize_term \
> + sched_getaffinity \
> setlocale \
> setrlimit \
> setsid \
> diff --git a/gdb/configure.ac b/gdb/configure.ac
> index 5d8e2d6628f..0d88a280b16 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -1542,6 +1542,7 @@ AC_CHECK_FUNCS([ \
> pread64 \
> pwrite \
> resize_term \
> + sched_getaffinity \
> setlocale \
> setrlimit \
> setsid \
> diff --git a/gdb/maint.c b/gdb/maint.c
> index 800cf7e0cda..ed57b34eab5 100644
> --- a/gdb/maint.c
> +++ b/gdb/maint.c
> @@ -47,7 +47,7 @@
> #include "cli/cli-style.h"
> #include "cli/cli-cmds.h"
>
> -#if defined (__linux__) || defined (__CYGWIN__)
> +#if HAVE_SCHED_GETAFFINITY
> #include <sched.h>
> #endif
>
> @@ -891,13 +891,11 @@ update_thread_pool_size ()
> {
> /* Exclude unavailable hardware threads (for instance made
> unavailable using taskset). */
> -#if (defined (__linux__) || defined (__CYGWIN__)) && defined (_GNU_SOURCE)
> +#if HAVE_SCHED_GETAFFINITY
> 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
> }
> }
>
> base-commit: 4c733e49e3da1eab7991ab64c5bb75c7a56bf48a
> --
> 2.51.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-29 11:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 12:40 [PATCH] [gdb] Check for sched_getaffinity in configure Tom de Vries
2026-09-29 11:01 ` Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox