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

Re: [PATCH] rwlock: remove unneeded subtraction


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Luca Fancellu <luca.fancellu@xxxxxxx>
  • Date: Tue, 15 Feb 2022 11:54:07 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wKcKXhoTx+igdbWMHJsiKM/50GDGJ8kddRW1k4iP5L0=; b=UXc82k/d4dC+Wf18dvtqEQ2GvTNprxAZR5GOvcgAQoKrDnwroLILmeOUswZ3Qur2QOUhVj19YEq1EnY9/Bk1fUauun9fOG+U0u2S4K6hMglP1v6byaA7TOiy4slKHywZvrvw0C5tPc6zhqZIcz5wUxgaqz3v8dA83tQi1ER4oLig2q6yYh78jb8kuhbRQr7TzqWnsafueO56IHfp81hcwJIT01khcCCJfnHmpcvuPrCDTdm4rXqaM5wtpKgrlHIcvEbfSm1PyvSCMig5NHJC4A6Ap1hyM4jMY4F0cBpbLTzUSw08sFoUKCu3vct2YE8VxNmDx/BAUdWZICQ4C7lagw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CGJRKN420fmEnqwGkQaevLuNNLPm+LDsQYt0c4IIOOCaByJtv/19w2cKd0DjwuB3rU39hb7Zc4HhHXiSpLE0hhBVdFZcQsyyLsYDacnq3b/pCEMHEo7pAFwbt1QNpBeK7Uk5Ec6ld7o29O4tqep9Qtt5fkVxg5MtV7NTqY5XDzSVfRnPJC2/GNawUfbn0MtX7O2RpshzY2x7Jl9ysBz6s6tYuM0ou5ORnVMBgPTC3B0eRj1RsooXWeQc9NYTAyNuZkv2jy1IV174N74iptXROj9P5G13mRCeAE++9e8237OQOHEm1ORsAcGznIOvCFFxcmJ8ziYowy/6ZhhSxghSoA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 15 Feb 2022 11:54:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;


> On 15 Feb 2022, at 09:39, Roger Pau Monne <roger.pau@xxxxxxxxxx> wrote:
> 
> 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.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

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);
> 
>     /*
> -- 
> 2.34.1
> 
> 




 


Rackspace

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