* [uml-devel] sysconf(_SC_NPROCESSORS_CONF) returning zero
@ 2008-08-04 13:58 Stanislav Meduna
2008-08-04 20:33 ` Jeff Dike
0 siblings, 1 reply; 6+ messages in thread
From: Stanislav Meduna @ 2008-08-04 13:58 UTC (permalink / raw)
To: user-mode-linux-devel
Hi,
the following program
===
#include <unistd.h>
#include <stdio.h>
main()
{
printf("Number of processors: %d\n", sysconf(_SC_NPROCESSORS_CONF));
}
===
produces
Number of processors: 0
on my system.
# uname -a
Linux dirk 2.6.26 #1 Wed Jul 30 10:56:10 CEST 2008 i686 GNU/Linux
# cat /proc/cpuinfo
processor : 0
vendor_id : User Mode Linux
model name : UML
mode : skas
host : Linux seldon-base 2.6.23.17 #2 SMP Sat Jun 21 15:04:22 CEST 2008 i686
bogomips : 4771.02
# ls -l /lib/libc.so.6
lrwxrwxrwx 1 root root 11 2008-07-17 17:16 /lib/libc.so.6 -> libc-2.7.so
The monit monitoring tool (http://www.tildeslash.com/monit/)
crashes because of this. I don't know whose fault it is, but
I suspect the UML - otherwise I'd expect many more instances
of this problem when googling for it.
Regards
--
Stano
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [uml-devel] sysconf(_SC_NPROCESSORS_CONF) returning zero
2008-08-04 13:58 [uml-devel] sysconf(_SC_NPROCESSORS_CONF) returning zero Stanislav Meduna
@ 2008-08-04 20:33 ` Jeff Dike
2008-08-04 20:59 ` Stanislav Meduna
0 siblings, 1 reply; 6+ messages in thread
From: Jeff Dike @ 2008-08-04 20:33 UTC (permalink / raw)
To: Stanislav Meduna; +Cc: user-mode-linux-devel
On Mon, Aug 04, 2008 at 03:58:04PM +0200, Stanislav Meduna wrote:
> Hi,
>
> the following program
>
> ===
> #include <unistd.h>
> #include <stdio.h>
>
> main()
> {
> printf("Number of processors: %d\n", sysconf(_SC_NPROCESSORS_CONF));
> }
> ===
>
> produces
>
> Number of processors: 0
>
> on my system.
Works here...
[root@uml-test ~]# cc -o ncpus ncpus.c
[root@uml-test ~]# ./ncpus
Number of processors: 1
sysconf seems to be looking at /proc/stat, which looks like this here:
cpu 80 0 157 12771 984 0 0 0 0
cpu0 80 0 157 12771 984 0 0 0 0
intr 15259 12519 0 75 0 2590 0 0 0 0 0 0 74 0 0 1
ctxt 8081
btime 1217881784
processes 1144
procs_running 3
procs_blocked 0
I'd guess it's looking at the cpu0 (and cpu<n>) lines.
Jeff
--
Work email - jdike at linux dot intel dot com
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [uml-devel] sysconf(_SC_NPROCESSORS_CONF) returning zero
2008-08-04 20:33 ` Jeff Dike
@ 2008-08-04 20:59 ` Stanislav Meduna
2008-08-04 21:47 ` Jeff Dike
0 siblings, 1 reply; 6+ messages in thread
From: Stanislav Meduna @ 2008-08-04 20:59 UTC (permalink / raw)
Cc: user-mode-linux-devel
Jeff Dike wrote:
> sysconf seems to be looking at /proc/stat, which looks like this here:
>
> cpu 80 0 157 12771 984 0 0 0 0
> cpu0 80 0 157 12771 984 0 0 0 0
> intr 15259 12519 0 75 0 2590 0 0 0 0 0 0 74 0 0 1
> ctxt 8081
> btime 1217881784
> processes 1144
> procs_running 3
> procs_blocked 0
>
> I'd guess it's looking at the cpu0 (and cpu<n>) lines.
# cat /proc/stat
cpu 38822 537 3376 46871329 174924 0 9 0 0
cpu0 38822 537 3376 46871329 174924 0 9 0 0
intr 47644940 47088997 0 5 0 395871 160067 0 0 0 0 0 0 0 0 0
ctxt 9822902
btime 1217412992
processes 26529
procs_running 2
procs_blocked 0
Hmmm... so I have cpu0 similar to yours. What version
of UML and libc do you have?
--
Stano
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [uml-devel] sysconf(_SC_NPROCESSORS_CONF) returning zero
2008-08-04 20:59 ` Stanislav Meduna
@ 2008-08-04 21:47 ` Jeff Dike
2008-08-04 22:06 ` Stanislav Meduna
2008-08-04 22:07 ` Ingo van Lil
0 siblings, 2 replies; 6+ messages in thread
From: Jeff Dike @ 2008-08-04 21:47 UTC (permalink / raw)
To: Stanislav Meduna; +Cc: user-mode-linux-devel
On Mon, Aug 04, 2008 at 10:59:36PM +0200, Stanislav Meduna wrote:
> Hmmm... so I have cpu0 similar to yours. What version
> of UML and libc do you have?
UML 2.6.26 and an older libc:
% ls -l /lib/libc.so.6
lrwxrwxrwx 1 root root 11 Jun 2 2007 /lib/libc.so.6 -> libc-2.5.so
Looking through libc at
http://www.google.com/codesearch?hl=en&q=file:\.c%24+\"/stat\"+package:http://su-se.lunar-linux.org/lunar/mirrors/glibc-2.3.3-cvs-20040708.tar.bz2+show:m1O9RV1wlw4:qbkros5194A:MbxD3_8dUHU&sa=N&cd=1&ct=rc&cs_p=http://su-se.lunar-linux.org/lunar/mirrors/glibc-2.3.3-cvs-20040708.tar.bz2&cs_f=glibc-2.3.3-cvs-20040708/sysdeps/unix/sysv/linux/getsysstats.c
I see it counting cpu<n> lines in /proc/stat, which is what I'm
seeing. It will also look at /proc/cpuinfo. Can you strace your
version and see if it's looking there at all?
Jeff
--
Work email - jdike at linux dot intel dot com
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [uml-devel] sysconf(_SC_NPROCESSORS_CONF) returning zero
2008-08-04 21:47 ` Jeff Dike
@ 2008-08-04 22:06 ` Stanislav Meduna
2008-08-04 22:07 ` Ingo van Lil
1 sibling, 0 replies; 6+ messages in thread
From: Stanislav Meduna @ 2008-08-04 22:06 UTC (permalink / raw)
To: user-mode-linux-devel
Jeff Dike wrote:
> I see it counting cpu<n> lines in /proc/stat, which is what I'm
> seeing. It will also look at /proc/cpuinfo. Can you strace your
> version and see if it's looking there at all?
No.. looks like they changed the method:
open("/sys/devices/system/cpu", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80
000) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
getdents64(3, /* 5 entries */, 4096) = 144
getdents64(3, /* 0 entries */, 4096) = 0
close(3) = 0
No reference to /proc/stat nor /proc/cpuinfo.
# ls -l /sys/devices/system/cpu
-r--r--r-- 1 root root 4096 2008-08-04 23:51 online
-r--r--r-- 1 root root 4096 2008-08-04 23:51 possible
-r--r--r-- 1 root root 4096 2008-08-04 23:51 present
# cat /sys/devices/system/cpu/online
0
# cat /sys/devices/system/cpu/possible
0
# cat /sys/devices/system/cpu/present
0
On another Linux (real, 2.6.18) this looks completely
different:
$ ls -l /sys/devices/system/cpu
total 0
drwxr-xr-x 4 root root 0 2008-08-04 23:53 cpu0
$ ls -l /sys/devices/system/cpu/cpu0/
total 0
drwxr-xr-x 5 root root 0 2007-06-11 09:30 cache
-r-------- 1 root root 4096 2008-08-04 23:53 crash_notes
drwxr-xr-x 2 root root 0 2007-06-11 09:30 topology
Well.. so this is an interface definition problem.. now who has
changet something and did not tell the others..
--
Stano
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [uml-devel] sysconf(_SC_NPROCESSORS_CONF) returning zero
2008-08-04 21:47 ` Jeff Dike
2008-08-04 22:06 ` Stanislav Meduna
@ 2008-08-04 22:07 ` Ingo van Lil
1 sibling, 0 replies; 6+ messages in thread
From: Ingo van Lil @ 2008-08-04 22:07 UTC (permalink / raw)
To: Jeff Dike; +Cc: user-mode-linux-devel
Jeff Dike schrieb:
>> Hmmm... so I have cpu0 similar to yours. What version
>> of UML and libc do you have?
>
> UML 2.6.26 and an older libc:
>
> % ls -l /lib/libc.so.6
> lrwxrwxrwx 1 root root 11 Jun 2 2007 /lib/libc.so.6 -> libc-2.5.so
>
> Looking through libc at
>
> http://www.google.com/codesearch?hl=en&q=file:\.c%24+\"/stat\"+package:http://su-se.lunar-linux.org/lunar/mirrors/glibc-2.3.3-cvs-20040708.tar.bz2+show:m1O9RV1wlw4:qbkros5194A:MbxD3_8dUHU&sa=N&cd=1&ct=rc&cs_p=http://su-se.lunar-linux.org/lunar/mirrors/glibc-2.3.3-cvs-20040708.tar.bz2&cs_f=glibc-2.3.3-cvs-20040708/sysdeps/unix/sysv/linux/getsysstats.c
>
> I see it counting cpu<n> lines in /proc/stat, which is what I'm
> seeing. It will also look at /proc/cpuinfo. Can you strace your
> version and see if it's looking there at all?
More recent versions of glibc (here: 2.8 on Fedora 9) seem to look at
the contents of /sys/devices/system/cpu instead. That directory is empty
in UML, which might explain the odd result from Stanislav's program.
Cheers,
Ingo
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-08-04 22:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-04 13:58 [uml-devel] sysconf(_SC_NPROCESSORS_CONF) returning zero Stanislav Meduna
2008-08-04 20:33 ` Jeff Dike
2008-08-04 20:59 ` Stanislav Meduna
2008-08-04 21:47 ` Jeff Dike
2008-08-04 22:06 ` Stanislav Meduna
2008-08-04 22:07 ` Ingo van Lil
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.