Re: per cpun+ spin locks coexistence?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Peter Teoh <htmldeveloper@...>
Cc: Jeremy Fitzhardinge <jeremy@...>, LKML <linux-kernel@...>, Tejun Heo <htejun@...>, Dipankar Sarma <dipankar@...>
Date: Sunday, March 16, 2008 - 4:20 pm

Hi Peter,

"Peter Teoh" <htmldeveloper@gmail.com> writes:


RELOC_HIDE is a GCC hack.  It does basically p+offset.


A per-cpu variable is basically an array the size of the number of
possible CPUs in the system.  get_cpu_var() checks what current CPU we
are running on and gets the array-element corresponding to this CPU.

So, really oversimplified, get_cpu_var(foo) translates to something like
foo[smp_processor_id()].

But per_cpu(), as Jemery said, allows you to retrieve an element from
the array that is not meant for your current CPU.  So even if you run on
CPU1, you might fetch the element that is meant for use on CPU0.

But even if you don't access the cpu-local variable from other CPUs, the
element might still be a reference to a shared structure that you have
to lock properly.  Another CPU might have a reference to this same
structure as well in its per-cpu variable.

	Hannes
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
per cpun+ spin locks coexistence?, Peter Teoh, (Wed Mar 12, 12:17 pm)
Re: per cpun+ spin locks coexistence?, Jeremy Fitzhardinge, (Fri Mar 14, 1:54 pm)
Re: per cpun+ spin locks coexistence?, Peter Teoh, (Sun Mar 16, 12:30 pm)
Re: per cpun+ spin locks coexistence?, Johannes Weiner, (Sun Mar 16, 4:20 pm)
Re: per cpun+ spin locks coexistence?, Peter Teoh, (Mon Mar 17, 1:06 pm)
Re: per cpun+ spin locks coexistence?, Johannes Weiner, (Mon Mar 17, 1:51 pm)
Re: per cpun+ spin locks coexistence?, Eric Dumazet, (Mon Mar 17, 3:22 pm)
Re: per cpun+ spin locks coexistence?, Peter Teoh, (Tue Mar 18, 1:00 pm)
Re: per cpun+ spin locks coexistence?, Eric Dumazet, (Tue Mar 18, 2:00 pm)
Re: per cpun+ spin locks coexistence?, Peter Teoh, (Wed Mar 19, 12:25 pm)
Re: per cpun+ spin locks coexistence?, Dipankar Sarma, (Tue Mar 18, 1:34 pm)