[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/5] linux-user: open_self_stat: Implement num_threads
From: |
Richard Henderson |
Subject: |
[PULL 5/5] linux-user: open_self_stat: Implement num_threads |
Date: |
Tue, 30 Jul 2024 11:12:02 +1000 |
From: Fabio D'Urso <fdurso@google.com>
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>
---
linux-user/syscall.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b8c278b91d..9d5415674d 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);
--
2.43.0
- [PULL 0/5] misc patch queue, Richard Henderson, 2024/07/29
- [PULL 2/5] util/getauxval: Ensure setting errno if not found, Richard Henderson, 2024/07/29
- [PATCH for-9.1] tests/vm/openbsd: Install tomli, Richard Henderson, 2024/07/29
- [PULL 1/5] target/rx: Use target_ulong for address in LI, Richard Henderson, 2024/07/29
- [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD, Richard Henderson, 2024/07/29
- [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD, Richard Henderson, 2024/07/29
- [PULL 5/5] linux-user: open_self_stat: Implement num_threads,
Richard Henderson <=
- Re: [PULL 0/5] misc patch queue, Richard Henderson, 2024/07/30