Commit 31679f38 authored by Andi Kleen's avatar Andi Kleen Committed by Andi Kleen

[PATCH] Simplify profile_pc on x86-64

Use knowledge about EFLAGS layout (bits 22:63 are always 0) to distingush
EFLAGS word and kernel address in the spin lock stack frame.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
parent 0cb91a22
...@@ -189,20 +189,15 @@ unsigned long profile_pc(struct pt_regs *regs) ...@@ -189,20 +189,15 @@ unsigned long profile_pc(struct pt_regs *regs)
{ {
unsigned long pc = instruction_pointer(regs); unsigned long pc = instruction_pointer(regs);
/* Assume the lock function has either no stack frame or only a single /* Assume the lock function has either no stack frame or a copy
word. This checks if the address on the stack looks like a kernel of eflags from PUSHF
text address. Eflags always has bits 22 and up cleared unlike kernel addresses. */
There is a small window for false hits, but in that case the tick
is just accounted to the spinlock function.
Better would be to write these functions in assembler again
and check exactly. */
if (!user_mode(regs) && in_lock_functions(pc)) { if (!user_mode(regs) && in_lock_functions(pc)) {
char *v = *(char **)regs->rsp; unsigned long *sp = (unsigned long *)regs->rsp;
if ((v >= _stext && v <= _etext) || if (sp[0] >> 22)
(v >= _sinittext && v <= _einittext) || return sp[0];
(v >= (char *)MODULES_VADDR && v <= (char *)MODULES_END)) if (sp[1] >> 22)
return (unsigned long)v; return sp[1];
return ((unsigned long *)regs->rsp)[1];
} }
return pc; return pc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment