[PATCH] Update to new generic semaphore algorithm v2

Torvald Riegel triegel@redhat.com
Tue Jan 13 01:15:00 GMT 2015


This patch is a revision of that patch:
https://sourceware.org/ml/libc-alpha/2014-12/msg00527.html

The changes compare to that patch are aimed at making this as
non-invasive as possible:
* Not based on top of the futex clean-up patches anymore.  The futex
wrappers from those patches have simply been copied, so can be replaced
easily once we do the futex clean-up; furthermore, we still get to do
proper futex error handling in the new semaphore.
* It assumes that EINTR is only returned by FUTEX_WAIT if the syscall
was indeed interrupted by a signal.  This conflicts with what the
current Linux-kernel-side info on when EINTR can be returned, but keeps
doing what glibc's semaphore has assumed so far.  As a result, we don't
need to change nptl/tst-sem4.
* Fixes a linknamespace issue by moving sem_timedwait into its own file.

Tested and no regressions on Linux x86_64 and i686.  I haven't tested
the old semaphore version (ie, __old_sem*), but the change is minimal
(one release fence added -- was already present in the alpha and powerpc
implementations).

OK?


2015-01-13  Torvald Riegel  <triegel@redhat.com>

	[BZ #12674]
	* nptl/sem_waitcommon.c: New file.  Implement new semaphore algorithm.
	* nptl/sem_wait.c: Include sem_waitcommon.c.
	(__sem_wait_cleanup, do_futex_wait): Remove.
	(__new_sem_wait): Adapt.
	(__new_sem_trywait): New function.
	(__old_sem_trywait): Moved here from nptl/sem_trywait.c.
	* nptl/sem_timedwait.c: Include sem_waitcommon.c.
	(__sem_wait_cleanup, do_futex_timed_wait): Remove.
	(sem_timedwait): Adapt.
	* nptl/sem_post.c (__new_sem_post): Adapt.
	(futex_wake): New function.
	(__old_sem_post): Add release MO fence.
	* nptl/sem_open.c (sem_open): Adapt.
	* nptl/sem_init.c (__new_sem_init): Adapt.
	(futex_private_if_supported): New function.
	* nptl/sem_getvalue.c (__new_sem_getvalue): Adapt.
	(__old_sem_getvalue): Add using previous code.
	* sysdeps/nptl/internaltypes.h: Adapt.
	* nptl/tst-sem13.c (do_test): Adapt.
	* nptl/tst-sem11.c (main): Adapt.
	* nptl/sem_trywait.c: Remove.
	* nptl/DESIGN-sem.txt: Remove.
	* nptl/Makefile (libpthread-routines): Remove sem_trywait.
	(gen-as-const-headers): Remove structsem.sym.
	* nptl/structsem.sym: Remove.
	* sysdeps/unix/sysv/linux/alpha/sem_post.c: Remove.
	* sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i586/sem_post.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i586/sem_wait.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i686/sem_post.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S: Remove.
	* sysdeps/unix/sysv/linux/i386/i686/sem_wait.S: Remove.
	* sysdeps/unix/sysv/linux/powerpc/sem_post.c: Remove.
	* sysdeps/unix/sysv/linux/sh/sem_post.S: Remove.
	* sysdeps/unix/sysv/linux/sh/sem_timedwait.S: Remove.
	* sysdeps/unix/sysv/linux/sh/sem_trywait.S: Remove.
	* sysdeps/unix/sysv/linux/sh/sem_wait.S: Remove.
	* sysdeps/unix/sysv/linux/x86_64/sem_post.S: Remove.
	* sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Remove.
	* sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Remove.
	* sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Remove.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: semv2.patch
Type: text/x-patch
Size: 87911 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150113/ebd106bd/attachment.bin>


More information about the Libc-alpha mailing list