Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Oct 2007 16:53:53 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        Darren Pilgrim <freebsd@bitfreak.org>
Subject:   Re: Non-sequential AP starts [Was: Re: 8-core server]
Message-ID:  <200710101653.54019.jhb@freebsd.org>
In-Reply-To: <46FDD3AB.3050305@bitfreak.org>
References:  <b41c75520709280103ied4e99dvfd33884185792a91@mail.gmail.com> <20070928184659.GB57646@cicely12.cicely.de> <46FDD3AB.3050305@bitfreak.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 29 September 2007 12:25:15 am Darren Pilgrim wrote:
> Bernd Walter wrote:
> > On Fri, Sep 28, 2007 at 07:56:49AM -0700, Darren Pilgrim wrote:
> >> Jeremy Chadwick wrote:
> >>> I think what you're not noticing is that the cores are being launched in
> >>> non-sequential order.  1, 2, 3, 4, 7, 5, 6.  This isn't a problem.
> >> Why they wouldn't be launched sequentially?
> > 
> > First SMP rule:
> > Don't expect a specific execution order from things running parallel.
> > 
> > I don't know the code, but would assume that they are started
> > sequentially and each core prints it's own line, so they get
> > disordered.
> 
> This question bugged me long enough for me to go read some source to 
> find the answer, but I ended up with more questions.  I guess that's 
> what I get for reading boot code. :)  I know it's basically just a race 
> condition, but where does the race actually occur?  In each core's 
> execution of startup instructions leading up to the printf() in 
> init_secondary() or in the assignment of the value returned by 
> PCPU_GET(cpudid)?  Where is the data behind PCPU_GET() anyway?  I 
> couldn't find it.  Is AP launch order random or are there CPU 
> characteristics that result in reproducible non-sequential ordering?

The lauch is random.  The boot processor sets a flag to tell the APs (which 
are already running, but spinnin in a loop) "ok, go run".  The APs then 
compete on a spin lock to serialize their final initialization, and 
they "launch" in the order they acquire the spin lock, which is quite 
indeterminate.

-- 
John Baldwin



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