Skip to content

Commit f5eb558

Browse files
Steven Rostedt (Red Hat)rostedt
authored andcommitted
ring-buffer: Do not use schedule_work_on() for current CPU
The ring buffer updates when done while the ring buffer is active, needs to be completed on the CPU that is used for the ring buffer per_cpu buffer. To accomplish this, schedule_work_on() is used to schedule work on the given CPU. Now there's no reason to use schedule_work_on() if the process doing the update happens to be on the CPU that it is processing. It has already filled the requirement. Instead, just do the work and continue. This is needed for tracing_snapshot_alloc() where it may be called really early in boot, where the work queues have not been set up yet. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent ad909e2 commit f5eb558

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

‎kernel/trace/ring_buffer.c‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,11 +1679,22 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
16791679
if (!cpu_buffer->nr_pages_to_update)
16801680
continue;
16811681

1682-
if (cpu_online(cpu))
1682+
/* The update must run on the CPU that is being updated. */
1683+
preempt_disable();
1684+
if (cpu == smp_processor_id() || !cpu_online(cpu)) {
1685+
rb_update_pages(cpu_buffer);
1686+
cpu_buffer->nr_pages_to_update = 0;
1687+
} else {
1688+
/*
1689+
* Can not disable preemption for schedule_work_on()
1690+
* on PREEMPT_RT.
1691+
*/
1692+
preempt_enable();
16831693
schedule_work_on(cpu,
16841694
&cpu_buffer->update_pages_work);
1685-
else
1686-
rb_update_pages(cpu_buffer);
1695+
preempt_disable();
1696+
}
1697+
preempt_enable();
16871698
}
16881699

16891700
/* wait for all the updates to complete */
@@ -1721,12 +1732,22 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
17211732

17221733
get_online_cpus();
17231734

1724-
if (cpu_online(cpu_id)) {
1735+
preempt_disable();
1736+
/* The update must run on the CPU that is being updated. */
1737+
if (cpu_id == smp_processor_id() || !cpu_online(cpu_id))
1738+
rb_update_pages(cpu_buffer);
1739+
else {
1740+
/*
1741+
* Can not disable preemption for schedule_work_on()
1742+
* on PREEMPT_RT.
1743+
*/
1744+
preempt_enable();
17251745
schedule_work_on(cpu_id,
17261746
&cpu_buffer->update_pages_work);
17271747
wait_for_completion(&cpu_buffer->update_done);
1728-
} else
1729-
rb_update_pages(cpu_buffer);
1748+
preempt_disable();
1749+
}
1750+
preempt_enable();
17301751

17311752
cpu_buffer->nr_pages_to_update = 0;
17321753
put_online_cpus();

0 commit comments

Comments
 (0)