lkml.org 
[lkml]   [2002]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] 2.5.1-pre5: per-cpu areas
On Thu, Mar 14, 2002 at 10:04:05AM -0800, David Mosberger wrote:
> How about the following proposal:
>
> - taking the address of this_cpu(var) is never allowed (can be
> enforced with RELOC_HIDE())
>
> - taking the address of per_cpu(var, n) is always legal and
> will return a pointer which will access CPU n's version of
> the variable, no matter what CPU dereferences the pointer
>
> Andi, I think this would take care of the x86-64 problem as well, right?

Yes, it would.

It would be a bit more overhead for taking the address than a
this_cpu_address(), because one would need to fetch the CPU number first
and do the arithmetic and the array reference instead of fetching the
address directly. But I agree that per_cpu() has much cleaner semantics than
this_cpu_address() for addresses, so it is worth it.

When one considers preemptive kernels where you can lose your CPU anytime
then it makes even more sense. But then this_cpu is only safe there when
you turn off preemption or hold some lock or run in interrupt context.
Outside such regions per_cpu() seems to be safer.

Thanks,
-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.072 / U:0.692 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site