Re: [PATCH 4/7] locking/rwsem: threshold limited spinning for active readers

From
Davidlohr Bueso <hidden>
Date
2014-08-05 05:30:38
Also in
lkml
Reply to
Davidlohr Bueso, 2014-08-05
On Mon, 2014-08-04 at 21:54 -0700, Davidlohr Bueso wrote:
quoted
 #ifdef CONFIG_RWSEM_SPIN_ON_OWNER
+/*
+ * The owner field is set to RWSEM_READ_OWNED if the last owner(s) are
+ * readers. It is not reset until a writer takes over and set it to its
+ * task structure pointer or NULL when it frees the lock. So a value
+ * of RWSEM_READ_OWNED doesn't mean it currently has active readers.
+ */
+#define RWSEM_READ_OWNED	((struct task_struct *)-1)
Looks rather weird...
Instead of populating owner when taking the reader lock, why not just
leave it NULL. Then, we can differentiate between the owner being NULL
either because it is taken by reader(s) or simply because it is not
taken. So something like this:

static inline bool rwsem_owner_is_reader(struct rw_semaphore *sem)
{
	return !sem->owner && rwsem_is_locked(sem));
}
Thread (23 messages) 23 messages, 4 authors, last reply 2014-08-05
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help