Commit ae9b661f authored by Mikio Hara's avatar Mikio Hara

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
parent ef6c21d0
......@@ -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
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment