[dm-devel] [PATCH] dm: fix race condition on Alpha

Mikulas Patocka mpatocka at redhat.com
Wed Mar 30 16:45:32 UTC 2022



On Tue, 29 Mar 2022, Hannes Reinecke wrote:

> On 3/28/22 18:34, Mikulas Patocka wrote:
> > Early alpha processors cannot write a single byte or short; they read 8
> > bytes, modify the value in registers and write back 8 bytes.
> > 
> > This could cause race condition in the structure dm_io - if the fields
> > flags and io_count are modified simultaneously.
> > 
> > Fix this bug by using 32-bit flags if we are on Alpha and if we are
> > compiling for a processor that doesn't have the byte-word-extension.
> > 
> Errm.
> 
> Seeing that those alphas could only modify 64 bit atomically, what 
> exactly do you gain by using 32-bit flags?
> Shouldn't you be using 64-bit flags?
> 
> Cheers,
> 
> Hannes

Alpha can modify atomically aligned 32 bits or aligned 64 bits (using the 
STL or STQ instruction).

If it needs to modify 8 or 16 bits, it reads 64 bits (using the LDQ_U 
instruction), modifies the value in the register (using the INSBL and 
MSKBL instructions) and writes back 64 bits (using the STQ_U instruction).

Using 32-bit flags is safe, because it reads them and writes them directly 
using the 32-bit LDL and STL instructions.

Mikulas


More information about the dm-devel mailing list