lkml.org 
[lkml]   [2010]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [thisops uV3 07/18] highmem: Use this_cpu_xx_return() operations
From
Date
Le mardi 30 novembre 2010 à 13:07 -0600, Christoph Lameter a écrit :
> pièce jointe document texte brut (this_cpu_highmem)
> Use this_cpu operations to optimize access primitives for highmem.
>
> The main effect is the avoidance of address calculations through the
> use of a segment prefix.
>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Christoph Lameter <cl@linux.com>
>
> ---
> include/linux/highmem.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> Index: linux-2.6/include/linux/highmem.h
> ===================================================================
> --- linux-2.6.orig/include/linux/highmem.h 2010-11-22 14:43:40.000000000 -0600
> +++ linux-2.6/include/linux/highmem.h 2010-11-22 14:45:02.000000000 -0600
> @@ -81,7 +81,8 @@ DECLARE_PER_CPU(int, __kmap_atomic_idx);
>
> static inline int kmap_atomic_idx_push(void)
> {
> - int idx = __get_cpu_var(__kmap_atomic_idx)++;
> + int idx = __this_cpu_inc_return(__kmap_atomic_idx) - 1;
> +
> #ifdef CONFIG_DEBUG_HIGHMEM
> WARN_ON_ONCE(in_irq() && !irqs_disabled());
> BUG_ON(idx > KM_TYPE_NR);
> @@ -91,12 +92,12 @@ static inline int kmap_atomic_idx_push(v
>
> static inline int kmap_atomic_idx(void)
> {
> - return __get_cpu_var(__kmap_atomic_idx) - 1;
> + return __this_cpu_read(__kmap_atomic_idx) - 1;
> }
>
> static inline int kmap_atomic_idx_pop(void)
> {
> - int idx = --__get_cpu_var(__kmap_atomic_idx);
> + int idx = __this_cpu_dec_return(__kmap_atomic_idx);

__this_cpu_dec_return() is only needed if CONFIG_DEBUG_HIGHMEM

> #ifdef CONFIG_DEBUG_HIGHMEM
> BUG_ON(idx < 0);
> #endif
>

You could change kmap_atomic_idx_pop() to return void, and use
__this_cpu_dec(__kmap_atomic_idx)


--
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: 2010-11-30 20:15    [from the cache]
©2003-2011 Jasper Spaans