Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 07 Oct 2001 09:28:16 -0700 (PDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
Cc:        Alfred Perlstein <bright@mu.org>, smp@freebsd.org
Subject:   Re: How to distinguish the SMP kernel and the UP kernel
Message-ID:  <XFMail.011007092816.jhb@FreeBSD.org>
In-Reply-To: <200110060625.PAA02451@zodiac.mech.utsunomiya-u.ac.jp>

next in thread | previous in thread | raw e-mail | index | archive | help

On 06-Oct-01 Kazutaka YOKOTA wrote:
> 
>>> - The following patch will add a new sysctl variable.
>>> 
>>> kern.smp.kernel
>>> 
>>> This will be 0 for the UP kernel and 1 for the SMP kernel.
>>> 
>>> - It also make kern.smp.active available in the UP kernel as well.
>>> (Previously this sysctl variable was only present in the SMP
>>> kernel.) It will always be 0 for the UP kernel.
>>
>>This shouldn't be done.  There's no need for 2 copies of the same sysctl. 
>>Actually, userland can _already_ tell if it is an SMP kernel or not by
>>looking
>>if the kern.smp.active sysctl exists.  This is how top works, for example. 
>>Thus, userland doesn't need any of this.  Only in the kernel do you need
>>this.
>> 
>>Now, ideally kernel modules shouldn't care if they are on a SMP kernel or
>>not.
> 
> I agree. But, some modules need to know ;-<  I was trying to make
> the pnpbios driver into a module and it has #ifdef SMP in it.

Ah, ok.  Yes, that might be a bit tricky in that case. :-)

>>Why does the module in question care?  The only thing I would do here is
>>possibly export a global variable saying if SMP was compiled in, nothing
>>more.
> 
> This is fine, as I am not very much interested in exposing to the userland
> which kernel configration, SMP or UP, is running.

Fair enough.  I really would prefer that the variable not be in subr_smp.c so
that we don't have compile all of that file just for one variable in a UP
kernel.  I'm not sure of a better place, however.  To avoid adding too many
variables, I would suggest exporting smp_active in the UP case (but not the
sysctl, as that might break things like top).

> Kazu

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.011007092816.jhb>