Discussion:
SMP in machine/params.h
Pietro Cerutti
2008-01-24 12:38:39 UTC
Permalink
Hello,

I'm running a Core2Duo on CURRENT, SMP kernel, but somehow the macro SMP
in machine/param.h 1.81 2006/01/09 line 68 is not defined, thus MAXCPU
is defined to 1. Any idea why?
uname -a
FreeBSD gahrtop.localhost 8.0-CURRENT FreeBSD 8.0-CURRENT #23: Tue Jan
22 00:15:05 CET 2008
sysctl kern.smp.active kern.smp.maxcpus
kern.smp.active: 1
kern.smp.maxcpus: 16
cat smp.c
#include <sys/param.h>

#ifndef SMP
# error SMP not defined
#endif
make smp
cc -O2 -pipe -march=pentiumpro smp.c -o smp
smp.c:5:3: error: #error SMP not defined
*** Error code 1
cat maxcpu.c
#include <sys/param.h>
#include <stdio.h>

int main(void)
{
return (MAXCPU);
}
./maxcpu; echo $?
1

Any idea?
--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Pietro Cerutti
2008-01-24 12:56:30 UTC
Permalink
Post by Pietro Cerutti
Hello,
I'm running a Core2Duo on CURRENT, SMP kernel, but somehow the macro SMP
in machine/param.h 1.81 2006/01/09 line 68 is not defined, thus MAXCPU
is defined to 1. Any idea why?
uname -a
FreeBSD gahrtop.localhost 8.0-CURRENT FreeBSD 8.0-CURRENT #23: Tue Jan
22 00:15:05 CET 2008
sysctl kern.smp.active kern.smp.maxcpus
kern.smp.active: 1
kern.smp.maxcpus: 16
cat smp.c
#include <sys/param.h>
#ifndef SMP
# error SMP not defined
#endif
make smp
cc -O2 -pipe -march=pentiumpro smp.c -o smp
smp.c:5:3: error: #error SMP not defined
*** Error code 1
cat maxcpu.c
#include <sys/param.h>
#include <stdio.h>
int main(void)
{
return (MAXCPU);
}
./maxcpu; echo $?
1
Any idea?
Did you define SMP in your config file?
Yes. How could I have kern.smp.active: 1 otherwise?
grep SMP /sys/i386/conf/MSI1034
# To make an SMP kernel, the next two lines are needed
options SMP # Symmetric MultiProcessor Kernel
Attilio
--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Pietro Cerutti
2008-01-24 13:05:07 UTC
Permalink
Post by Pietro Cerutti
Did you define SMP in your config file?
Yes. How could I have kern.smp.active: 1 otherwise?
grep SMP /sys/i386/conf/MSI1034
# To make an SMP kernel, the next two lines are needed
options SMP # Symmetric MultiProcessor Kernel
grep "SMP" /usr/obj/usr/src/sys/MSI1034/opt_global.h
#define SMP 1
Post by Pietro Cerutti
Attilio
--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Pietro Cerutti
2008-01-24 13:38:02 UTC
Permalink
Some more interesting findings in this field lead me to another related
question:

what is the relation between kern.smp.cpus, kern.smp.active and
kern.smp.maxcpus?

To my understanding, it should be:
If the machine has more than one CPU, and SMP and apic are enabled in
the config file, then

kern.smp.cpus = nof cpus in the system
kern.smp.active = 1
kern.smp.maxcpus = 16

else

kern.smp.cpus = 1
kern.smp.active = 0
kern.smp.maxcpus = 1

This is the expected result, and also the result I get from my single
CPU Pentium 3, running 6.3-RELEASE:

kern.smp.cpus: 1
kern.smp.active: 0
kern.smp.maxcpus: 1

From my single CPU sparc64, running 7.0-PRERELEASE, I get:

kern.smp.cpus: 1
kern.smp.active: 0
kern.smp.maxcpus: 16 <-- why not 1??

From my Core2Due, running 8.0-CURRENT, I get:

kern.smp.cpus: 2
kern.smp.active: 1
kern.smp.maxcpus: 16

which is OK, but nevertheless SMP is not defined in sys/param.h (see
previous posts).


Thanks for any insight,
--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Ivan Voras
2008-01-24 13:45:36 UTC
Permalink
Post by Pietro Cerutti
This is the expected result, and also the result I get from my single
kern.smp.cpus: 1
kern.smp.active: 0
kern.smp.maxcpus: 1
kern.smp.cpus: 1
kern.smp.active: 0
kern.smp.maxcpus: 16 <-- why not 1??
maxcpus is the maximum number of CPUs supported by the kernel. I.e. if
the kernel is UP, maxcpus is 1, if the kernel is SMP, maxcpus is 16.
This means (though you probably won't care) that if you have a 32-CPU
machine, ony 16 of them will be used by the SMP kernel.
John Baldwin
2008-01-24 20:14:38 UTC
Permalink
Post by Pietro Cerutti
Hello,
I'm running a Core2Duo on CURRENT, SMP kernel, but somehow the macro SMP
in machine/param.h 1.81 2006/01/09 line 68 is not defined, thus MAXCPU
is defined to 1. Any idea why?
It is defined in opt_global.h for a kernel build, but it is not defined in
userland. If you want to use MAXCPU in userland you should query the
appropriate sysctl (kern.smp.maxcpu) instead.
--
John Baldwin
Pietro Cerutti
2008-01-25 00:00:00 UTC
Permalink
Post by John Baldwin
Post by Pietro Cerutti
Hello,
I'm running a Core2Duo on CURRENT, SMP kernel, but somehow the macro SMP
in machine/param.h 1.81 2006/01/09 line 68 is not defined, thus MAXCPU
is defined to 1. Any idea why?
It is defined in opt_global.h for a kernel build, but it is not defined in
userland. If you want to use MAXCPU in userland you should query the
appropriate sysctl (kern.smp.maxcpu) instead.
Thanks for the clarification!
--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Loading...