All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Laurent Vivier <laurent@vivier.eu>,
	Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH v2] linux-user: Fix /proc/cpuinfo output for sparc and hppa
Date: Wed, 28 Dec 2022 22:01:14 +0100	[thread overview]
Message-ID: <3ce79ab4-c8c8-e5e5-94e3-07d02f8d2c6d@gmx.de> (raw)
In-Reply-To: <Y5juEOgG2Jnad1j9@p100>

On 12/13/22 22:26, Helge Deller wrote:
> The sparc and hppa architectures provide an own output for the emulated
> /proc/cpuinfo file.
>
> Some userspace applications count (even if that's not the recommended
> way) the number of lines which start with "processor:" and assume that
> this number then reflects the number of online CPUs. Since those 3
> architectures don't provide any such line, applications may assume "0"
> CPUs.  One such issue can be seen in debian bug report:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653
>
> Avoid such issues by adding a "processor:" line for each of the online
> CPUs.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
>
> ---
> v2:
> - drop m68k part (based on feedback from Laurent Vivier <laurent@vivier.eu>)
> - change commit message
>
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 9e2c0a18fc..d58e9b8d10 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -8299,7 +8299,13 @@ static int open_net_route(CPUArchState *cpu_env, int fd)
>   #if defined(TARGET_SPARC)
>   static int open_cpuinfo(CPUArchState *cpu_env, int fd)
>   {
> -    dprintf(fd, "type\t\t: sun4u\n");
> +    int i, num_cpus;
> +
> +    num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> +    for (i = 0; i < num_cpus; i++) {
> +        dprintf(fd, "%sprocessor\t: %d\n", (i > 0) ? "\n":"", i);

it turned out, that the procps tools expect the /proc/cpuinfo file
to have a trailing \n at the end of the file.
So, I'll respin this patch and send a v3 version to replace this
conditional \n-output.

Same applies for the hppa arch.....


> +        dprintf(fd, "type\t\t: sun4u\n");
> +    }
>       return 0;
>   }
>   #endif
> @@ -8307,11 +8313,17 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
>   #if defined(TARGET_HPPA)
>   static int open_cpuinfo(CPUArchState *cpu_env, int fd)
>   {
> -    dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> -    dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> -    dprintf(fd, "capabilities\t: os32\n");
> -    dprintf(fd, "model\t\t: 9000/778/B160L\n");
> -    dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n");
> +    int i, num_cpus;
> +
> +    num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> +    for (i = 0; i < num_cpus; i++) {
> +        dprintf(fd, "%sprocessor\t: %d\n", (i > 0) ? "\n":"", i);

^^  here.

Helge

> +        dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> +        dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> +        dprintf(fd, "capabilities\t: os32\n");
> +        dprintf(fd, "model\t\t: 9000/778/B160L - "
> +                    "Merlin L2 160 QEMU (9000/778/B160L)\n");
> +    }
>       return 0;
>   }
>   #endif



      reply	other threads:[~2022-12-28 21:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 21:26 [PATCH v2] linux-user: Fix /proc/cpuinfo output for sparc and hppa Helge Deller
2022-12-28 21:01 ` Helge Deller [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=3ce79ab4-c8c8-e5e5-94e3-07d02f8d2c6d@gmx.de \
    --to=deller@gmx.de \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.