linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace: Simplify ring buffer resizing, make work with RT
@ 2014-05-08 20:03 minyard
  2014-05-09 13:12 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: minyard @ 2014-05-08 20:03 UTC (permalink / raw)
  To: linux-rt-users, linux-kernel; +Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

ring_buffer_resize() would call rb_update_pages() with preempt
disabled.  It did this with preempt disabled, bu rb_update_pages
would eventually claim the zone semaphore, which is a mutex in PREEMPT_RT,
thus resulting in a "scheduling while atomic" BUG.

When doing this, all other CPUs except the running one did the operation
in a work queue.  So just do the current CPU operation in a work queue,
too.  This simplifies the code, gets rid of the need for preempt_disable(),
and solves the RT issue.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 kernel/trace/ring_buffer.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

This isn't well tested, but fixes an obvious PREEMPT_RT problem and seems
like a good simplification.  You can see the PREEMPT_RT bug if you enable
ftrace and all the self tests; it will fail running selftests when it tries
to resize the buffers.

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index fc4da2d..972125e 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1688,21 +1688,13 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
 				continue;
 
 			/* The update must run on the CPU that is being updated. */
-			preempt_disable();
-			if (cpu == smp_processor_id() || !cpu_online(cpu)) {
+			if (!cpu_online(cpu)) {
 				rb_update_pages(cpu_buffer);
 				cpu_buffer->nr_pages_to_update = 0;
 			} else {
-				/*
-				 * Can not disable preemption for schedule_work_on()
-				 * on PREEMPT_RT.
-				 */
-				preempt_enable();
 				schedule_work_on(cpu,
 						&cpu_buffer->update_pages_work);
-				preempt_disable();
 			}
-			preempt_enable();
 		}
 
 		/* wait for all the updates to complete */
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ftrace: Simplify ring buffer resizing, make work with RT
  2014-05-08 20:03 [PATCH] ftrace: Simplify ring buffer resizing, make work with RT minyard
@ 2014-05-09 13:12 ` Sebastian Andrzej Siewior
  2014-05-09 17:08   ` Corey Minyard
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-05-09 13:12 UTC (permalink / raw)
  To: minyard; +Cc: linux-rt-users, linux-kernel, Corey Minyard

* minyard@acm.org | 2014-05-08 15:03:22 [-0500]:

>This isn't well tested, but fixes an obvious PREEMPT_RT problem and seems
>like a good simplification.  You can see the PREEMPT_RT bug if you enable
>ftrace and all the self tests; it will fail running selftests when it tries
>to resize the buffers.

I posted http://marc.info/?l=linux-rt-users&m=139962823022896&w=2 before
I noticed this one. You seem not to touch the second hunk.

Sebastian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ftrace: Simplify ring buffer resizing, make work with RT
  2014-05-09 13:12 ` Sebastian Andrzej Siewior
@ 2014-05-09 17:08   ` Corey Minyard
  0 siblings, 0 replies; 3+ messages in thread
From: Corey Minyard @ 2014-05-09 17:08 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, minyard; +Cc: linux-rt-users, linux-kernel

On 05/09/2014 08:12 AM, Sebastian Andrzej Siewior wrote:
> * minyard@acm.org | 2014-05-08 15:03:22 [-0500]:
>
>> This isn't well tested, but fixes an obvious PREEMPT_RT problem and seems
>> like a good simplification.  You can see the PREEMPT_RT bug if you enable
>> ftrace and all the self tests; it will fail running selftests when it tries
>> to resize the buffers.
> I posted http://marc.info/?l=linux-rt-users&m=139962823022896&w=2 before
> I noticed this one. You seem not to touch the second hunk.
>
> Sebastian
That's a good solution, too.  I didn't notice the second hunk in my testing.

Thanks,

-corey

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-09 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-08 20:03 [PATCH] ftrace: Simplify ring buffer resizing, make work with RT minyard
2014-05-09 13:12 ` Sebastian Andrzej Siewior
2014-05-09 17:08   ` Corey Minyard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).