[lustre-devel] [PATCH 1/4] staging: lustre: obdclass: change spinlock of key to rwlock

David Laight David.Laight at ACULAB.COM
Thu May 3 06:50:07 PDT 2018


From: James Simmons
> Sent: 02 May 2018 19:22
> From: Li Xi <lixi at ddn.com>
> 
> Most of the time, keys are never changed. So rwlock might be
> better for the concurrency of key read.

OTOH unless there is contention on the spin lock during reads the
additional cost of a rwlock (probably double that of a spinlock)
will hurt performance.

...
> -	spin_lock(&lu_keys_guard);
> +	read_lock(&lu_keys_guard);
>  	atomic_inc(&lu_key_initing_cnt);
> -	spin_unlock(&lu_keys_guard);
> +	read_unlock(&lu_keys_guard);

WTF, seems unlikely that you need to hold any kind of lock
over an atomic_inc().

If this is just ensuring that no code holds the lock then
it would need to request the write_lock().
(and would need a comment)

	David



More information about the lustre-devel mailing list