Re: what is __get_cpu_var() ?

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

 



Hi Dave,
thanks for your reply.

On Wed, Feb 23, 2011 at 1:22 AM, Dave Hylands <dhylands@xxxxxxxxx> wrote:
> Hi Murali,
>
> On Tue, Feb 22, 2011 at 9:27 PM, Murali N <nalajala.murali@xxxxxxxxx> wrote:
>> Hi,
>> can somebody explain me what "__get_cpu_var()" macro does?
>> I try to understand this macro but i couldn't, its representation is weired!!!
>
> get_cpu_var returns the contents of a per-cpu variable.
>
> __get_cpu_var contains the actual machine-dependant implementation. It
> looks like all of the architectures use the one in
> asm-generic/percpu.h
>
> In general, all of the per-cpu data is gathered together into a
> section. Multiple sections are allocated (one per CPU). I think that
> the address of the variable is really the offset within the section,
> and each allocated section is cache-line aligned. This offset is then
> added to the "offset for my cpu" to come up with the final address of
> the variable, which is dereferenced as a pointer dereference. There
> are lots of extra doo-dads to get around warnings, and to prevent the
> linker from producing relocation references for for the variable
> access (since it looks like an access of a global variable, but it's
> really just doing a game of using the offset of the variable within
> the section).
>
> So you could think of it as a very fancy offsetof macro.
>
> There are several other macros involved, perhaps you could be a bit
> more specific about your request?
>
> Dave Hylands
>

I have one more basic question.
Why would we need to maintain structures like this? Is there any
advantage we get here?
I saw one of the architectures specifics timer code, through out the
code they are using this macro.

-- 
Regards,
Murali N

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux