Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern Define kthread_fpu_enter/exit for ...



details:   https://anonhg.NetBSD.org/src/rev/bbbf1f999211
branches:  trunk
changeset: 974515:bbbf1f999211
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Aug 01 22:30:57 2020 +0000

description:
Define kthread_fpu_enter/exit for rump.

XXX Not 100% sure that it's safe to touch curlwp->l_flag in this
context, but this change will make progress, at least.

diffstat:

 sys/rump/librump/rumpkern/threads.c |  30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diffs (51 lines):

diff -r e37612588699 -r bbbf1f999211 sys/rump/librump/rumpkern/threads.c
--- a/sys/rump/librump/rumpkern/threads.c       Sat Aug 01 21:51:22 2020 +0000
+++ b/sys/rump/librump/rumpkern/threads.c       Sat Aug 01 22:30:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: threads.c,v 1.26 2017/04/21 19:16:10 kamil Exp $       */
+/*     $NetBSD: threads.c,v 1.27 2020/08/01 22:30:57 riastradh Exp $   */
 
 /*
  * Copyright (c) 2007-2009 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.26 2017/04/21 19:16:10 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.27 2020/08/01 22:30:57 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -247,6 +247,32 @@
        return rv;
 }
 
+int
+kthread_fpu_enter(void)
+{
+       struct lwp *l = curlwp;
+       int s;
+
+       KASSERTMSG(l->l_flag & LW_SYSTEM,
+           "%s is allowed only in kthreads", __func__);
+       s = l->l_flag & LW_SYSTEM_FPU;
+       l->l_flag |= LW_SYSTEM_FPU;
+
+       return s;
+}
+
+void
+kthread_fpu_exit(int s)
+{
+       struct lwp *l = curlwp;
+
+       KASSERT(s == (s & LW_SYSTEM_FPU));
+       KASSERTMSG(l->l_flag & LW_SYSTEM,
+           "%s is allowed only in kthreads", __func__);
+       KASSERT(l->l_flag & LW_SYSTEM_FPU);
+       l->l_flag ^= s ^ LW_SYSTEM_FPU;
+}
+
 /*
  * Create a non-kernel thread that is scheduled by a rump kernel hypercall.
  *



Home | Main Index | Thread Index | Old Index