Thread (25 messages) 25 messages, 3 authors, 2021-04-27

Re: [PATCH 8/8] blk-mq: clear stale request in tags->rq[] before freeing one request pool

From: Ming Lei <hidden>
Date: 2021-04-26 02:07:13
Also in: linux-nvme, linux-scsi

On Sun, Apr 25, 2021 at 06:50:48PM -0700, Bart Van Assche wrote:
On 4/25/21 5:49 PM, Ming Lei wrote:
quoted
On Sun, Apr 25, 2021 at 01:42:59PM -0700, Bart Van Assche wrote:
quoted
Using cmpxchg() on set->tags[] is only safe if all other set->tags[]
accesses are changed into WRITE_ONCE() or READ_ONCE().
Why?

Semantic of cmpxchg() is to modify value pointed by the address if its
old value is same with passed 'rq'. That is exactly what we need.

writting 'void *' is always atomic. if someone has touched
'->rqs[tag]', cmpxchg() won't modify the value.
WRITE_ONCE() supports data types that have the same size as char, short,
int, long and long long. That includes void *. If writes to these data
types would always be atomic then we wouldn't need the WRITE_ONCE()
macro.
OK, then we don't need WRITE_ONCE(), since WRITE on tags->rqs[i] is
always atomic.


Thanks, 
Ming
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help