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

Commit 500d85ce authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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

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

* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  perf tools: Fix time function double declaration with glibc
  perf tools: Fix build by checking if extra warnings are supported
  perf tools: Fix build when using gcc 3.4.6
  perf tools: Add missing header, fixes build
  perf tools: Fix 64 bit integer format strings
  perf test: Fix build on older glibcs
  perf: perf_event_exit_task_context: s/rcu_dereference/rcu_dereference_raw/
  perf test: Use cpu_map->[cpu] when setting affinity
  perf symbols: Fix annotation of thumb code
  perf: Annotate cpuctx->ctx.mutex to avoid a lockdep splat
  powerpc, perf: Fix frequency calculation for overflowing counters (FSL version)
  perf: Fix perf_event_init_task()/perf_event_free_task() interaction
  perf: Fix find_get_context() vs perf_event_exit_task() race
parents ce84d539 00e99a49
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -596,6 +596,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
			if (left <= 0)
			if (left <= 0)
				left = period;
				left = period;
			record = 1;
			record = 1;
			event->hw.last_period = event->hw.sample_period;
		}
		}
		if (left < 0x80000000LL)
		if (left < 0x80000000LL)
			val = 0x80000000LL - left;
			val = 0x80000000LL - left;
+27 −19
Original line number Original line Diff line number Diff line
@@ -2201,13 +2201,6 @@ find_lively_task_by_vpid(pid_t vpid)
	if (!task)
	if (!task)
		return ERR_PTR(-ESRCH);
		return ERR_PTR(-ESRCH);


	/*
	 * Can't attach events to a dying task.
	 */
	err = -ESRCH;
	if (task->flags & PF_EXITING)
		goto errout;

	/* Reuse ptrace permission checks for now. */
	/* Reuse ptrace permission checks for now. */
	err = -EACCES;
	err = -EACCES;
	if (!ptrace_may_access(task, PTRACE_MODE_READ))
	if (!ptrace_may_access(task, PTRACE_MODE_READ))
@@ -2268,14 +2261,27 @@ find_get_context(struct pmu *pmu, struct task_struct *task, int cpu)


		get_ctx(ctx);
		get_ctx(ctx);


		if (cmpxchg(&task->perf_event_ctxp[ctxn], NULL, ctx)) {
		err = 0;
		mutex_lock(&task->perf_event_mutex);
		/*
		/*
			 * We raced with some other task; use
		 * If it has already passed perf_event_exit_task().
			 * the context they set.
		 * we must see PF_EXITING, it takes this mutex too.
		 */
		 */
		if (task->flags & PF_EXITING)
			err = -ESRCH;
		else if (task->perf_event_ctxp[ctxn])
			err = -EAGAIN;
		else
			rcu_assign_pointer(task->perf_event_ctxp[ctxn], ctx);
		mutex_unlock(&task->perf_event_mutex);

		if (unlikely(err)) {
			put_task_struct(task);
			put_task_struct(task);
			kfree(ctx);
			kfree(ctx);

			if (err == -EAGAIN)
				goto retry;
				goto retry;
			goto errout;
		}
		}
	}
	}


@@ -5374,6 +5380,8 @@ static int pmu_dev_alloc(struct pmu *pmu)
	goto out;
	goto out;
}
}


static struct lock_class_key cpuctx_mutex;

