Reduce lock contention in kernel port subsystem.
* Replace ports list mutex with R/W-lock. * Move team port list protection to separate array of mutexes. Relieve contention on sPortsLock by removing Team::port_list from its protected items. With this, set_port_owner() only needs to acquire the sPortsLock for reading. * Add another hash table holding the ports by name. Used by find_port() so it doesn't have to iterate over the list anymore. * Use slab-based memory allocator for port messages. sPortQuotaLock was acquired on every message send or receive and was thus another point of contention. The lock is not necessary anymore. * Lock for port hashes and Port::lock are no longer locked in a nested fashion to reduce chances of blocking other threads. * Make operations concurrency-safe by adding an atomically accessed Port::state which provides linearization points to port creation and deletion. Both operations are now divided into logical and physical parts, the logical part just updating the state and the physical part adding/remove it to/from the port hash and team port list. * set_port_owner() is the only remaining function which still locks Port::lock and one or two of sTeamListLock[] in a nested fashion. Since it needs to move the port from one team list to another and change Port::owner, there's no way around. * Ports are now reference counted to make accesses to already-deleted ports safe. * Should fix #8007.
This commit is contained in:
@@ -36,6 +36,8 @@ void delete_owned_ports(Team* team);
|
||||
int32 port_max_ports(void);
|
||||
int32 port_used_ports(void);
|
||||
|
||||
size_t port_team_link_offset();
|
||||
|
||||
status_t select_port(int32 object, struct select_info *info, bool kernel);
|
||||
status_t deselect_port(int32 object, struct select_info *info, bool kernel);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user