Unverified Commit dc3c1ebc authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!8237 x86: profiling: Using generic unwinding in profile_pc

parents af08693e 3121bb17
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -24,26 +24,18 @@
#include <asm/timer.h>
#include <asm/hpet.h>
#include <asm/time.h>
#include <asm/unwind.h>

unsigned long profile_pc(struct pt_regs *regs)
{
	unsigned long pc = instruction_pointer(regs);

	if (!user_mode(regs) && in_lock_functions(pc)) {
#ifdef CONFIG_FRAME_POINTER
		return *(unsigned long *)(regs->bp + sizeof(long));
#else
		unsigned long *sp = (unsigned long *)regs->sp;
		/*
		 * Return address is either directly at stack pointer
		 * or above a saved flags. Eflags has bits 22-31 zero,
		 * kernel addresses don't.
		 */
		if (sp[0] >> 22)
			return sp[0];
		if (sp[1] >> 22)
			return sp[1];
#endif
		struct unwind_state state;

		/* unwind_start will skip the first regs frame */
		unwind_start(&state, current, regs, NULL);
		pc = unwind_get_return_address(&state);
	}
	return pc;
}