Re: [PATCH -V2] acpi: don't cond_resched if irq is disabled

From: Lin Ming
Date: Fri Dec 11 2009 - 01:00:57 EST


On Thu, 2009-12-10 at 20:21 +0800, Alexey Starikovskiy wrote:
> Hi Xiaotian,
>
> I think, this is another round of "armor vs. bullet" race... It will hold until
> might_sleep() logic changes again.
>
> Please consider using preemptible() -- IMHO this is the check we should perform
> in our case of voluntary preemption.

preemptible() may not work here because it always returns 0 for
non-preemptible kernel.

#ifdef CONFIG_PREEMPT
# define preemptible() (preempt_count() == 0 && !irqs_disabled())
# define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
#else
# define preemptible() 0
# define IRQ_EXIT_OFFSET HARDIRQ_OFFSET
#endif

Lin Ming

>
> Regards,
> Alex.
>
>
> Xiaotian Feng ÐÐÑÐÑ:
> > commit 8bd108d adds preemption point after each opcode parse, then
> > a sleeping function called from invalid context bug was founded
> > during suspend/resume stage. this was fixed in commit abe1dfa by
> > don't cond_resched when irq_disabled. But recent commit 138d156 changes
> > the behaviour to don't cond_resched when in_atomic. This makes the
> > sleeping function called from invalid context bug happen again, which
> > is reported in http://lkml.org/lkml/2009/12/1/371.
> >
> > This patch also fixes http://bugzilla.kernel.org/show_bug.cgi?id=14483
> >
> > Reported-and-bisected-by: Larry Finger <Larry.Finger@xxxxxxxxxxxx>
> > Reported-and-bisected-by: Justin P. Mattock <justinmattock@xxxxxxxxx>
> > Signed-off-by: Xiaotian Feng <dfeng@xxxxxxxxxx>
> > Cc: Len Brown <lenb@xxxxxxxxxx>
> > Cc: Bob Moore <robert.moore@xxxxxxxxx>
> > Cc: Lin Ming <ming.m.lin@xxxxxxxxx>
> > Cc: Alexey Starikovskiy <astarikovskiy@xxxxxxx>
> > Cc: Pavel Machek <pavel@xxxxxx>
> > ---
> > include/acpi/platform/aclinux.h | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
> > index 9d7febd..0946997 100644
> > --- a/include/acpi/platform/aclinux.h
> > +++ b/include/acpi/platform/aclinux.h
> > @@ -152,7 +152,7 @@ static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
> > #include <linux/hardirq.h>
> > #define ACPI_PREEMPTION_POINT() \
> > do { \
> > - if (!in_atomic_preempt_off()) \
> > + if (!in_atomic_preempt_off() && !irqs_disabled()) \
> > cond_resched(); \
> > } while (0)
> >
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/