* [PATCH 1/3] genirq: Get rid of unneeded force parameter in irq_finalize_oneshot()
@ 2012-03-19 14:58 Alexander Gordeev
2012-03-22 10:32 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Gordeev @ 2012-03-19 14:58 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel
The only place irq_finalize_oneshot() is called with force parameter set
is the threaded handler error exit path. But IRQTF_RUNTHREAD is dropped
at this point and irq_wake_thread() is not going to reset it again,
since PF_EXITING is set for this thread already. So we will drop the
thread's bit in threads_oneshot anyway and the force parameter is
superfluous.
Also, the orded or checking PF_EXITING and IRQTF_RUNTHREAD flags in
irq_wake_thread() is important now, so escalate it more visibly in the
source code.
---
kernel/irq/handle.c | 16 ++++++++++------
kernel/irq/manage.c | 10 +++++-----
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 6ff84e6..bdb1803 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -54,14 +54,18 @@ static void warn_no_thread(unsigned int irq, struct irqaction *action)
static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
{
/*
- * Wake up the handler thread for this action. In case the
- * thread crashed and was killed we just pretend that we
- * handled the interrupt. The hardirq handler has disabled the
- * device interrupt, so no irq storm is lurking. If the
+ * In case the thread crashed and was killed we just pretend that
+ * we handled the interrupt. The hardirq handler has disabled the
+ * device interrupt, so no irq storm is lurking.
+ */
+ if (action->thread->flags & PF_EXITING)
+ return;
+
+ /*
+ * Wake up the handler thread for this action. If the
* RUNTHREAD bit is already set, nothing to do.
*/
- if ((action->thread->flags & PF_EXITING) ||
- test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags))
+ if (test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags))
return;
/*
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index b0ccd1a..bf606a5 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -645,7 +645,7 @@ static int irq_wait_for_interrupt(struct irqaction *action)
* is marked MASKED.
*/
static void irq_finalize_oneshot(struct irq_desc *desc,
- struct irqaction *action, bool force)
+ struct irqaction *action)
{
if (!(desc->istate & IRQS_ONESHOT))
return;
@@ -679,7 +679,7 @@ again:
* we would clear the threads_oneshot bit of this thread which
* was just set.
*/
- if (!force && test_bit(IRQTF_RUNTHREAD, &action->thread_flags))
+ if (test_bit(IRQTF_RUNTHREAD, &action->thread_flags))
goto out_unlock;
desc->threads_oneshot &= ~action->thread_mask;
@@ -739,7 +739,7 @@ irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action)
local_bh_disable();
ret = action->thread_fn(action->irq, action->dev_id);
- irq_finalize_oneshot(desc, action, false);
+ irq_finalize_oneshot(desc, action);
local_bh_enable();
return ret;
}
@@ -755,7 +755,7 @@ static irqreturn_t irq_thread_fn(struct irq_desc *desc,
irqreturn_t ret;
ret = action->thread_fn(action->irq, action->dev_id);
- irq_finalize_oneshot(desc, action, false);
+ irq_finalize_oneshot(desc, action);
return ret;
}
@@ -844,7 +844,7 @@ void exit_irq_thread(void)
wake_threads_waitq(desc);
/* Prevent a stale desc->threads_oneshot */
- irq_finalize_oneshot(desc, action, true);
+ irq_finalize_oneshot(desc, action);
}
static void irq_setup_forced_threading(struct irqaction *new)
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] genirq: Get rid of unneeded force parameter in irq_finalize_oneshot()
2012-03-19 14:58 [PATCH 1/3] genirq: Get rid of unneeded force parameter in irq_finalize_oneshot() Alexander Gordeev
@ 2012-03-22 10:32 ` Thomas Gleixner
2012-03-22 11:06 ` Alexander Gordeev
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2012-03-22 10:32 UTC (permalink / raw)
To: Alexander Gordeev; +Cc: linux-kernel
On Mon, 19 Mar 2012, Alexander Gordeev wrote:
> The only place irq_finalize_oneshot() is called with force parameter set
> is the threaded handler error exit path. But IRQTF_RUNTHREAD is dropped
> at this point and irq_wake_thread() is not going to reset it again,
> since PF_EXITING is set for this thread already. So we will drop the
> thread's bit in threads_oneshot anyway and the force parameter is
> superfluous.
Wrong.
CPU 0 CPU 1
do_exit()
check(PF_EXITING)
set_bit(IRQTF_RUNTHREAD)
...
set(PF_EXITING)
exit_irq_thread()
if (test_bit(IRQTF_RUNTHREAD))
goto out;
-> FAIL
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] genirq: Get rid of unneeded force parameter in irq_finalize_oneshot()
2012-03-22 10:32 ` Thomas Gleixner
@ 2012-03-22 11:06 ` Alexander Gordeev
2012-03-22 14:15 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Gordeev @ 2012-03-22 11:06 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel
On Thu, Mar 22, 2012 at 11:32:26AM +0100, Thomas Gleixner wrote:
> Wrong.
>
> CPU 0 CPU 1
>
> do_exit()
> check(PF_EXITING)
> set_bit(IRQTF_RUNTHREAD)
> ...
> set(PF_EXITING)
> exit_irq_thread()
Thomas,
Did not you pick this code with 7140ea1 commit?
@@ -845,6 +842,13 @@ void exit_irq_thread(void)
desc = irq_to_desc(action->irq);
+ /*
+ * If IRQTF_RUNTHREAD is set, we need to decrement
+ * desc->threads_active and wake possible waiters.
+ */
+ if (test_and_clear_bit(IRQTF_RUNTHREAD, &action->thread_flags))
+ wake_threads_waitq(desc);
+
/* Prevent a stale desc->threads_oneshot */
irq_finalize_oneshot(desc, action, true);
}
>
> if (test_bit(IRQTF_RUNTHREAD))
> goto out;
>
> -> FAIL
>
> Thanks,
>
> tglx
--
Regards,
Alexander Gordeev
agordeev@redhat.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] genirq: Get rid of unneeded force parameter in irq_finalize_oneshot()
2012-03-22 11:06 ` Alexander Gordeev
@ 2012-03-22 14:15 ` Thomas Gleixner
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2012-03-22 14:15 UTC (permalink / raw)
To: Alexander Gordeev; +Cc: linux-kernel
On Thu, 22 Mar 2012, Alexander Gordeev wrote:
> On Thu, Mar 22, 2012 at 11:32:26AM +0100, Thomas Gleixner wrote:
> > Wrong.
> >
> > CPU 0 CPU 1
> >
> > do_exit()
> > check(PF_EXITING)
> > set_bit(IRQTF_RUNTHREAD)
> > ...
> > set(PF_EXITING)
> > exit_irq_thread()
>
> Thomas,
>
> Did not you pick this code with 7140ea1 commit?
>
> @@ -845,6 +842,13 @@ void exit_irq_thread(void)
>
> desc = irq_to_desc(action->irq);
>
> + /*
> + * If IRQTF_RUNTHREAD is set, we need to decrement
> + * desc->threads_active and wake possible waiters.
> + */
> + if (test_and_clear_bit(IRQTF_RUNTHREAD, &action->thread_flags))
> + wake_threads_waitq(desc);
> +
Gah crap. Was looking on the wrong branch. That's what you get for
looking at patches before coffee hit brain.
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-03-22 14:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-19 14:58 [PATCH 1/3] genirq: Get rid of unneeded force parameter in irq_finalize_oneshot() Alexander Gordeev
2012-03-22 10:32 ` Thomas Gleixner
2012-03-22 11:06 ` Alexander Gordeev
2012-03-22 14:15 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox