lkml.org 
[lkml]   [2000]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] preemptive kernel, preemptive-2.3.52-A7

On Tue, 14 Mar 2000, Andrea Arcangeli wrote:

> >i've also introduced a new light-weight 'IRQ-atomic' increment and
> >decrement method in atomic.h, because ->may_preempt has to be
> >local-IRQ-safe.
>
> Could you describe which race you are talking about? I can't see any
> race on such field.

i've introduced atomic_inc_local() and atomic_dec_local() to implement
'local-CPU-IRQ atomic' increments and decrements. The following increment
which you are using:

current->blah--;

is not theoretically local-IRQ-safe, because the compiler is free to
reorder this with other lines. (and thus those other lines could get
possibly moved into the 'freely preemptable' area, causing subtle
small-window bugs.)

the following is safe as well:

barrier();
current->blah--;
barrier();

but i just felt we want to make it IRQ-atomic as well (although this is
not strictly necessery now as IRQ contexts never change current->blah.) If
current->blah is modified from IRQ contexts as well then 'current->blah--'
is not IRQ-safe as it might get compiled into several instructions:

movl blah, %eax
decl %eax
movl %eax, blah

although this does not happen on x86 currently, it could theoretically.
But your version is definitely buggy because it lacks a compiler-level
barrier. (which atomic_dec_local() automatically is)

Ingo


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

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.159 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site