This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: __ASSUME_PRIVATE_FUTEX and __ASSUME_FUTEX_CLOCK_REALTIME
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Torvald Riegel <triegel at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 12 Jun 2015 10:49:37 -0700 (PDT)
- Subject: Re: __ASSUME_PRIVATE_FUTEX and __ASSUME_FUTEX_CLOCK_REALTIME
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1406202013520 dot 1155 at digraph dot polyomino dot org dot uk> <20140620231516 dot 6C7AA2C39C2 at topped-with-meat dot com> <1420486141 dot 29798 dot 4 dot camel at triegel dot csb> <20150609232041 dot 5B2622C3BE6 at topped-with-meat dot com> <1433948418 dot 10071 dot 90 dot camel at triegel dot csb> <20150610205031 dot CBF222C3C19 at topped-with-meat dot com> <1434128706 dot 5250 dot 19 dot camel at localhost dot localdomain>
> Several of the pthread data structures combine the availability of
> private futexes and the choice the user makes into a final flag on data
> structure initialization time (futex_private_if_supported in my new API
> is a helper function for that). We could do that, and then futex_*
> don't need to check/transform on the calls. Alternatively, we could
> check whether the requested private/shared is actually supported during
> each futex_* call, and adapt accordingly. The latter might be a tiny
> bit of overhead, but futex_* calls are basically always on slow paths.
> If we can do the latter, we can remove futex_private_if_supported and
> all that.
I recognize that overhead on slow paths matter little and that tiny
overheads matter not much more. But I still think we should go for early
transformation into the forms that need the least work and/or storage
later. Partly it just seems like a close to zero-sum trade-off between
doing work early and doing it later, and since early means once per object
and later means once per use (worst case), might as well choose the better
one even if it's negligibly better in practice. But also it just seems
right to fold together the input validation with the transformation to
internal forms, and we always have some amount of input validation anyway.
Thanks,
Roland