qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Helge Deller <deller@gmx.de>,
	Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH] linux-user: Enhance /proc/cpuinfo output for sparc, hppa and m68k
Date: Tue, 13 Dec 2022 20:31:37 +0100	[thread overview]
Message-ID: <577ccfca-2767-c8a2-5b05-0b02c898e486@vivier.eu> (raw)
In-Reply-To: <Y5ij6ST3s5dLNHPM@p100>

Le 13/12/2022 à 17:10, Helge Deller a écrit :
> The sparc, hppa and m68k 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

Why don't they use something like system("getconf _NPROCESSORS_CONF") ?

> 
> Avoid such issues by adding a "processor:" line for each of the online
> CPUs.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> 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
...
> @@ -8319,6 +8331,7 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
>   #if defined(TARGET_M68K)
>   static int open_hardware(CPUArchState *cpu_env, int fd)
>   {
> +    dprintf(fd, "processor\t: 0\n");
>       dprintf(fd, "Model:\t\tqemu-m68k\n");
>       return 0;
>   }

This is /proc/hardware, not /proc/cpuinfo.

root@debian10-vm1:~# cat /proc/hardware
Model:		Macintosh Quadra 800
System Memory:	1025024K
root@debian10-vm1:~# cat /proc/cpuinfo
CPU:		68040
MMU:		68040
FPU:		68040
Clocking:	1529.8MHz
BogoMips:	1019.90
Calibration:	5099520 loops

And on m68k, no one expects to have a "processor" line.

Thanks,
Laurent



  reply	other threads:[~2022-12-13 19:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 16:10 [PATCH] linux-user: Enhance /proc/cpuinfo output for sparc, hppa and m68k Helge Deller
2022-12-13 19:31 ` Laurent Vivier [this message]
2022-12-13 19:48   ` Helge Deller

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=577ccfca-2767-c8a2-5b05-0b02c898e486@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=deller@gmx.de \
    --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 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).