[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] SMP initialization: detection and enumeration

From: Richard Braun
Subject: Re: [PATCH] SMP initialization: detection and enumeration
Date: Thu, 30 Jul 2020 23:06:56 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

On Thu, Jul 30, 2020 at 10:44:40PM +0200, Samuel Thibault wrote:
> > > I'm wondering: is it really *that* simple to get the current cpu number,
> > > just read a memory location?  I'm surprised that this would provide
> > > different results on different cpus.
> > 
> > The APIC ID is stored in the Local APIC of each cpu. This address is common 
> > for
> > all Local APIC: accessing this from each cpu, it shows the Local APIC of 
> > this
> > cpu.
> > By example, if you access this address from cpu1, you can see the Local 
> > APIC of
> > cpu1.
> So it's a special address whose accesses are trapped within the chip and
> don't actually get out on the memory bus?

It's physically memory mapped to the local APIC address space, but
because of that, it's also not optimal. All systems I know use a scheme
similar to TLS, i.e. using the fs or gs segment register, to fetch
a per-CPU structure and from it, per-CPU data. This avoids relying on
hardware running at a lower frequency than the CPU.

Richard Braun

reply via email to

[Prev in Thread] Current Thread [Next in Thread]