Futex Asynchronous Interface
Hi Rusty,
Quoted 11 lines
if (this->page == page && this->offset == offset) { list_del_init(i); tell_waiter(this);(quoted diff) +1
-0+ unpin_page(this->page);num_woken++; if (num_woken >= num) break; } } spin_unlock(&futex_lock);(quoted diff) +1
-0+ unpin_page(page);return num_woken;
If I understand right you shouldn't unpin the page if you are not sure that all waiters for a specific (page,offset)-combination are woken up and deleted from the waitqueue. Otherwise a second call to futex_wake may look on the wrong hash_queue or wake the wrong waiters.
In general, I think fast userspace synchronization primitives and asynchronous notification are different enough to keep them logically more separated. Your double use of the hashed wait queues and sys_call make the code difficult to grasp and thus open for subtle error.
Martin
Martin
In message <[email protected]> you write:
Quoted 17 lines
Hi Rusty,
Quoted 11 lines
if (this->page == page && this->offset == offset) { list_del_init(i); tell_waiter(this);(quoted diff) +1
-0+ unpin_page(this->page);num_woken++; if (num_woken >= num) break; } } spin_unlock(&futex_lock);(quoted diff) +1
-0+ unpin_page(page);return num_woken;If I understand right you shouldn't unpin the page if you are not sure that all waiters for a specific (page,offset)-combination are woken up and deleted from the waitqueue. Otherwise a second call to
futex_wakemay look on the wro
ng
Quoted 1 line
hash_queueor wake the wrong waiters.
No, we delete them from the list (list_del_init) so we can't find it
again: ie. futex_wake can't be invoked twice on the same thing without someone putting it back on the queue...
Quoted 5 lines
In general, I think fast userspace synchronization primitives and asynchronous notification are different enough to keep them logically more separated. Your double use of the hashed wait queues and
sys_callmake the code difficult to grasp and thus open for subtle error.
I don't think the complexity is much worse: async is inherently complex given that there are no real in-kernel primitives to do offer both sync and async cleanly. Having two incompatible primitives would be painful, too.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.