From waddlesplash <waddlesplash@xxxxxxxxx>:
waddlesplash has uploaded this change for review. (
Change subject: [WIP!] kernel: Overhaul select() implementation and surrounding
[WIP!] kernel: Overhaul select() implementation and surrounding code.
This change does a lot of similar things to hamishm's version, but
in a much cleaner way (or at least I think so :). About 1/5 of the
changes are from that commit, the rest are mine.
* The select hooks (with the exception of the legacy driver hooks)
now take "uint32* events" instead of "uint8 event" as an argument,
which specifies the events in B_EVENT_* format instead of B_SELECT_*
format, and then is modified by the calling driver to indicate what
events there already are. This eliminates the need to invoke the
notifiers within the select hooks themselves, and cleans up
a good number of code paths.
* A number of drivers that did not properly "notify immediately"
(the socket module is the biggest culprit here ... there are
some open tickets about this problem, actually) now do so.
* The select structs have been overhauled and rearranged. There is now
- select_pool, which holds selectsyncs in a linked list, and has
utility functions to notify all the selects in it. Its functionalites
have been tweaked to the point where all other storage mechanisms
for selectsyncs have been replaced with it (except in userlandfs,
more on that later.)
- select_set, which contains a set of selectsyncs, and is what
select/wait_for_objects/poll use to store their select objects.
It contains the semaphore used to wake up the waiting thread.
- selectsync, a single select wait entry which is passed to
one driver, and is a member of one select_set.
Only selectsync is defined in a header, and there it is only used
inside the kernel itself. All other modules interact with these
via API calls.
* select_pools now lock themselves independently of the structure they
are a part of.
* Double storages of selectsyncs (most notably in VFS) have been
eliminated. This formally makes the "bottom-most" driver that
receives the selectsync responsible for storing and dealing with
it (this was already true in practice, so I'm not sure why VFS
stored the selectsyncs, anyway.)
* hamishm went the route of "deprecating" the fd_deselect hooks but
not removing them. I've mostly removed them here, as events are
now deselected directly by removing the selectsync from the
select_pool it was added to. This breaks userlandfs (I have a
half baked solution to fix that...) and out-of-tree/BeOS drivers
using the old no-pool system.
In thinking about this carefully, I'm not so sure removing the
deselect hooks is such a good idea. It does remove an awful
lot of overhead, but it seems like the benefits and clarity
of having the deselect hooks outweight whatever downsides
there may be. So depending on what reviewers think, I'll
revise this patch to reinstate them, most likely (which will
make the changes to userlandfs much easier, too.)
Tested with the @minimum image. Terminal works, as does curl/ping/etc.
So it seems this is at least functioning as things did before.
53 files changed, 538 insertions(+), 1,211 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/42/1742/1
To view, visit https://review.haiku-os.org/c/haiku/+/1742
To unsubscribe, or for help writing mail filters, visit
Gerrit-Owner: waddlesplash <waddlesplash@xxxxxxxxx>