This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Make sem_timedwait use FUTEX_CLOCK_REALTIME (bug 18138)

It's come to my attention that in fact my patch does not fix the bug for 
32-bit x86, since that has its own lowlevellock-futex.h which does not 
define lll_futex_timed_wait_bitset.

The reason 32-bit x86 cannot use the generic Linux lowlevellock-futex.h 
(at least, as stated in 
<>) is 
unavailability of six-argument syscalls from C.  The sixth syscall 
argument goes in %ebp (the frame pointer), leaving no general-purpose 
registers other than %esp free at the time of the syscall.

The effect is that using a six-argument syscall from C would require the 
frame pointer to be eliminated in any function using such a syscall, as 
well as requiring the compiler to handle an inline asm that leaves no 
registers free other than the stack pointer.

It is or was also the case that asms clobbering the hard frame pointer do 
not work with GCC; this resulted in problems for Thumb-2 glibc.  
Furthermore, if you make the asms save and restore the frame pointer 
internally (necessarily on the stack in the x86 case, given the lack of 
other registers), you need to represent this in CFI.

The problem with representing frame pointer save and restore resulted in 
Thumb-2 glibc using out-of-line syscalls; see 
<>.  With DWARF 
it should be possible to represent "at this point, the CFA is derived in 
this way from the value saved in this stack location".  It's not clear to 
me, however, how that could be done in an inline asm in such a way to work 
with whatever choice the compiler has made for the CFA for that function 
(which might be based on either %ebp or %esp, at an offset unknown to the 
inline asm) - normal register saves and restores inside inline asm are 
fine, saving %ebp on the stack may be harder.

So it seems natural to me for six-argument syscalls to use an out-of-line 
helper on x86, as for Thumb-2.  Which options would people prefer?

For how the helper is defined:

* Some way I haven't thought of to keep the syscalls inline while having 
accurate CFI.

* Out-of-line in libc, normal calling convention.

* Out-of-line in libpthread only (given the current need for such syscalls 
only in libpthread), normal calling convention.

* Out-of-line in libpthread only, special calling convention.

For how it is used:

* Used in some way by the INTERNAL_SYSCALL macro for the six-argument 

* Used only by some special macro in lowlevellock-futex.h.

For how large the initial fix is:

* Implement only lll_futex_timed_wait_bitset with the new facility, 
deferring other futex features until there is some known case for them.

* Completely move to the generic lowlevellock-futex.h (implies making 
INTERNAL_SYSCALL handle the six-argument case).

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]