All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH-rt 1/1] softirqs: add preempt_check_resched() in ksoftirqd()
@ 2009-11-11  4:35 Jupyung Lee
  2009-11-11  7:21 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Jupyung Lee @ 2009-11-11  4:35 UTC (permalink / raw)
  To: LKML; +Cc: Thomas Gleixner, Jupyung Lee

In its current preempt-rt kernel, ksoftirq() includes a series of primitives
related with kernel preemption and irq on/off, in the following order:

preempt_disable()		... (1)
local_irq_disable()		... (2)
__preempt_enable_no_resched()	... (3)
local_irq_enable()		... (4)

A problem arises if a process is awakened between (1) and (2) because
it is not given a chance to preempt the currently running process
for a while since (4): since (4), the kernel is preemptible, but there
is no explicit reschedule point.

A simple suggestion to resolve the problem is to add a reschedule point,
preempt_check_resched(), just after (4).

Signed-off-by: Jupyung Lee <jupyung@gmail.com>
---
 kernel/softirq.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 590049c..7c1b041 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -1037,6 +1037,7 @@ sleep_more:
 			set_softirq_pending(local_softirq_pending() & ~softirq_mask);
 			local_bh_disable();
 			local_irq_enable();
+			preempt_check_resched();
 
 			h = &softirq_vec[data->nr];
 			if (h)
-- 
1.5.4.3


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

* Re: [PATCH-rt 1/1] softirqs: add preempt_check_resched() in ksoftirqd()
  2009-11-11  4:35 [PATCH-rt 1/1] softirqs: add preempt_check_resched() in ksoftirqd() Jupyung Lee
@ 2009-11-11  7:21 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2009-11-11  7:21 UTC (permalink / raw)
  To: Jupyung Lee; +Cc: LKML

Jupyung,

On Wed, 11 Nov 2009, Jupyung Lee wrote:

> In its current preempt-rt kernel, ksoftirq() includes a series of primitives
> related with kernel preemption and irq on/off, in the following order:
> 
> preempt_disable()		... (1)
> local_irq_disable()		... (2)
> __preempt_enable_no_resched()	... (3)
> local_irq_enable()		... (4)
> 
> A problem arises if a process is awakened between (1) and (2) because
> it is not given a chance to preempt the currently running process
> for a while since (4): since (4), the kernel is preemptible, but there
> is no explicit reschedule point.
> 
> A simple suggestion to resolve the problem is to add a reschedule point,
> preempt_check_resched(), just after (4).

Good catch. I applied it with a simple modification.

Thanks,

	tglx
---
commit ca0b4bfa5994856bbcf4227e29f9c73722efaef2
Author: Jupyung Lee <jupyung@gmail.com>

<snip>

--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -1033,10 +1033,10 @@ sleep_more:
 				goto sleep_more;
 			}
 			per_cpu(softirq_running, cpu) |= softirq_mask;
-			__preempt_enable_no_resched();
 			set_softirq_pending(local_softirq_pending() & ~softirq_mask);
 			local_bh_disable();
 			local_irq_enable();
+			preempt_enable();
 
 			h = &softirq_vec[data->nr];
 			if (h)

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

end of thread, other threads:[~2009-11-11  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-11  4:35 [PATCH-rt 1/1] softirqs: add preempt_check_resched() in ksoftirqd() Jupyung Lee
2009-11-11  7:21 ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.