Skip to content

Commit

Permalink
highmem: Use this_cpu_xx_return() operations
Browse files Browse the repository at this point in the history
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.

V3->V4
	- kmap_atomic_idx: Do not return a value.
	- Use __this_cpu_dec without HIGHMEM_DEBUG

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Christoph Lameter authored and Tejun Heo committed Dec 17, 2010
1 parent 908ee0f commit cfb8243
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions include/linux/highmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -91,16 +92,18 @@ static inline int kmap_atomic_idx_push(void)

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)
static inline void kmap_atomic_idx_pop(void)
{
int idx = --__get_cpu_var(__kmap_atomic_idx);
#ifdef CONFIG_DEBUG_HIGHMEM
int idx = __this_cpu_dec_return(__kmap_atomic_idx);

BUG_ON(idx < 0);
#else
__this_cpu_dec(__kmap_atomic_idx);
#endif
return idx;
}

#endif
Expand Down

0 comments on commit cfb8243

Please sign in to comment.