From owner-freebsd-smp Fri Oct 5 23:13:21 2001 Delivered-To: freebsd-smp@freebsd.org Received: from nasu.utsunomiya-u.ac.jp (nasu.utsunomiya-u.ac.jp [160.12.128.3]) by hub.freebsd.org (Postfix) with ESMTP id 7EECE37B422 for ; Fri, 5 Oct 2001 23:13:03 -0700 (PDT) Received: from nantai.utsunomiya-u.ac.jp by nasu.utsunomiya-u.ac.jp (8.11.2/1.1.29.3/26Jan01-1134AM) id f966Cm593890; Sat, 6 Oct 2001 15:12:48 +0900 (JST) Received: from zodiac.mech.utsunomiya-u.ac.jp by nantai.utsunomiya-u.ac.jp (8.11.2/1.1.29.3/30Jan01-0241PM) id f966ClE73635; Sat, 6 Oct 2001 15:12:47 +0900 (JST) Received: from zodiac.mech.utsunomiya-u.ac.jp (IDENT:MPP64vOnghrN5CW2YByjF1W3FRh1U5Cp@zodiac.mech.utsunomiya-u.ac.jp [160.12.43.7]) by zodiac.mech.utsunomiya-u.ac.jp (8.9.3+3.2W/3.7W/zodiac-May2000) with ESMTP id PAA02409; Sat, 6 Oct 2001 15:22:43 +0900 (JST) Message-Id: <200110060622.PAA02409@zodiac.mech.utsunomiya-u.ac.jp> To: tlambert2@mindspring.com Cc: smp@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp Subject: Re: How to distinguish the SMP kernel and the UP kernel In-reply-to: Your message of "Fri, 05 Oct 2001 02:43:21 MST." <3BBD80B9.4191B288@mindspring.com> References: <200110030310.MAA13836@zodiac.mech.utsunomiya-u.ac.jp> <3BBB6757.9A668E99@mindspring.com> <200110041211.VAA24646@zodiac.mech.utsunomiya-u.ac.jp> <3BBD80B9.4191B288@mindspring.com> Date: Sat, 06 Oct 2001 15:22:42 +0900 From: Kazutaka YOKOTA Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >> When hw.ncpu == 1, it doesn't necessarily signifies the kernel >> is configured for UP. Because it is perfectly permissible >> to run the SMP kernel on the multi-CPU motherboard with only one >> CPU installed... >> >> Am I wrong? > >No. > >I assumed you wanted the information to determine how many >kernel threads, etc., to run in order to ensure that your >code would operate optimally to take advantage of the extra >hardware. No, you guessed wrong :-) I am not interested in optimizing for the SMP environment. I was simply interested in making a device driver into a module, and found the following conditional in the code. #ifdef SMP ... #else /* for UP */ ... #endif or #ifdef APIC_IO ... #else ... #endif In order to make this module work, we can do either 1) provide a kernel global variable to indicate whether the kernel is configured for SMP, or UP (smp_kernel), or 2) compile two versions of the module: one for SMP, another for UP, as you suggested. Load either of the two depending on the running kernel configuration. If the code in question involves in manipulating structures which have different members or sizes in SMP and UP kernels, the first approach don't work, as you pointed out. The second approach won't work now, as neither the boot loader or kldload has this capability at the moment. Kazu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message