Re: [patch] possible SMP races all over the place in wait_event

Andrea Arcangeli (andrea@suse.de)
Tue, 24 Aug 1999 14:45:38 +0200 (CEST)


On Tue, 24 Aug 1999, David S. Miller wrote:

> From: Ingo Molnar <mingo@redhat.com>
>
> instead of:
>
> current->state = TASK_INTERRUPTIBLE;
> + mb();
>
> shouldnt we do:
>
> + xchgl(&current->state, TASK_INTERRUPTIBLE);
>
> This 'merges' the barrier and the write. Or rather, in asm-i386 we could
> do something like:
>
> #define set_mb(addr,val) xchgl(addr,val)
>
> and then use set_barrier().
>
>Sure, but it costs ~8 instructions instead of 2 on ll/sc architectures.

I don't know what is "ll/sc" but I agree that at least on architectures
that has a proper "mb" assembler instruction the mb() approch seems to be
right choice to me.

When we'll reach an agreement I'll be happy to redo the patch with a
different approch. ;) (after all the conversion will be only a trivial
task)

My proposal could be something like:

set_current_state(INTERRUPTIBLE);

and #define a secondary:

__set_current_state(INTERRUPTIBLE);

that it will never used by me, but it can be used to implement future code
that doesn't need an explicit SMP memory barrier.

Hints are welcome. ;)

Thanks.

Andrea

-
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/