Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85be928c authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'perfcounters-fixes-for-linus' of...

Merge branch 'perfcounters-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perfcounters-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (50 commits)
  perf report: Add "Fractal" mode output - support callchains with relative overhead rate
  perf_counter tools: callchains: Manage the cumul hits on the fly
  perf report: Change default callchain parameters
  perf report: Use a modifiable string for default callchain options
  perf report: Warn on callchain output request from non-callchain file
  x86: atomic64: Inline atomic64_read() again
  x86: atomic64: Clean up atomic64_sub_and_test() and atomic64_add_negative()
  x86: atomic64: Improve atomic64_xchg()
  x86: atomic64: Export APIs to modules
  x86: atomic64: Improve atomic64_read()
  x86: atomic64: Code atomic(64)_read and atomic(64)_set in C not CPP
  x86: atomic64: Fix unclean type use in atomic64_xchg()
  x86: atomic64: Make atomic_read() type-safe
  x86: atomic64: Reduce size of functions
  x86: atomic64: Improve atomic64_add_return()
  x86: atomic64: Improve cmpxchg8b()
  x86: atomic64: Improve atomic64_read()
  x86: atomic64: Move the 32-bit atomic64_t implementation to a .c file
  x86: atomic64: The atomic64_t data type should be 8 bytes aligned on 32-bit too
  perf report: Annotate variable initialization
  ...
parents d86ee480 805d127d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -358,6 +358,7 @@ static struct power_pmu power7_pmu = {
	.get_constraint		= power7_get_constraint,
	.get_alternatives	= power7_get_alternatives,
	.disable_pmc		= power7_disable_pmc,
	.flags			= PPMU_ALT_SIPR,
	.n_generic		= ARRAY_SIZE(power7_generic_events),
	.generic_events		= power7_generic_events,
	.cache_events		= &power7_cache_events,
+57 −128
Original line number Diff line number Diff line
@@ -19,7 +19,10 @@
 *
 * Atomically reads the value of @v.
 */
#define atomic_read(v)		((v)->counter)
static inline int atomic_read(const atomic_t *v)
{
	return v->counter;
}

/**
 * atomic_set - set atomic variable
@@ -28,7 +31,10 @@
 *
 * Atomically sets the value of @v to @i.
 */
#define atomic_set(v, i)	(((v)->counter) = (i))
static inline void atomic_set(atomic_t *v, int i)
{
	v->counter = i;
}

/**
 * atomic_add - add integer to atomic variable
@@ -200,8 +206,15 @@ static inline int atomic_sub_return(int i, atomic_t *v)
	return atomic_add_return(-i, v);
}

#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
{
	return cmpxchg(&v->counter, old, new);
}

static inline int atomic_xchg(atomic_t *v, int new)
{
	return xchg(&v->counter, new);
}

/**
 * atomic_add_unless - add unless the number is already a given value
@@ -250,45 +263,12 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
/* An 64bit atomic type */

typedef struct {
	unsigned long long counter;
	u64 __aligned(8) counter;
} atomic64_t;

#define ATOMIC64_INIT(val)	{ (val) }

/**
 * atomic64_read - read atomic64 variable
 * @ptr: pointer of type atomic64_t
 *
 * Atomically reads the value of @v.
 * Doesn't imply a read memory barrier.
 */
#define __atomic64_read(ptr)		((ptr)->counter)

static inline unsigned long long
cmpxchg8b(unsigned long long *ptr, unsigned long long old, unsigned long long new)
{
	asm volatile(

		LOCK_PREFIX "cmpxchg8b (%[ptr])\n"

		     :		"=A" (old)

		     : [ptr]	"D" (ptr),
				"A" (old),
				"b" (ll_low(new)),
				"c" (ll_high(new))

		     : "memory");

	return old;
}

static inline unsigned long long
atomic64_cmpxchg(atomic64_t *ptr, unsigned long long old_val,
		 unsigned long long new_val)
{
	return cmpxchg8b(&ptr->counter, old_val, new_val);
}
extern u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old_val, u64 new_val);

/**
 * atomic64_xchg - xchg atomic64 variable
@@ -298,18 +278,7 @@ atomic64_cmpxchg(atomic64_t *ptr, unsigned long long old_val,
 * Atomically xchgs the value of @ptr to @new_val and returns
 * the old value.
 */

static inline unsigned long long
atomic64_xchg(atomic64_t *ptr, unsigned long long new_val)
{
	unsigned long long old_val;

	do {
		old_val = atomic_read(ptr);
	} while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);

	return old_val;
}
extern u64 atomic64_xchg(atomic64_t *ptr, u64 new_val);

/**
 * atomic64_set - set atomic64 variable
@@ -318,10 +287,7 @@ atomic64_xchg(atomic64_t *ptr, unsigned long long new_val)
 *
 * Atomically sets the value of @ptr to @new_val.
 */
