Re: [RFC] locking/rwsem: Avoid issuing wakeup before setting the reader waiter to nil

From: Davidlohr Bueso
Date: Tue Dec 18 2018 - 12:27:26 EST


On Tue, 18 Dec 2018, Peter Zijlstra wrote:
I'd rather do it like so, except I'm still conflicted on the naming.

+void wake_q_add(struct wake_q_head *head, struct task_struct *task)
+{
+ if (__wake_q_add(head, task))
+ get_task_struct(task);
+}
+
+void wake_q_add_safe(struct wake_q_head *head, struct task_struct *task)
+{
+ if (!__wake_a_add(head, task))
+ put_task_struct(task);
}

That is, in the one case it has internal reference counting, in the
other case it consumes the reference counting.

Yeah I like that better for an interface. Also no concurrency in head
so delaying the get() should be ok.

Thanks,
Davidlohr