Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Mar 2012 08:34:08 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Maninya M <maninya@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: CPUID and CPU STATE
Message-ID:  <201203060834.08160.jhb@freebsd.org>
In-Reply-To: <CAC46K3kZCS1__ESeTkRojoi4GqWeE3AfTuz5CQkkw1bhzb4LWg@mail.gmail.com>
References:  <CAC46K3mS1FSy0qpze7hN6YzR_63xT9eMHUXgLJo5cjyzMz=RnQ@mail.gmail.com> <201203051221.08681.jhb@freebsd.org> <CAC46K3kZCS1__ESeTkRojoi4GqWeE3AfTuz5CQkkw1bhzb4LWg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, March 06, 2012 2:16:03 am Maninya M wrote:
> Thank you.
> How do we get hardware cpuid?
> Can we change the number of CPUs available to the scheduler (in the
> scheduler code) dynamically, say completely cutting off a specific cpu core
> from being used at all?

The hardware cpuid is machine-dependent.  If you are in the kernel, you can 
use PCPU_GET(apic_id) on x86 to get the local APIC ID.  Other platforms have a 
similar per-CPU variable.  As far as getting it from userland, we do not have 
a good way of getting it currently aside from scraping /var/run/dmesg.boot or 
using libkvm to grovel around in kernel variables.

As far as offlining a CPU, we do not have a way to do that currently (though
you can take it out of the default cpuset which will prevent user threads from
using it).
 
> On 5 March 2012 22:51, John Baldwin <jhb@freebsd.org> wrote:
> 
> > On Friday, March 02, 2012 2:20:00 am Maninya M wrote:
> > > I was unable to get this information about the cpuid variable in the
> > > scheduler source code.
> > > How does cpuid get its value from the hardware?
> >
> > The cpuid is a software ID value assigned during boot.  It is not
> > directly related to any specific hardware IDs.
> >
> > > How is the CPUSTATES value obtained/changed with  hardware in the source
> > > code?
> >
> > Do you mean, does cp_time[] handle hardware changes (hotplug CPUs, etc.)?
> > Currently that isn't supported, the kernel assumes the set of CPUs is
> > static for a given boot's lifetime.
> >
> > --
> > John Baldwin
> >
> 
> 
> 
> -- 
> Maninya
> 

-- 
John Baldwin



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