kernel/team: Convert Team linked-lists into DoublyLinkedLists.

They were hand-rolled singly-linked lists before. This adds 24 bytes
of size to the Team structure, but turns all the removal operations
in parent and process group into O(1) operations instead of O(N) ones.
Realistically, the Thread linked-lists should be converted as well,
but this is trickier due to interdependence on the Team structure.
This commit is contained in:
Augustin Cavalier
2025-01-06 23:39:40 -05:00
parent cc9746dbc6
commit 6a75e767e6
3 changed files with 31 additions and 58 deletions
+12 -8
View File
@@ -220,14 +220,13 @@ struct Team : TeamThreadIteratorEntry<team_id>, KernelReferenceable,
AssociatedDataOwner {
DoublyLinkedListLink<Team> global_list_link;
Team *hash_next; // next in hash
Team *siblings_next; // next in parent's list; protected by
// parent's fLock
DoublyLinkedListLink<Team> siblings_link; // protected by parent's fLock
Team *parent; // write-protected by both parent (if any)
// and this team's fLock
Team *children; // protected by this team's fLock;
// adding/removing a child also requires the
// child's fLock
Team *group_next; // protected by the group's lock
DoublyLinkedList<Team, DoublyLinkedListMemberGetLink<Team, &Team::siblings_link> > children;
// protected by this team's fLock;
// adding/removing a child also requires the child's fLock
DoublyLinkedListLink<Team> group_link; // protected by the group's lock
int64 serial_number; // immutable after adding team to hash
@@ -667,9 +666,14 @@ private:
struct ProcessGroup : KernelReferenceable {
struct ProcessGroup *next; // next in hash
typedef DoublyLinkedList<Team,
DoublyLinkedListMemberGetLink<Team,
&Team::group_link> > TeamList;
public:
struct ProcessGroup *hash_next;
pid_t id;
BKernel::Team *teams;
TeamList teams;
public:
ProcessGroup(pid_t id);