* [PATCH] linux-user: open_self_stat: Implement num_threads
@ 2024-06-19 19:41 Fabio D'Urso
2024-06-20 14:38 ` Alex Bennée
0 siblings, 1 reply; 2+ messages in thread
From: Fabio D'Urso @ 2024-06-19 19:41 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, Fabio D'Urso
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>
---
linux-user/syscall.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b9b5a387b3..a47b2eeb65 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8171,6 +8171,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.45.2.627.g7a2c4fd464-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] linux-user: open_self_stat: Implement num_threads
2024-06-19 19:41 [PATCH] linux-user: open_self_stat: Implement num_threads Fabio D'Urso
@ 2024-06-20 14:38 ` Alex Bennée
0 siblings, 0 replies; 2+ messages in thread
From: Alex Bennée @ 2024-06-20 14:38 UTC (permalink / raw)
To: Fabio D'Urso; +Cc: qemu-devel, Laurent Vivier
"Fabio D'Urso" <fdurso@google.com> writes:
> 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>
> ---
> linux-user/syscall.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index b9b5a387b3..a47b2eeb65 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -8171,6 +8171,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);
Looks ok to me.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-20 14:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 19:41 [PATCH] linux-user: open_self_stat: Implement num_threads Fabio D'Urso
2024-06-20 14:38 ` Alex Bennée
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).