Thread (29 messages) flat view 29 messages, 3 authors, 2016-09-02

Re: [PATCH RESEND net-next 13/15] smc: receive data from RMBE

From: Ursula Braun <hidden>
Date: 2016-08-10 20:04:50
Also in: linux-s390


On 08/09/2016 11:32 PM, David Miller wrote:
From: Ursula Braun <redacted>
Date: Tue,  9 Aug 2016 12:12:58 +0200
quoted
+		xchg(&conn->rx_curs_confirmed.acurs,
+		     smc_curs_read(conn->local_tx_ctrl.cons.acurs));
Why in the world do you need to use xchg() in all of these places?

It makes no sense whatsoever, especially since you don't even check
the return value.
98e906b2
If you need the operation to be atomic, then you have to check the
return value and do something to recover if something else beat
you to the xchg() and put something else into the location.

Otherwise, you therefore don't need it be atomic and can avoid
this expensive operation and just store the value normally.
Reviewing my xchg() usages, I really detected some paranoid usages, that 
I am going to remove. But there are still usages (and 
conn->rx_curs_confirmed is one of them), where I need an 8-byte cursor 
field to be read and written atomicaly, even though I do not care 
whether the write operation has been beaten or not. But I do care that 
reading the cursor does not return a partially updated cursor. Isn't 
xchg() a possible solution in this case?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help