Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Introduce curlwp_bind and curlwp_bindx
details: https://anonhg.NetBSD.org/src/rev/4ee12437df71
branches: trunk
changeset: 816073:4ee12437df71
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Jun 16 02:34:33 2016 +0000
description:
Introduce curlwp_bind and curlwp_bindx
The API prevents the current LWP from migrating between CPUs during
the critical section (between curlwp_bind and curlwp_bindx). One use
case of it is psref(9) that has a contract that forbids such migrations.
Proposed at http://mail-index.netbsd.org/tech-kern/2016/06/13/msg020710.html
(check it out if you want to know why the function names are chosen)
diffstat:
sys/sys/lwp.h | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diffs (38 lines):
diff -r 147d4c40e75c -r 4ee12437df71 sys/sys/lwp.h
--- a/sys/sys/lwp.h Thu Jun 16 01:33:35 2016 +0000
+++ b/sys/sys/lwp.h Thu Jun 16 02:34:33 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lwp.h,v 1.170 2015/03/31 01:10:02 matt Exp $ */
+/* $NetBSD: lwp.h,v 1.171 2016/06/16 02:34:33 ozaki-r Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010
@@ -521,6 +521,28 @@
#define DOPREEMPT_ACTIVE 0x01
#define DOPREEMPT_COUNTED 0x02
+/*
+ * Prevent curlwp from migrating between CPUs beteen curlwp_bind and
+ * curlwp_bindx. One use case is psref(9) that has a contract that
+ * forbids migrations.
+ */
+static inline int
+curlwp_bind(void)
+{
+ int bound;
+
+ bound = curlwp->l_pflag & LP_BOUND;
+ curlwp->l_pflag |= LP_BOUND;
+
+ return bound;
+}
+
+static inline void
+curlwp_bindx(int bound)
+{
+ curlwp->l_pflag ^= bound ^ LP_BOUND;
+}
+
#endif /* _KERNEL */
/* Flags for _lwp_create(), as per Solaris. */
Home |
Main Index |
Thread Index |
Old Index