qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Fabio D'Urso" <fdurso@google.com>
Cc: qemu-devel@nongnu.org,  Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH] linux-user: open_self_stat: Implement num_threads
Date: Thu, 20 Jun 2024 15:38:30 +0100	[thread overview]
Message-ID: <87plsbbrx5.fsf@draig.linaro.org> (raw)
In-Reply-To: <20240619194109.248066-1-fdurso@google.com> (Fabio D'Urso's message of "Wed, 19 Jun 2024 21:41:09 +0200")

"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


      reply	other threads:[~2024-06-20 14:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87plsbbrx5.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=fdurso@google.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).