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

Commit 94ac003b authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge tag 'perf-core-for-mingo' of...

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

 into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

User visible changes:

  - Warn if given uprobe event accesses memory on older kernel (Masami Hiramatsu)

  - 'perf record' Documentation fixes (Namhyung Kim)

  - Report unsupported events properly in 'perf stat' (Suzuki K. Poulose)

Infrastructure changes:

  - Avoid FORK after COMM when synthesizing records for pre-existing threads (Arnaldo Carvalho de Melo)

  - Reference count struct thread (Arnaldo Carvalho de Melo)

  - Don't keep the session around in 'perf sched', thread refcounting removes that need (Arnaldo Carvalho de Melo)

  - Initialize cpu set in pthread_attr_setaffinity_np() feature test (Adrian Hunter)

  - Only include tsc file for x86 (David Ahern)

  - Compare JOBS to 0 after grep (David Ahern)

  - Improve feature detection messages (Ingo Molnar)

  - Revert "perf: Remove the extra validity check on nr_pages" (Kan Liang)

  - Remove bias offset to find probe point by address (Masami Hiramatsu)

  - Fix build error on ARCH=i386/x86_64/sparc64 (Namhyung Kim)

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 788b94ba ae536acf
Loading
Loading
Loading
Loading
+40 −14
Original line number Diff line number Diff line
@@ -223,10 +223,22 @@ static unsigned long
__recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
{
	struct kprobe *kp;
	unsigned long faddr;

	kp = get_kprobe((void *)addr);
	/* There is no probe, return original address */
	if (!kp)
	faddr = ftrace_location(addr);
	/*
	 * Addresses inside the ftrace location are refused by
	 * arch_check_ftrace_location(). Something went terribly wrong
	 * if such an address is checked here.
	 */
	if (WARN_ON(faddr && faddr != addr))
		return 0UL;
	/*
	 * Use the current code if it is not modified by Kprobe
	 * and it cannot be modified by ftrace.
	 */
	if (!kp && !faddr)
		return addr;

	/*
@@ -236,13 +248,22 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
	 * that instruction. In that case, we can't recover the instruction
	 * from the kp->ainsn.insn.
	 *
	 *  On the other hand, kp->opcode has a copy of the first byte of
	 *  the probed instruction, which is overwritten by int3. And
	 *  the instruction at kp->addr is not modified by kprobes except
	 *  for the first byte, we can recover the original instruction
	 * On the other hand, in case on normal Kprobe, kp->opcode has a copy
	 * of the first byte of the probed instruction, which is overwritten
	 * by int3. And the instruction at kp->addr is not modified by kprobes
	 * except for the first byte, we can recover the original instruction
	 * from it and kp->opcode.
	 *
	 * In case of Kprobes using ftrace, we do not have a copy of
	 * the original instruction. In fact, the ftrace location might
	 * be modified at anytime and even could be in an inconsistent state.
	 * Fortunately, we know that the original code is the ideal 5-byte
	 * long NOP.
	 */
	memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
	memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
	if (faddr)
		memcpy(buf, ideal_nops[NOP_ATOMIC5], 5);
	else
		buf[0] = kp->opcode;
	return (unsigned long)buf;
}
@@ -251,6 +272,7 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
 * Recover the probed instruction at addr for further analysis.
 * Caller must lock kprobes by kprobe_mutex, or disable preemption
 * for preventing to release referencing kprobes.
 * Returns zero if the instruction can not get recovered.
 */
unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
{
@@ -285,6 +307,8 @@ static int can_probe(unsigned long paddr)
		 * normally used, we just go through if there is no kprobe.
		 */
		__addr = recover_probed_instruction(buf, addr);
		if (!__addr)
			return 0;
		kernel_insn_init(&insn, (void *)__addr, MAX_INSN_SIZE);
		insn_get_length(&insn);

@@ -333,6 +357,8 @@ int __copy_instruction(u8 *dest, u8 *src)
	unsigned long recovered_insn =
		recover_probed_instruction(buf, (unsigned long)src);

	if (!recovered_insn)
		return 0;
	kernel_insn_init(&insn, (void *)recovered_insn, MAX_INSN_SIZE);
	insn_get_length(&insn);
	/* Another subsystem puts a breakpoint, failed to recover */
+2 −0
Original line number Diff line number Diff line
@@ -259,6 +259,8 @@ static int can_optimize(unsigned long paddr)
			 */
			return 0;
		recovered_insn = recover_probed_instruction(buf, addr);
		if (!recovered_insn)
			return 0;
		kernel_insn_init(&insn, (void *)recovered_insn, MAX_INSN_SIZE);
		insn_get_length(&insn);
		/* Another subsystem puts a breakpoint */
+1 −1
Original line number Diff line number Diff line
@@ -4446,7 +4446,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
	 * If we have rb pages ensure they're a power-of-two number, so we
	 * can do bitmasks instead of modulo.
	 */
	if (!is_power_of_2(nr_pages))
	if (nr_pages != 0 && !is_power_of_2(nr_pages))
		return -EINVAL;

	if (vma_size != PAGE_SIZE * (1 + nr_pages))
+1 −0
Original line number Diff line number Diff line
PERF-CFLAGS
PERF-GUI-VARS
PERF-VERSION-FILE
PERF-FEATURES
perf
perf-read-vdso32
perf-read-vdsox32
+9 −3
Original line number Diff line number Diff line
@@ -55,6 +55,11 @@ OPTIONS
          If you want to profile write accesses in [0x1000~1008), just set
          'mem:0x1000/8:w'.

	- a group of events surrounded by a pair of brace ("{event1,event2,...}").
	  Each event is separated by commas and the group should be quoted to
	  prevent the shell interpretation.  You also need to use --group on
	  "perf report" to view group events together.

--filter=<filter>::
        Event filter.

@@ -62,9 +67,6 @@ OPTIONS
--all-cpus::
        System-wide collection from all CPUs.

-l::
        Scale counter values.

-p::
--pid=::
	Record events on existing process ID (comma separated list).
@@ -107,6 +109,10 @@ OPTIONS
	specification with appended unit character - B/K/M/G. The
	size is rounded up to have nearest pages power of two value.

--group::
	Put all events in a single event group.  This precedes the --event
	option and remains only for backward compatibility.  See --event.

-g::
	Enables call-graph (stack chain/backtrace) recording.

Loading