hwpmc dealing with sparse cpu systems.

Alfred Perlstein alfred at freebsd.org
Fri Oct 12 13:22:49 PDT 2007

One of the engineers here seems to have found a bug in the
hwpmc_mod.c module.  The problem we have is that cpuids can
be greater than mp_ncpus due to sparseness.

Does the fix here make sense?  (replace mp_ncpus with MAXCPU)

I would like to commit it.


----- Forwarded message from Alfred Perlstein <perlstein at juniper.net> -----

From: "Sunil Mudunuri"
Subject: Re: hwpmc on mpsdk.
Date: Thu, 11 Oct 2007 18:11:27 -0700
Message-ID: <470EC9BF.5070607 at juniper.net>
User-Agent: Mozilla Thunderbird 1.0 (X11/20041206)

Looking at the code in hwpmc_mod.c, I feel that
the mp_ncpus (global) is wrongly used in this module.

While mp_ncpus is the count of active cpus in the system,
this is being used to range check a cpu id(active/inactive) which can be 
greater than mp_ncpus.

The code works fine in systems which has all the cpu's active eg. 
SPU(australia), but is causing crashes
in mpsdk where we have the active cpus interleaved with idle cpu's.

I replaced mp_ncpus with MAXCPU in almost all the places and it works fine.

So this should be fixed in the FreeBSD proper, I guess.

Alfred/Girish, can you push this to be fixed in FreeBSD


----- End forwarded message -----

- Alfred Perlstein

More information about the freebsd-smp mailing list