Re: [PATCH v2 07/10] softmmu/physmem: Don't use atomic operations in ram_block_discard_(disable|require)

2020-12-10 Thread Pankaj Gupta
> >> bool ram_block_discard_is_disabled(void) > >> { > >> -return qatomic_read(&ram_block_discard_disabled) > 0; > >> +return qatomic_read(&ram_block_discard_disablers); > >> } > > return value won't be bool? > > The compiler does type conversion. > > != 0 -> true > == 0 -> false ah... I

Re: [PATCH v2 07/10] softmmu/physmem: Don't use atomic operations in ram_block_discard_(disable|require)

2020-12-10 Thread David Hildenbrand
>> bool ram_block_discard_is_disabled(void) >> { >> -return qatomic_read(&ram_block_discard_disabled) > 0; >> +return qatomic_read(&ram_block_discard_disablers); >> } > return value won't be bool? The compiler does type conversion. != 0 -> true == 0 -> false [...] > Apart from query

Re: [PATCH v2 07/10] softmmu/physmem: Don't use atomic operations in ram_block_discard_(disable|require)

2020-12-10 Thread Pankaj Gupta
> We have users in migration context that don't hold the BQL (when > finishing migration). To prepare for further changes, use a dedicated mutex > instead of atomic operations. Keep using qatomic_read ("READ_ONCE") for the > functions that only extract the current state (e.g., used by > virtio-ball

[PATCH v2 07/10] softmmu/physmem: Don't use atomic operations in ram_block_discard_(disable|require)

2020-12-08 Thread David Hildenbrand
We have users in migration context that don't hold the BQL (when finishing migration). To prepare for further changes, use a dedicated mutex instead of atomic operations. Keep using qatomic_read ("READ_ONCE") for the functions that only extract the current state (e.g., used by virtio-balloon), lock