1
0
mirror of https://github.com/golang/go synced 2024-11-12 05:30:21 -07:00

runtime: make use of THREAD_SHARE userspace mutex on freebsd

For now Note, futexsleep and futexwakeup are designed for threads,
not for processes. The explicit use of UMTX_OP_WAIT_UINT_PRIVATE and
UMTX_OP_WAKE_PRIVATE can avoid unnecessary traversals of VM objects,
to hit undiscovered bugs related to VM system on SMP/SMT/NUMA
environment.

Update #7496

LGTM=iant
R=golang-codereviews, gobot, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/72760043
This commit is contained in:
Mikio Hara 2014-03-12 10:33:09 +09:00
parent ef6c21d0e9
commit ae9b661fa8
5 changed files with 19 additions and 11 deletions

View File

@ -49,8 +49,10 @@ const (
SA_RESTART = C.SA_RESTART
SA_ONSTACK = C.SA_ONSTACK
UMTX_OP_WAIT_UINT = C.UMTX_OP_WAIT_UINT
UMTX_OP_WAKE = C.UMTX_OP_WAKE
UMTX_OP_WAIT_UINT = C.UMTX_OP_WAIT_UINT
UMTX_OP_WAIT_UINT_PRIVATE = C.UMTX_OP_WAIT_UINT_PRIVATE
UMTX_OP_WAKE = C.UMTX_OP_WAKE
UMTX_OP_WAKE_PRIVATE = C.UMTX_OP_WAKE_PRIVATE
SIGHUP = C.SIGHUP
SIGINT = C.SIGINT

View File

@ -21,8 +21,10 @@ enum {
SA_RESTART = 0x2,
SA_ONSTACK = 0x1,
UMTX_OP_WAIT_UINT = 0xb,
UMTX_OP_WAKE = 0x3,
UMTX_OP_WAIT_UINT = 0xb,
UMTX_OP_WAIT_UINT_PRIVATE = 0xf,
UMTX_OP_WAKE = 0x3,
UMTX_OP_WAKE_PRIVATE = 0x10,
SIGHUP = 0x1,
SIGINT = 0x2,

View File

@ -21,8 +21,10 @@ enum {
SA_RESTART = 0x2,
SA_ONSTACK = 0x1,
UMTX_OP_WAIT_UINT = 0xb,
UMTX_OP_WAKE = 0x3,
UMTX_OP_WAIT_UINT = 0xb,
UMTX_OP_WAIT_UINT_PRIVATE = 0xf,
UMTX_OP_WAKE = 0x3,
UMTX_OP_WAKE_PRIVATE = 0x10,
SIGHUP = 0x1,
SIGINT = 0x2,

View File

@ -21,8 +21,10 @@ enum {
SA_RESTART = 0x2,
SA_ONSTACK = 0x1,
UMTX_OP_WAIT_UINT = 0xb,
UMTX_OP_WAKE = 0x3,
UMTX_OP_WAIT_UINT = 0xb,
UMTX_OP_WAIT_UINT_PRIVATE = 0xf,
UMTX_OP_WAKE = 0x3,
UMTX_OP_WAKE_PRIVATE = 0x10,
SIGHUP = 0x1,
SIGINT = 0x2,

View File

@ -50,7 +50,7 @@ runtime·futexsleep(uint32 *addr, uint32 val, int64 ns)
Timespec ts;
if(ns < 0) {
ret = runtime·sys_umtx_op(addr, UMTX_OP_WAIT_UINT, val, nil, nil);
ret = runtime·sys_umtx_op(addr, UMTX_OP_WAIT_UINT_PRIVATE, val, nil, nil);
if(ret >= 0 || ret == -EINTR)
return;
goto fail;
@ -58,7 +58,7 @@ runtime·futexsleep(uint32 *addr, uint32 val, int64 ns)
// NOTE: tv_nsec is int64 on amd64, so this assumes a little-endian system.
ts.tv_nsec = 0;
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)&ts.tv_nsec);
ret = runtime·sys_umtx_op(addr, UMTX_OP_WAIT_UINT, val, nil, &ts);
ret = runtime·sys_umtx_op(addr, UMTX_OP_WAIT_UINT_PRIVATE, val, nil, &ts);
if(ret >= 0 || ret == -EINTR)
return;
@ -78,7 +78,7 @@ runtime·futexwakeup(uint32 *addr, uint32 cnt)
{
int32 ret;
ret = runtime·sys_umtx_op(addr, UMTX_OP_WAKE, cnt, nil, nil);
ret = runtime·sys_umtx_op(addr, UMTX_OP_WAKE_PRIVATE, cnt, nil, nil);
if(ret >= 0)
return;