int perf_pmu_register(struct pmu *pmu, char *name, int type)
int perf_pmu_register(struct pmu *pmu, char *name, int type)
{
{
	int cpu, ret;
	int cpu, ret;
@@ -5422,6 +5430,7 @@ int perf_pmu_register(struct pmu *pmu, char *name, int type)


		cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
		cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
		__perf_event_init_context(&cpuctx->ctx);
		__perf_event_init_context(&cpuctx->ctx);
		lockdep_set_class(&cpuctx->ctx.mutex, &cpuctx_mutex);
		cpuctx->ctx.type = cpu_context;
		cpuctx->ctx.type = cpu_context;
		cpuctx->ctx.pmu = pmu;
		cpuctx->ctx.pmu = pmu;
		cpuctx->jiffies_interval = 1;
		cpuctx->jiffies_interval = 1;
@@ -6127,7 +6136,7 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
	 * scheduled, so we are now safe from rescheduling changing
	 * scheduled, so we are now safe from rescheduling changing
	 * our context.
	 * our context.
	 */
	 */
	child_ctx = child->perf_event_ctxp[ctxn];
	child_ctx = rcu_dereference_raw(child->perf_event_ctxp[ctxn]);
	task_ctx_sched_out(child_ctx, EVENT_ALL);
	task_ctx_sched_out(child_ctx, EVENT_ALL);


	/*
	/*
@@ -6440,11 +6449,6 @@ int perf_event_init_context(struct task_struct *child, int ctxn)
	unsigned long flags;
	unsigned long flags;
	int ret = 0;
	int ret = 0;


	child->perf_event_ctxp[ctxn] = NULL;

	mutex_init(&child->perf_event_mutex);
	INIT_LIST_HEAD(&child->perf_event_list);

	if (likely(!parent->perf_event_ctxp[ctxn]))
	if (likely(!parent->perf_event_ctxp[ctxn]))
		return 0;
		return 0;


@@ -6533,6 +6537,10 @@ int perf_event_init_task(struct task_struct *child)
{
{
	int ctxn, ret;
	int ctxn, ret;


	memset(child->perf_event_ctxp, 0, sizeof(child->perf_event_ctxp));
	mutex_init(&child->perf_event_mutex);
	INIT_LIST_HEAD(&child->perf_event_list);

	for_each_task_context_nr(ctxn) {
	for_each_task_context_nr(ctxn) {
		ret = perf_event_init_context(child, ctxn);
		ret = perf_event_init_context(child, ctxn);
		if (ret)
		if (ret)
+7 −2
Original line number Original line Diff line number Diff line
@@ -204,13 +204,11 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
@@ -294,6 +292,13 @@ ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y)
	CFLAGS := $(CFLAGS) -fstack-protector-all
	CFLAGS := $(CFLAGS) -fstack-protector-all
endif
endif


ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wstack-protector),y)
       CFLAGS := $(CFLAGS) -Wstack-protector
endif

ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wvolatile-register-var),y)
       CFLAGS := $(CFLAGS) -Wvolatile-register-var
endif


### --- END CONFIGURATION SECTION ---
### --- END CONFIGURATION SECTION ---


+3 −3
Original line number Original line Diff line number Diff line
@@ -212,7 +212,7 @@ get_source_line(struct hist_entry *he, int len, const char *filename)
			continue;
			continue;


		offset = start + i;
		offset = start + i;
		sprintf(cmd, "addr2line -e %s %016llx", filename, offset);
		sprintf(cmd, "addr2line -e %s %016" PRIx64, filename, offset);
		fp = popen(cmd, "r");
		fp = popen(cmd, "r");
		if (!fp)
		if (!fp)
			continue;
			continue;
@@ -270,9 +270,9 @@ static void hist_entry__print_hits(struct hist_entry *self)


	for (offset = 0; offset < len; ++offset)
	for (offset = 0; offset < len; ++offset)
		if (h->ip[offset] != 0)
		if (h->ip[offset] != 0)
			printf("%*Lx: %Lu\n", BITS_PER_LONG / 2,
			printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2,
			       sym->start + offset, h->ip[offset]);
			       sym->start + offset, h->ip[offset]);
	printf("%*s: %Lu\n", BITS_PER_LONG / 2, "h->sum", h->sum);
	printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum);
}
}


static int hist_entry__tty_annotate(struct hist_entry *he)
static int hist_entry__tty_annotate(struct hist_entry *he)
+2 −2
Original line number Original line Diff line number Diff line
@@ -371,10 +371,10 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
			addr = data->ptr;
			addr = data->ptr;


		if (sym != NULL)
		if (sym != NULL)
			snprintf(buf, sizeof(buf), "%s+%Lx", sym->name,
			snprintf(buf, sizeof(buf), "%s+%" PRIx64 "", sym->name,
				 addr - map->unmap_ip(map, sym->start));
				 addr - map->unmap_ip(map, sym->start));
		else
		else
			snprintf(buf, sizeof(buf), "%#Lx", addr);
			snprintf(buf, sizeof(buf), "%#" PRIx64 "", addr);
		printf(" %-34s |", buf);
		printf(" %-34s |", buf);


		printf(" %9llu/%-5lu | %9llu/%-5lu | %8lu | %8lu | %6.3f%%\n",
		printf(" %9llu/%-5lu | %9llu/%-5lu | %8lu | %8lu | %6.3f%%\n",
Loading