Re: [PATCH] crypto: hisilicon/zip - Optimize performance by replacing rw_lock with spinlock
From: Herbert Xu
Date: Fri Aug 30 2024 - 06:48:16 EST
On Sat, Aug 24, 2024 at 02:38:56AM +0800, Kuan-Wei Chiu wrote:
> The req_lock is currently implemented as a rw_lock, but there are no
> instances where read_lock() is called. This means that the lock is
> effectively only used by writers, making it functionally equivalent to
> a simple spinlock.
>
> As stated in Documentation/locking/spinlocks.rst:
> "Reader-writer locks require more atomic memory operations than simple
> spinlocks. Unless the reader critical section is long, you are better
> off just using spinlocks."
>
> Since the rw_lock in this case incurs additional atomic memory
> operations without any benefit from reader-writer locking, it is more
> efficient to replace it with a spinlock. This patch implements that
> replacement to optimize the driver's performance.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
> ---
> Note: Build test only.
>
> drivers/crypto/hisilicon/zip/zip_crypto.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt