adding general purpose mtx+cv to kthread

Poul-Henning Kamp phk at phk.freebsd.dk
Sat Feb 2 12:47:57 PST 2008


The select(2) system call has a dirty little secret data structure
(struct seltd) which it hangs off the kthread (->td_sel), amongst
the reasons for this is to avoid a mtx_init() and cv_init() and associated
destroy calls with each call to select(2).

I'm working on an enhancement to sendfile(2) that has the exact same
need for a mtx+cv combo and the question is how many other such
we have, once we get through the code.

Various solutions present themselves, from swallowing the overhead
for sendfile(2) since it's probably delta anyway over sharing selects
data structure (safe for the locks, since both syscalls are stateless)
to what seems most sensible to me:

Add a general purpose mtx+cv to struct kthread for use by syscalls
that need to keep track of things and sleep on stuff.

This wouldn't make the seltd structure go away, it contains other
stuff as well, it would just eliminate the mtx+cv combo from it.

Any comment or insights ?

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-arch mailing list