diff options
author | Fabio D'Urso <fdurso@google.com> | 2024-06-19 21:41:09 +0200 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2024-07-30 07:59:23 +1000 |
commit | d9b019e0a05cbbaa184815dd201b25006950c6d7 (patch) | |
tree | 32dad478b7d697565368d72879750a04b17a238b | |
parent | 27fca0a0d560ae704457c5f89e0be658afef034d (diff) | |
download | qemu-d9b019e0a05cbbaa184815dd201b25006950c6d7.zip qemu-d9b019e0a05cbbaa184815dd201b25006950c6d7.tar.gz qemu-d9b019e0a05cbbaa184815dd201b25006950c6d7.tar.bz2 |
linux-user: open_self_stat: Implement num_threads
The num_threads field reports the total number of threads in the
process. In QEMU, this is equal to the number of CPU instances.
Signed-off-by: Fabio D'Urso <fdurso@google.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20240619194109.248066-1-fdurso@google.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rw-r--r-- | linux-user/syscall.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b8c278b..9d54156 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8168,6 +8168,16 @@ static int open_self_stat(CPUArchState *cpu_env, int fd) } else if (i == 3) { /* ppid */ g_string_printf(buf, FMT_pid " ", getppid()); + } else if (i == 19) { + /* num_threads */ + int cpus = 0; + WITH_RCU_READ_LOCK_GUARD() { + CPUState *cpu_iter; + CPU_FOREACH(cpu_iter) { + cpus++; + } + } + g_string_printf(buf, "%d ", cpus); } else if (i == 21) { /* starttime */ g_string_printf(buf, "%" PRIu64 " ", ts->start_boottime); |