lkml.org 
[lkml]   [2005]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [CRYPTO]: Only reschedule if !in_atomic()
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
>
> On Mon, 2005-05-23 at 16:28 -0700, Andrew Morton wrote:
>
> > This code can cause deadlocks on CONFIG_SMP && !CONFIG_PREEMPT kernels.
> >
> > Please see http://lkml.org/lkml/2005/3/10/358
> >
> > You (the programmer) *have* to know what context you're running in before
> > doing a voluntary yield. There is simply no way to work this out at
> > runtime.
>
> Hrm... Linus just merged it though...
>

The old version was:

if (!in_softirq())
cond_resched();

Which I guess is OK if the programmer knows that this code is only ever called

a) from softirq context or

b) from process context with no locks/smp_processor_id/etc held.

The new version is:

if (!in_atomic())
cond_resched();

which happens to still be correct as long as a) and b) still hold, which I
assume they do.

Both versions are deadlocky if b) is violated.

So. It sucks before and it sucks after, but we might not be deadlocky.
Problem is, !CONFIG_PREEMPT also disable the beancounting which
might_sleep() depends upon, so it's harder to tell whether all callers are
correct.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-05-24 02:30    [W:0.170 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site