static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val)
{
	atomic64_xchg(ptr, new_val);
}
extern void atomic64_set(atomic64_t *ptr, u64 new_val);

/**
 * atomic64_read - read atomic64 variable
@@ -329,17 +295,30 @@ static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val)
 *
 * Atomically reads the value of @ptr and returns it.
 */
static inline unsigned long long atomic64_read(atomic64_t *ptr)
static inline u64 atomic64_read(atomic64_t *ptr)
{
	unsigned long long curr_val;

	do {
		curr_val = __atomic64_read(ptr);
	} while (atomic64_cmpxchg(ptr, curr_val, curr_val) != curr_val);
	u64 res;

	return curr_val;
	/*
	 * Note, we inline this atomic64_t primitive because
	 * it only clobbers EAX/EDX and leaves the others
	 * untouched. We also (somewhat subtly) rely on the
	 * fact that cmpxchg8b returns the current 64-bit value
	 * of the memory location we are touching:
	 */
	asm volatile(
		"mov %%ebx, %%eax\n\t"
		"mov %%ecx, %%edx\n\t"
		LOCK_PREFIX "cmpxchg8b %1\n"
			: "=&A" (res)
			: "m" (*ptr)
		);

	return res;
}

extern u64 atomic64_read(atomic64_t *ptr);

/**
 * atomic64_add_return - add and return
 * @delta: integer value to add
@@ -347,34 +326,14 @@ static inline unsigned long long atomic64_read(atomic64_t *ptr)
 *
 * Atomically adds @delta to @ptr and returns @delta + *@ptr
 */
static inline unsigned long long
atomic64_add_return(unsigned long long delta, atomic64_t *ptr)
{
	unsigned long long old_val, new_val;

	do {
		old_val = atomic_read(ptr);
		new_val = old_val + delta;

	} while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);

	return new_val;
}

static inline long atomic64_sub_return(unsigned long long delta, atomic64_t *ptr)
{
	return atomic64_add_return(-delta, ptr);
}
extern u64 atomic64_add_return(u64 delta, atomic64_t *ptr);

static inline long atomic64_inc_return(atomic64_t *ptr)
{
	return atomic64_add_return(1, ptr);
}

static inline long atomic64_dec_return(atomic64_t *ptr)
{
	return atomic64_sub_return(1, ptr);
}
/*
 * Other variants with different arithmetic operators:
 */
extern u64 atomic64_sub_return(u64 delta, atomic64_t *ptr);
extern u64 atomic64_inc_return(atomic64_t *ptr);
extern u64 atomic64_dec_return(atomic64_t *ptr);

/**
 * atomic64_add - add integer to atomic64 variable
@@ -383,10 +342,7 @@ static inline long atomic64_dec_return(atomic64_t *ptr)
 *
 * Atomically adds @delta to @ptr.
 */
static inline void atomic64_add(unsigned long long delta, atomic64_t *ptr)
{
	atomic64_add_return(delta, ptr);
}
extern void atomic64_add(u64 delta, atomic64_t *ptr);

/**
 * atomic64_sub - subtract the atomic64 variable
@@ -395,10 +351,7 @@ static inline void atomic64_add(unsigned long long delta, atomic64_t *ptr)
 *
 * Atomically subtracts @delta from @ptr.
 */
static inline void atomic64_sub(unsigned long long delta, atomic64_t *ptr)
{
	atomic64_add(-delta, ptr);
}
extern void atomic64_sub(u64 delta, atomic64_t *ptr);

/**
 * atomic64_sub_and_test - subtract value from variable and test result
@@ -409,13 +362,7 @@ static inline void atomic64_sub(unsigned long long delta, atomic64_t *ptr)
 * true if the result is zero, or false for all
 * other cases.
 */
static inline int
atomic64_sub_and_test(unsigned long long delta, atomic64_t *ptr)
{
	unsigned long long old_val = atomic64_sub_return(delta, ptr);

	return old_val == 0;
}
extern int atomic64_sub_and_test(u64 delta, atomic64_t *ptr);

/**
 * atomic64_inc - increment atomic64 variable
@@ -423,10 +370,7 @@ atomic64_sub_and_test(unsigned long long delta, atomic64_t *ptr)
 *
 * Atomically increments @ptr by 1.
 */
static inline void atomic64_inc(atomic64_t *ptr)
{
	atomic64_add(1, ptr);
}
extern void atomic64_inc(atomic64_t *ptr);

/**
 * atomic64_dec - decrement atomic64 variable
@@ -434,10 +378,7 @@ static inline void atomic64_inc(atomic64_t *ptr)
 *
 * Atomically decrements @ptr by 1.
 */
static inline void atomic64_dec(atomic64_t *ptr)
{
	atomic64_sub(1, ptr);
}
extern void atomic64_dec(atomic64_t *ptr);

/**
 * atomic64_dec_and_test - decrement and test
@@ -447,10 +388,7 @@ static inline void atomic64_dec(atomic64_t *ptr)
 * returns true if the result is 0, or false for all other
 * cases.
 */
static inline int atomic64_dec_and_test(atomic64_t *ptr)
{
	return atomic64_sub_and_test(1, ptr);
}
extern int atomic64_dec_and_test(atomic64_t *ptr);

/**
 * atomic64_inc_and_test - increment and test
@@ -460,10 +398,7 @@ static inline int atomic64_dec_and_test(atomic64_t *ptr)
 * and returns true if the result is zero, or false for all
 * other cases.
 */
static inline int atomic64_inc_and_test(atomic64_t *ptr)
{
	return atomic64_sub_and_test(-1, ptr);
}
extern int atomic64_inc_and_test(atomic64_t *ptr);

/**
 * atomic64_add_negative - add and test if negative
@@ -474,13 +409,7 @@ static inline int atomic64_inc_and_test(atomic64_t *ptr)
 * if the result is negative, or false when
 * result is greater than or equal to zero.
 */
static inline int
atomic64_add_negative(unsigned long long delta, atomic64_t *ptr)
{
	long long old_val = atomic64_add_return(delta, ptr);

	return old_val < 0;
}
extern int atomic64_add_negative(u64 delta, atomic64_t *ptr);

#include <asm-generic/atomic-long.h>
#endif /* _ASM_X86_ATOMIC_32_H */
+34 −8
Original line number Diff line number Diff line
@@ -18,7 +18,10 @@
 *
 * Atomically reads the value of @v.
 */
#define atomic_read(v)		((v)->counter)
static inline int atomic_read(const atomic_t *v)
{
	return v->counter;
}

/**
 * atomic_set - set atomic variable
@@ -27,7 +30,10 @@
 *
 * Atomically sets the value of @v to @i.
 */
#define atomic_set(v, i)		(((v)->counter) = (i))
static inline void atomic_set(atomic_t *v, int i)
{
	v->counter = i;
}

/**
 * atomic_add - add integer to atomic variable
@@ -192,7 +198,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
 * Atomically reads the value of @v.
 * Doesn't imply a read memory barrier.
 */
#define atomic64_read(v)		((v)->counter)
static inline long atomic64_read(const atomic64_t *v)
{
	return v->counter;
}

/**
 * atomic64_set - set atomic64 variable
@@ -201,7 +210,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
 *
 * Atomically sets the value of @v to @i.
 */
#define atomic64_set(v, i)		(((v)->counter) = (i))
static inline void atomic64_set(atomic64_t *v, long i)
{
	v->counter = i;
}

/**
 * atomic64_add - add integer to atomic64 variable
@@ -355,11 +367,25 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
#define atomic64_inc_return(v)  (atomic64_add_return(1, (v)))
#define atomic64_dec_return(v)  (atomic64_sub_return(1, (v)))

#define atomic64_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
#define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
{
	return cmpxchg(&v->counter, old, new);
}

static inline long atomic64_xchg(atomic64_t *v, long new)
{
	return xchg(&v->counter, new);
}

#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
static inline long atomic_cmpxchg(atomic_t *v, int old, int new)
{
	return cmpxchg(&v->counter, old, new);
}

static inline long atomic_xchg(atomic_t *v, int new)
{
	return xchg(&v->counter, new);
}

/**
 * atomic_add_unless - add unless the number is a given value
+2 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@

extern int kstack_depth_to_print;

int x86_is_stack_id(int id, char *name);

/* Generic stack tracer with callbacks */

struct stacktrace_ops {
+7 −1
Original line number Diff line number Diff line
@@ -1561,6 +1561,7 @@ void callchain_store(struct perf_callchain_entry *entry, u64 ip)

static DEFINE_PER_CPU(struct perf_callchain_entry, irq_entry);
static DEFINE_PER_CPU(struct perf_callchain_entry, nmi_entry);
static DEFINE_PER_CPU(int, in_nmi_frame);


static void
@@ -1576,7 +1577,9 @@ static void backtrace_warning(void *data, char *msg)

static int backtrace_stack(void *data, char *name)
{
	/* Process all stacks: */
	per_cpu(in_nmi_frame, smp_processor_id()) =
			x86_is_stack_id(NMI_STACK, name);

	return 0;
}

@@ -1584,6 +1587,9 @@ static void backtrace_address(void *data, unsigned long addr, int reliable)
{
	struct perf_callchain_entry *entry = data;

	if (per_cpu(in_nmi_frame, smp_processor_id()))
		return;

	if (reliable)
		callchain_store(entry, addr);
}
Loading