fix modern futex handling

This commit is contained in:
Tom Callaway 2015-06-09 17:43:35 -04:00
parent 2bec3a5226
commit 706d9bf33a
2 changed files with 60 additions and 7 deletions

View File

@ -1,7 +1,32 @@
diff -up gperftools-2.4/src/base/spinlock_linux-inl.h.armfutex gperftools-2.4/src/base/spinlock_linux-inl.h diff -ru gperftools-2.4/src/base/linux_syscall_support.h gperftools-2.4-fixed/src/base/linux_syscall_support.h
--- gperftools-2.4/src/base/spinlock_linux-inl.h.armfutex 2015-06-01 15:46:32.129618825 -0400 --- gperftools-2.4/src/base/linux_syscall_support.h 2014-12-06 23:51:40.000000000 +0100
+++ gperftools-2.4/src/base/spinlock_linux-inl.h 2015-06-01 15:46:55.081459716 -0400 +++ gperftools-2.4-fixed/src/base/linux_syscall_support.h 2015-06-01 16:51:03.725616215 +0200
@@ -51,13 +51,8 @@ static struct InitModule { @@ -83,7 +83,6 @@
* sys_fcntl(
* sys_fstat(
* sys_futex(
- * sys_futex1(
* sys_getcpu(
* sys_getdents64(
* sys_getppid(
@@ -2094,9 +2093,11 @@
int, c, long, a)
LSS_INLINE _syscall2(int, fstat, int, f,
struct kernel_stat*, b)
- LSS_INLINE _syscall4(int, futex, int*, a,
+ LSS_INLINE _syscall6(int, futex, int*, a,
int, o, int, v,
- struct kernel_timespec*, t)
+ struct kernel_timespec*, t,
+ int*, a2,
+ int, v3)
#ifdef __NR_getdents64
LSS_INLINE _syscall3(int, getdents64, int, f,
struct kernel_dirent64*, d, int, c)
diff -ru gperftools-2.4/src/base/spinlock_linux-inl.h gperftools-2.4-fixed/src/base/spinlock_linux-inl.h
--- gperftools-2.4/src/base/spinlock_linux-inl.h 2014-12-06 23:51:40.000000000 +0100
+++ gperftools-2.4-fixed/src/base/spinlock_linux-inl.h 2015-06-01 16:51:03.725616215 +0200
@@ -51,15 +51,10 @@
int x = 0; int x = 0;
// futexes are ints, so we can use them only when // futexes are ints, so we can use them only when
// that's the same size as the lockword_ in SpinLock. // that's the same size as the lockword_ in SpinLock.
@ -10,8 +35,32 @@ diff -up gperftools-2.4/src/base/spinlock_linux-inl.h.armfutex gperftools-2.4/sr
- have_futex = 0; - have_futex = 0;
-#else -#else
have_futex = (sizeof (Atomic32) == sizeof (int) && have_futex = (sizeof (Atomic32) == sizeof (int) &&
sys_futex(&x, FUTEX_WAKE, 1, 0) >= 0); - sys_futex(&x, FUTEX_WAKE, 1, 0) >= 0);
-#endif -#endif
+ sys_futex(&x, FUTEX_WAKE, 1, NULL, NULL, 0) >= 0);
if (have_futex && if (have_futex &&
sys_futex(&x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) { - sys_futex(&x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) {
+ sys_futex(&x, FUTEX_WAKE | futex_private_flag, 1, NULL, NULL, 0) < 0) {
futex_private_flag = 0; futex_private_flag = 0;
}
}
@@ -85,7 +85,8 @@
tm.tv_nsec *= 16; // increase the delay; we expect explicit wakeups
sys_futex(reinterpret_cast<int *>(const_cast<Atomic32 *>(w)),
FUTEX_WAIT | futex_private_flag,
- value, reinterpret_cast<struct kernel_timespec *>(&tm));
+ value, reinterpret_cast<struct kernel_timespec *>(&tm),
+ NULL, 0);
} else {
nanosleep(&tm, NULL);
}
@@ -96,7 +97,8 @@
void SpinLockWake(volatile Atomic32 *w, bool all) {
if (have_futex) {
sys_futex(reinterpret_cast<int *>(const_cast<Atomic32 *>(w)),
- FUTEX_WAKE | futex_private_flag, all? INT_MAX : 1, 0);
+ FUTEX_WAKE | futex_private_flag, all? INT_MAX : 1,
+ NULL, NULL, 0);
}
}

View File

@ -4,12 +4,13 @@
Name: gperftools Name: gperftools
Version: 2.4 Version: 2.4
Release: 3%{?dist} Release: 4%{?dist}
License: BSD License: BSD
Group: Development/Tools Group: Development/Tools
Summary: Very fast malloc and performance analysis tools Summary: Very fast malloc and performance analysis tools
URL: http://code.google.com/p/gperftools/ URL: http://code.google.com/p/gperftools/
Source0: https://googledrive.com/host/0B6NtGsLhIcf7MWxMMF9JdTN3UVk/%{name}-%{version}.tar.gz Source0: https://googledrive.com/host/0B6NtGsLhIcf7MWxMMF9JdTN3UVk/%{name}-%{version}.tar.gz
# https://code.google.com/p/gperftools/issues/detail?id=693
Patch0: gperftools-arm-has-futex.patch Patch0: gperftools-arm-has-futex.patch
ExcludeArch: s390 s390x ExcludeArch: s390 s390x
%ifnarch ppc %{power64} %ifnarch ppc %{power64}
@ -110,6 +111,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/INSTALL
%{_libdir}/*.so.* %{_libdir}/*.so.*
%changelog %changelog
* Tue Jun 9 2015 Tom Callaway <spot@fedoraproject.org> - 2.4-4
- fix modern futex handling (thanks to Paolo Bonzini)
* Mon Jun 1 2015 Tom Callaway <spot@fedoraproject.org> - 2.4-3 * Mon Jun 1 2015 Tom Callaway <spot@fedoraproject.org> - 2.4-3
- enable futex for ARM - enable futex for ARM