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

Commit 78f13e95 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

perf_counter: allow for data addresses to be recorded



Paul suggested we allow for data addresses to be recorded along with
the traditional IPs as power can provide these.

For now, only the software pagefault events provide data addresses,
but in the future power might as well for some events.

x86 doesn't seem capable of providing this atm.

Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090408130409.394816925@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 4d855457
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -749,7 +749,7 @@ static void record_and_restart(struct perf_counter *counter, long val,
	 * Finally record data if requested.
	 */
	if (record)
		perf_counter_overflow(counter, 1, regs);
		perf_counter_overflow(counter, 1, regs, 0);
}

/*
+5 −3
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
		die("Weird page fault", regs, SIGSEGV);
	}

	perf_swcounter_event(PERF_COUNT_PAGE_FAULTS, 1, 0, regs);
	perf_swcounter_event(PERF_COUNT_PAGE_FAULTS, 1, 0, regs, address);

	/* When running in the kernel we expect faults to occur only to
	 * addresses in user space.  All other faults represent errors in the
@@ -312,7 +312,8 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
	}
	if (ret & VM_FAULT_MAJOR) {
		current->maj_flt++;
		perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MAJ, 1, 0, regs);
		perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MAJ, 1, 0,
				     regs, address);
#ifdef CONFIG_PPC_SMLPAR
		if (firmware_has_feature(FW_FEATURE_CMO)) {
			preempt_disable();
@@ -322,7 +323,8 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
#endif
	} else {
		current->min_flt++;
		perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MIN, 1, 0, regs);
		perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MIN, 1, 0,
				     regs, address);
	}
	up_read(&mm->mmap_sem);
	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -800,7 +800,7 @@ static int __smp_perf_counter_interrupt(struct pt_regs *regs, int nmi)
			continue;

		perf_save_and_restart(counter);
		if (perf_counter_overflow(counter, nmi, regs))
		if (perf_counter_overflow(counter, nmi, regs, 0))
			__pmc_generic_disable(counter, &counter->hw, bit);
	}

+5 −3
Original line number Diff line number Diff line
@@ -1045,7 +1045,7 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
	if (unlikely(error_code & PF_RSVD))
		pgtable_bad(regs, error_code, address);

	perf_swcounter_event(PERF_COUNT_PAGE_FAULTS, 1, 0, regs);
	perf_swcounter_event(PERF_COUNT_PAGE_FAULTS, 1, 0, regs, address);

	/*
	 * If we're in an interrupt, have no user context or are running
@@ -1142,10 +1142,12 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)

	if (fault & VM_FAULT_MAJOR) {
		tsk->maj_flt++;
		perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MAJ, 1, 0, regs);
		perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MAJ, 1, 0,
				     regs, address);
	} else {
		tsk->min_flt++;
		perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MIN, 1, 0, regs);
		perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MIN, 1, 0,
				     regs, address);
	}

	check_v8086_mode(regs, address, tsk);
+8 −6
Original line number Diff line number Diff line
@@ -101,8 +101,9 @@ enum perf_counter_record_format {
	PERF_RECORD_IP		= 1U << 0,
	PERF_RECORD_TID		= 1U << 1,
	PERF_RECORD_TIME	= 1U << 2,
	PERF_RECORD_GROUP	= 1U << 3,
	PERF_RECORD_CALLCHAIN	= 1U << 4,
	PERF_RECORD_ADDR	= 1U << 3,
	PERF_RECORD_GROUP	= 1U << 4,
	PERF_RECORD_CALLCHAIN	= 1U << 5,
};

/*
@@ -251,6 +252,7 @@ enum perf_event_type {
	 * 	{ u64			ip;	  } && PERF_RECORD_IP
	 * 	{ u32			pid, tid; } && PERF_RECORD_TID
	 * 	{ u64			time;     } && PERF_RECORD_TIME
	 * 	{ u64			addr;     } && PERF_RECORD_ADDR
	 *
	 * 	{ u64			nr;
	 * 	  { u64 event, val; } 	cnt[nr];  } && PERF_RECORD_GROUP
@@ -537,7 +539,7 @@ extern int hw_perf_group_sched_in(struct perf_counter *group_leader,
extern void perf_counter_update_userpage(struct perf_counter *counter);

extern int perf_counter_overflow(struct perf_counter *counter,
				 int nmi, struct pt_regs *regs);
				 int nmi, struct pt_regs *regs, u64 addr);
/*
 * Return 1 for a software counter, 0 for a hardware counter
 */
@@ -547,7 +549,7 @@ static inline int is_software_counter(struct perf_counter *counter)
		perf_event_type(&counter->hw_event) != PERF_TYPE_HARDWARE;
}

extern void perf_swcounter_event(u32, u64, int, struct pt_regs *);
extern void perf_swcounter_event(u32, u64, int, struct pt_regs *, u64);

extern void perf_counter_mmap(unsigned long addr, unsigned long len,
			      unsigned long pgoff, struct file *file);
@@ -584,8 +586,8 @@ static inline int perf_counter_task_disable(void) { return -EINVAL; }
static inline int perf_counter_task_enable(void)	{ return -EINVAL; }

static inline void
perf_swcounter_event(u32 event, u64 nr, int nmi, struct pt_regs *regs)	{ }

perf_swcounter_event(u32 event, u64 nr, int nmi,
		     struct pt_regs *regs, u64 addr)			{ }

static inline void
perf_counter_mmap(unsigned long addr, unsigned long len,
Loading