We have some form of reference counting for at least the following:
fs_node_ts ("open" increments the reference count, "close" decrements it)
- Page directories
- File descriptor tables (
->refs)
- On x86-64, individual memory pages for CoW.
Only file nodes really have something remotely close to a proper interface for managing the reference counts.
We should build a standard interface for reference counting kernel objects like these, and also extend that to other kernel objects - particularly processes, which somehow have managed to escape having any sort of reference counting mostly through very lazy disposal.
Linux calls the operations on reference counted objects "get" and "put" which... I'm not going to bother trying to phrase this professionally: I think "put" is a stupid name for "decrement reference count".
Since our file nodes are the only thing that has a real interface, maybe we should standardize around that: "open" references to things and then "close" the references when we're done :-)
All operations that want to deal with a reference counted object must either being creating the object in the first place, or be able to obtain it through an existing open reference in a lock-safe manner. Processes and files are some of the trickier cases, as we want to both be able to discard them when no more users are around, but these things need to be discoverable from outside of the context of an existing reference, so lock management around increment references for such a lookup-based retrieval must be very carefully implemented.
We have some form of reference counting for at least the following:
fs_node_ts ("open" increments the reference count, "close" decrements it)->refs)Only file nodes really have something remotely close to a proper interface for managing the reference counts.
We should build a standard interface for reference counting kernel objects like these, and also extend that to other kernel objects - particularly processes, which somehow have managed to escape having any sort of reference counting mostly through very lazy disposal.
Linux calls the operations on reference counted objects "get" and "put" which... I'm not going to bother trying to phrase this professionally: I think "put" is a stupid name for "decrement reference count".
Since our file nodes are the only thing that has a real interface, maybe we should standardize around that: "open" references to things and then "close" the references when we're done :-)
All operations that want to deal with a reference counted object must either being creating the object in the first place, or be able to obtain it through an existing open reference in a lock-safe manner. Processes and files are some of the trickier cases, as we want to both be able to discard them when no more users are around, but these things need to be discoverable from outside of the context of an existing reference, so lock management around increment references for such a lookup-based retrieval must be very carefully implemented.