turnstile
include/sync/turnstile.h View source View on GitHubStructs
Section titled “Structs”turnstile
Section titled “turnstile” struct turnstile (11 fields) source
§
struct thread_wait_header wait §
struct thread_class_donation pi §
size_t waiters how many goobers are blocking on me?
§
void *lock_obj lock we are for
§
struct rbt queues[TURNSTILE_NUM_QUEUES] §
enum turnstile_state state §
uint64_t next_wait_seq §
uint32_t handoffs since the last fairness turn
turnstile_hash_chain
Section titled “turnstile_hash_chain” struct turnstile_hash_chain (2 fields) source
turnstile_hash_table
Section titled “turnstile_hash_table” struct turnstile_hash_table (1 field) source
§
struct turnstile_hash_chain heads[TURNSTILE_HASH_SIZE] turnstile_state
Section titled “turnstile_state” enum turnstile_state (3 variants) source
Functions
Section titled “Functions”turnstiles_init
Section titled “turnstiles_init”void turnstiles_init(void) source turnstile_create
Section titled “turnstile_create”turnstile_destroy
Section titled “turnstile_destroy”turnstile_init
Section titled “turnstile_init”turnstile_block
Section titled “turnstile_block”turnstile_lookup
Section titled “turnstile_lookup”turnstile_unlock
Section titled “turnstile_unlock”turnstile_wake
Section titled “turnstile_wake”turnstile_propagate_wroost
Section titled “turnstile_propagate_wroost”bool turnstile_propagate_wroost(
struct wroost_percpu_data *pcd,
struct thread *t
) source Returns whether the caller pcd needs to re-check threads because somewhere down the PI chain, someone wanted to bother the caller pcd (also merges kicks into pcd)
turnstile_wake_handoff
Section titled “turnstile_wake_handoff”void turnstile_wake_handoff(
struct turnstile *ts,
size_t queue,
struct thread *target,
enum irql lock_irql
) source Hand off to queue head if target is NULL
turnstile_fair_pick
Section titled “turnstile_fair_pick”Called once per handoff with chain locked. NULL means we should use the priority ordering of wq_prio
turnstile_get_waiter_count
Section titled “turnstile_get_waiter_count”size_t turnstile_get_waiter_count(void *lock_obj) source turnstile_thread_priority
Section titled “turnstile_thread_priority”Macros
Section titled “Macros”TURNSTILE_WRITER_QUEUE
Section titled “TURNSTILE_WRITER_QUEUE”#define TURNSTILE_WRITER_QUEUE 0 source TURNSTILE_READER_QUEUE
Section titled “TURNSTILE_READER_QUEUE”#define TURNSTILE_READER_QUEUE 1 source TURNSTILE_NUM_QUEUES
Section titled “TURNSTILE_NUM_QUEUES”#define TURNSTILE_NUM_QUEUES 2 source TURNSTILE_BYPASS_LIMIT
Section titled “TURNSTILE_BYPASS_LIMIT”#define TURNSTILE_BYPASS_LIMIT 4 source Every TURNSTILE_BYPASS_LIMIT-th handoff wakes the longest waiting waiter instead of the highest wq_prio
turnstile_from_freelist
Section titled “turnstile_from_freelist”#define turnstile_from_freelist(fl) source Expansion
#define turnstile_from_freelist(fl) \
(container_of(fl, struct turnstile, freelist_node)) turnstile_from_hash_list_node
Section titled “turnstile_from_hash_list_node”#define turnstile_from_hash_list_node(hln) source Expansion
#define turnstile_from_hash_list_node(hln) \
(container_of(hln, struct turnstile, hash_list)) TURNSTILE_HASH_SIZE
Section titled “TURNSTILE_HASH_SIZE”#define TURNSTILE_HASH_SIZE 128 source TURNSTILE_HASH_MASK
Section titled “TURNSTILE_HASH_MASK”#define TURNSTILE_HASH_MASK (TURNSTILE_HASH_SIZE - 1) source TURNSTILE_OBJECT_HASH
Section titled “TURNSTILE_OBJECT_HASH”#define TURNSTILE_OBJECT_HASH(obj) source Expansion
#define TURNSTILE_OBJECT_HASH(obj) \
((((uintptr_t) (obj) >> 3) * 2654435761u) & TURNSTILE_HASH_MASK) TURNSTILE_CHAIN
Section titled “TURNSTILE_CHAIN”#define TURNSTILE_CHAIN(sobj) source Expansion
#define TURNSTILE_CHAIN(sobj) global.turnstiles[TURNSTILE_OBJECT_HASH(sobj)]