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

Commit 560ae371 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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

Pull perf fixes from Thomas Gleixner:
 - fix for do_div() abuse on x86
 - locking fix in perf core
 - a pile of (build) fixes and cleanups in perf tools

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (27 commits)
  perf/x86: Fix incorrect use of do_div() in NMI warning
  perf: Fix perf_lock_task_context() vs RCU
  perf: Remove WARN_ON_ONCE() check in __perf_event_enable() for valid scenario
  perf: Clone child context from parent context pmu
  perf script: Fix broken include in Context.xs
  perf tools: Fix -ldw/-lelf link test when static linking
  perf tools: Revert regression in configuration of Python support
  perf tools: Fix perf version generation
  perf stat: Fix per-socket output bug for uncore events
  perf symbols: Fix vdso list searching
  perf evsel: Fix missing increment in sample parsing
  perf tools: Update symbol_conf.nr_events when processing attribute events
  perf tools: Fix new_term() missing free on error path
  perf tools: Fix parse_events_terms() segfault on error path
  perf evsel: Fix count parameter to read call in event_format__new
  perf tools: fix a typo of a Power7 event name
  perf tools: Fix -x/--exclude-other option for report command
  perf evlist: Enhance perf_evlist__start_workload()
  perf record: Remove -f/--force option
  perf record: Remove -A/--append option
  ...
parents 4fa109b1 baf64b85
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ Description: Generic performance monitoring events

What: 		/sys/devices/cpu/events/PM_1PLUS_PPC_CMPL
		/sys/devices/cpu/events/PM_BRU_FIN
		/sys/devices/cpu/events/PM_BRU_MPRED
		/sys/devices/cpu/events/PM_BR_MPRED
		/sys/devices/cpu/events/PM_CMPLU_STALL
		/sys/devices/cpu/events/PM_CMPLU_STALL_BRU
		/sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS
+6 −6
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@
#define	PME_PM_LD_REF_L1		0xc880
#define	PME_PM_LD_MISS_L1		0x400f0
#define	PME_PM_BRU_FIN			0x10068
#define	PME_PM_BRU_MPRED		0x400f6
#define	PME_PM_BR_MPRED			0x400f6

#define PME_PM_CMPLU_STALL_FXU			0x20014
#define PME_PM_CMPLU_STALL_DIV			0x40014
@@ -349,7 +349,7 @@ static int power7_generic_events[] = {
	[PERF_COUNT_HW_CACHE_REFERENCES] =		PME_PM_LD_REF_L1,
	[PERF_COUNT_HW_CACHE_MISSES] =			PME_PM_LD_MISS_L1,
	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] =		PME_PM_BRU_FIN,
	[PERF_COUNT_HW_BRANCH_MISSES] =			PME_PM_BRU_MPRED,
	[PERF_COUNT_HW_BRANCH_MISSES] =			PME_PM_BR_MPRED,
};

#define C(x)	PERF_COUNT_HW_CACHE_##x
@@ -405,7 +405,7 @@ GENERIC_EVENT_ATTR(instructions, INST_CMPL);
GENERIC_EVENT_ATTR(cache-references,		LD_REF_L1);
GENERIC_EVENT_ATTR(cache-misses,		LD_MISS_L1);
GENERIC_EVENT_ATTR(branch-instructions,		BRU_FIN);
GENERIC_EVENT_ATTR(branch-misses,		BRU_MPRED);
GENERIC_EVENT_ATTR(branch-misses,		BR_MPRED);

POWER_EVENT_ATTR(CYC,				CYC);
POWER_EVENT_ATTR(GCT_NOSLOT_CYC,		GCT_NOSLOT_CYC);
@@ -414,7 +414,7 @@ POWER_EVENT_ATTR(INST_CMPL, INST_CMPL);
POWER_EVENT_ATTR(LD_REF_L1,			LD_REF_L1);
POWER_EVENT_ATTR(LD_MISS_L1,			LD_MISS_L1);
POWER_EVENT_ATTR(BRU_FIN,			BRU_FIN)
POWER_EVENT_ATTR(BRU_MPRED,			BRU_MPRED);
POWER_EVENT_ATTR(BR_MPRED,			BR_MPRED);

POWER_EVENT_ATTR(CMPLU_STALL_FXU,		CMPLU_STALL_FXU);
POWER_EVENT_ATTR(CMPLU_STALL_DIV,		CMPLU_STALL_DIV);
@@ -449,7 +449,7 @@ static struct attribute *power7_events_attr[] = {
	GENERIC_EVENT_PTR(LD_REF_L1),
	GENERIC_EVENT_PTR(LD_MISS_L1),
	GENERIC_EVENT_PTR(BRU_FIN),
	GENERIC_EVENT_PTR(BRU_MPRED),
	GENERIC_EVENT_PTR(BR_MPRED),

	POWER_EVENT_PTR(CYC),
	POWER_EVENT_PTR(GCT_NOSLOT_CYC),
@@ -458,7 +458,7 @@ static struct attribute *power7_events_attr[] = {
	POWER_EVENT_PTR(LD_REF_L1),
	POWER_EVENT_PTR(LD_MISS_L1),
	POWER_EVENT_PTR(BRU_FIN),
	POWER_EVENT_PTR(BRU_MPRED),
	POWER_EVENT_PTR(BR_MPRED),

	POWER_EVENT_PTR(CMPLU_STALL_FXU),
	POWER_EVENT_PTR(CMPLU_STALL_DIV),
+4 −3
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
	 */
	list_for_each_entry_rcu(a, &desc->head, list) {
		u64 before, delta, whole_msecs;
		int decimal_msecs, thishandled;
		int remainder_ns, decimal_msecs, thishandled;

		before = local_clock();
		thishandled = a->handler(type, regs);
@@ -123,8 +123,9 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
			continue;

		nmi_longest_ns = delta;
		whole_msecs = do_div(delta, (1000 * 1000));
		decimal_msecs = do_div(delta, 1000) % 1000;
		whole_msecs = delta;
		remainder_ns = do_div(whole_msecs, (1000 * 1000));
		decimal_msecs = remainder_ns / 1000;
		printk_ratelimited(KERN_INFO
			"INFO: NMI handler (%ps) took too long to run: "
			"%lld.%03d msecs\n", a->handler, whole_msecs,
+25 −3
Original line number Diff line number Diff line
@@ -947,8 +947,18 @@ perf_lock_task_context(struct task_struct *task, int ctxn, unsigned long *flags)
{
	struct perf_event_context *ctx;

	rcu_read_lock();
retry:
	/*
	 * One of the few rules of preemptible RCU is that one cannot do
	 * rcu_read_unlock() while holding a scheduler (or nested) lock when
	 * part of the read side critical section was preemptible -- see
	 * rcu_read_unlock_special().
	 *
	 * Since ctx->lock nests under rq->lock we must ensure the entire read
	 * side critical section is non-preemptible.
	 */
	preempt_disable();
	rcu_read_lock();
	ctx = rcu_dereference(task->perf_event_ctxp[ctxn]);
	if (ctx) {
		/*
@@ -964,6 +974,8 @@ perf_lock_task_context(struct task_struct *task, int ctxn, unsigned long *flags)
		raw_spin_lock_irqsave(&ctx->lock, *flags);
		if (ctx != rcu_dereference(task->perf_event_ctxp[ctxn])) {
			raw_spin_unlock_irqrestore(&ctx->lock, *flags);
			rcu_read_unlock();
			preempt_enable();
			goto retry;
		}

@@ -973,6 +985,7 @@ perf_lock_task_context(struct task_struct *task, int ctxn, unsigned long *flags)
		}
	}
	rcu_read_unlock();
	preempt_enable();
	return ctx;
}

@@ -1950,7 +1963,16 @@ static int __perf_event_enable(void *info)
	struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
	int err;

	if (WARN_ON_ONCE(!ctx->is_active))
	/*
	 * There's a time window between 'ctx->is_active' check
	 * in perf_event_enable function and this place having:
	 *   - IRQs on
	 *   - ctx->lock unlocked
	 *
	 * where the task could be killed and 'ctx' deactivated
	 * by perf_event_exit_task.
	 */
	if (!ctx->is_active)
		return -EINVAL;

	raw_spin_lock(&ctx->lock);
@@ -7465,7 +7487,7 @@ inherit_task_group(struct perf_event *event, struct task_struct *parent,
		 * child.
		 */

		child_ctx = alloc_perf_context(event->pmu, child);
		child_ctx = alloc_perf_context(parent_ctx->pmu, child);
		if (!child_ctx)
			return -ENOMEM;

+16 −1
Original line number Diff line number Diff line
@@ -3,6 +3,21 @@ include ../../scripts/Makefile.include
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar

# Makefiles suck: This macro sets a default value of $(2) for the
# variable named by $(1), unless the variable has been set by
# environment or command line. This is necessary for CC and AR
# because make sets default values, so the simpler ?= approach
# won't work as expected.
define allow-override
  $(if $(or $(findstring environment,$(origin $(1))),\
            $(findstring command line,$(origin $(1)))),,\
    $(eval $(1) = $(2)))
endef

# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
$(call allow-override,CC,$(CROSS_COMPILE)gcc)
$(call allow-override,AR,$(CROSS_COMPILE)ar)

# guard against environment variables
LIB_H=
LIB_OBJS=
@@ -14,7 +29,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
LIBFILE = liblk.a

CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
EXTLIBS = -lpthread -lrt -lelf -lm
EXTLIBS = -lelf -lpthread -lrt -lm
ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
ALL_LDFLAGS = $(LDFLAGS)

Loading