Module Name: src
Committed By: ozaki-r
Date: Fri Feb 16 07:11:50 UTC 2018
Modified Files:
src/sys/sys: lwp.h
Log Message:
Add missing barriers to curlwp_bind and curlwp_bindx
The barriers prevent the instruction of setting/clearing the LP_BOUND flag
from reordering over where we want to prevent LWP migrations.
Note that the fix doesn't mean that there was a race condition. For now the API
is used only for psref and the combination use of them doesn't need the
barriers(*).
(*) https://mail-index.netbsd.org/tech-kern/2018/02/15/msg023101.html
Pointed out by Mateusz Guzik
To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/sys/lwp.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/sys/lwp.h
diff -u src/sys/sys/lwp.h:1.177 src/sys/sys/lwp.h:1.178
--- src/sys/sys/lwp.h:1.177 Sun Jan 14 16:43:03 2018
+++ src/sys/sys/lwp.h Fri Feb 16 07:11:50 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: lwp.h,v 1.177 2018/01/14 16:43:03 maxv Exp $ */
+/* $NetBSD: lwp.h,v 1.178 2018/02/16 07:11:50 ozaki-r Exp $ */
/*
* Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010
@@ -536,6 +536,7 @@ curlwp_bind(void)
bound = curlwp->l_pflag & LP_BOUND;
curlwp->l_pflag |= LP_BOUND;
+ __insn_barrier();
return bound;
}
@@ -545,6 +546,7 @@ curlwp_bindx(int bound)
{
KASSERT(curlwp->l_pflag & LP_BOUND);
+ __insn_barrier();
curlwp->l_pflag ^= bound ^ LP_BOUND;
}