mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
tracing: Reuse logic from perf's get_recursion_context()
Instead of having branches that adds noise to the branch prediction, use the addition logic to set the bit for the level of interrupt context that the state is currently in. This copies the logic from perf's get_recursion_context() function. Link: https://lore.kernel.org/all/20211015161702.GF174703@worktop.programming.kicks-ass.net/ Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
7ce1bb83a1
commit
9b84fadc44
2 changed files with 12 additions and 11 deletions
|
@ -137,12 +137,13 @@ enum {
|
|||
static __always_inline int trace_get_context_bit(void)
|
||||
{
|
||||
unsigned long pc = preempt_count();
|
||||
unsigned char bit = 0;
|
||||
|
||||
if (!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)))
|
||||
return TRACE_CTX_NORMAL;
|
||||
else
|
||||
return pc & NMI_MASK ? TRACE_CTX_NMI :
|
||||
pc & HARDIRQ_MASK ? TRACE_CTX_IRQ : TRACE_CTX_SOFTIRQ;
|
||||
bit += !!(pc & (NMI_MASK));
|
||||
bit += !!(pc & (NMI_MASK | HARDIRQ_MASK));
|
||||
bit += !!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET));
|
||||
|
||||
return TRACE_CTX_NORMAL - bit;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FTRACE_RECORD_RECURSION
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue