adding general purpose mtx+cv to kthread

Julian Elischer julian at elischer.org
Sat Feb 2 21:26:15 PST 2008


Poul-Henning Kamp wrote:
> 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 ?
        [...]
	void *td_syscal_priv; /* valid for duration of syscall only */
        [...]

seems a reasonably useful thing





More information about the freebsd-arch mailing list