Re: [PATCH] [CPU-HOTPLUG] convert cpucontrol to be a rwsem

Lee Revell
2004-11-02T15:11:00Z

On Tue, 2004-11-02 at 10:48 +1100, Rusty Russell wrote:
> On Mon, 2004-11-01 at 13:04 -0500, Lee Revell wrote:
> > On Mon, 2004-11-01 at 07:00 -0700, Zwane Mwaikambo wrote:
> > > Agreed it makes a lot more sense, i think there could be some places where
> > > we use preempt_disable to protect against cpu offline which could
> > > converted, but that can come later.
> > >
> >
> > You know I picked up Robert Love's book the other day and was surprised
> > to read we are not supposed to be using preempt_disable, there is a
> > per_cpu interface for exactly this kind of thing. Which is currently
> > recommended?
>
> get_cpu() both ensures that this CPU won't go down, and ensures we won't
> get scheduled off it. It returns the current processor ID, as well.
> put_cpu() puts the CPU back.
>
> In my experience it's usually clearer than preempt_disable().

To answer Zwane's earlier question, Love's book covers this on page 136,
then all of Appendix B. I also completely missed this the first time...

Lee