Skip to content

Commit aa5ff93

Browse files
committed
Merge tag 'trace-v5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Two tracing fixes: - Fix temp buffer accounting that caused a WARNING for ftrace_dump_on_opps() - Move the recursion check in one of the function callback helpers to the beginning of the function, as if the rcu_is_watching() gets traced, it will cause a recursive loop that will crash the kernel" * tag 'trace-v5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: ftrace: Move RCU is watching check after recursion check tracing: Fix trace_find_next_entry() accounting of temp buffer size
2 parents 60e7209 + b40341f commit aa5ff93

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

kernel/trace/ftrace.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6993,16 +6993,14 @@ static void ftrace_ops_assist_func(unsigned long ip, unsigned long parent_ip,
69936993
{
69946994
int bit;
69956995

6996-
if ((op->flags & FTRACE_OPS_FL_RCU) && !rcu_is_watching())
6997-
return;
6998-
69996996
bit = trace_test_and_set_recursion(TRACE_LIST_START, TRACE_LIST_MAX);
70006997
if (bit < 0)
70016998
return;
70026999

70037000
preempt_disable_notrace();
70047001

7005-
op->func(ip, parent_ip, op, regs);
7002+
if (!(op->flags & FTRACE_OPS_FL_RCU) || rcu_is_watching())
7003+
op->func(ip, parent_ip, op, regs);
70067004

70077005
preempt_enable_notrace();
70087006
trace_clear_recursion(bit);

kernel/trace/trace.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3546,13 +3546,15 @@ struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
35463546
if (iter->ent && iter->ent != iter->temp) {
35473547
if ((!iter->temp || iter->temp_size < iter->ent_size) &&
35483548
!WARN_ON_ONCE(iter->temp == static_temp_buf)) {
3549-
kfree(iter->temp);
3550-
iter->temp = kmalloc(iter->ent_size, GFP_KERNEL);
3551-
if (!iter->temp)
3549+
void *temp;
3550+
temp = kmalloc(iter->ent_size, GFP_KERNEL);
3551+
if (!temp)
35523552
return NULL;
3553+
kfree(iter->temp);
3554+
iter->temp = temp;
3555+
iter->temp_size = iter->ent_size;
35533556
}
35543557
memcpy(iter->temp, iter->ent, iter->ent_size);
3555-
iter->temp_size = iter->ent_size;
35563558
iter->ent = iter->temp;
35573559
}
35583560
entry = __find_next_entry(iter, ent_cpu, NULL, ent_ts);

0 commit comments

Comments
 (0)