|
|
Subscribe / Log in / New account

The perils of pinning

The perils of pinning

Posted Sep 19, 2022 4:40 UTC (Mon) by koverstreet (✭ supporter ✭, #4296)
In reply to: The perils of pinning by willy
Parent article: The perils of pinning

In general I agree, but for lock waitlists I don't think we'd ever want to switch to a vector.

Lock waitlists are typically short - expected length of 1! - and we aren't ever walking the whole thing, the operations are adding to the end of the list and waking up the waiter at the head of the list, so we actually end up with less pointer chasing with a linked list.


to post comments

The perils of pinning

Posted Sep 19, 2022 7:04 UTC (Mon) by willy (subscriber, #9762) [Link]

Oh yes, (sleep) locks shouldn't even have a list_head. Instead they should have a pointer to their first waiter. That shrinks the lock by the size of one pointer. How that waiter keeps track of other waiters is debatable; maybe it should be vector, but I suspect a list_head is just fine. Perhaps a vector makes sense to keep track of the readers so they can all be woken up quickly, but I see no advantage to keep writers in anything other than a list.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds