[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] rwlock: remove unneeded subtraction



commit 26f8eead2b8d19396bb57d00144bb19ae25f8f27
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Fri Feb 18 09:01:27 2022 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Feb 18 09:01:27 2022 +0100

    rwlock: remove unneeded subtraction
    
    There's no need to subtract _QR_BIAS from the lock value for storing
    in the local cnts variable in the read lock slow path: the users of
    the value in cnts only care about the writer-related bits and use a
    mask to get the value.
    
    Note that further setting of cnts in rspin_until_writer_unlock already
    do not subtract _QR_BIAS.
    
    Originally _QR_BIAS was subtracted from the result of
    atomic_add_return_acquire in order to prevent GCC from emitting an
    unneeded ADD instruction. This being in the lock slow path such
    optimizations don't seem likely to make any relevant performance
    difference. Also modern GCC and CLANG versions will already avoid
    emitting the ADD instruction.
    
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
 xen/common/rwlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/common/rwlock.c b/xen/common/rwlock.c
index dadab372b5..aa15529bbe 100644
--- a/xen/common/rwlock.c
+++ b/xen/common/rwlock.c
@@ -47,7 +47,7 @@ void queue_read_lock_slowpath(rwlock_t *lock)
     while ( atomic_read(&lock->cnts) & _QW_WMASK )
         cpu_relax();
 
-    cnts = atomic_add_return(_QR_BIAS, &lock->cnts) - _QR_BIAS;
+    cnts = atomic_add_return(_QR_BIAS, &lock->cnts);
     rspin_until_writer_unlock(lock, cnts);
 
     /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.