]> git.baikalelectronics.ru Git - kernel.git/commit
rds: Make sure updates to cp_send_gen can be observed
authorHåkon Bugge <Haakon.Bugge@oracle.com>
Thu, 20 Jul 2017 10:28:55 +0000 (12:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Jul 2017 22:33:01 +0000 (15:33 -0700)
commit8ade9f40b96ee355869a1b26c326f012ff5323e3
treee3dc5acbe886b14e0dde4296b6b78748ac7175cd
parent7e29f5f65342a618e1d2b8e6272c13b7a139019f
rds: Make sure updates to cp_send_gen can be observed

cp->cp_send_gen is treated as a normal variable, although it may be
used by different threads.

This is fixed by using {READ,WRITE}_ONCE when it is incremented and
READ_ONCE when it is read outside the {acquire,release}_in_xmit
protection.

Normative reference from the Linux-Kernel Memory Model:

    Loads from and stores to shared (but non-atomic) variables should
    be protected with the READ_ONCE(), WRITE_ONCE(), and
    ACCESS_ONCE().

Clause 5.1.2.4/25 in the C standard is also relevant.

Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
Reviewed-by: Knut Omang <knut.omang@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/send.c