Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Teach pcu(9) about LW_SYSTEM_FPU -- kthreads with f...



details:   https://anonhg.NetBSD.org/src/rev/6cd900d5e0c5
branches:  trunk
changeset: 936625:6cd900d5e0c5
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Aug 01 02:05:45 2020 +0000

description:
Teach pcu(9) about LW_SYSTEM_FPU -- kthreads with fpu enabled.

diffstat:

 sys/kern/subr_pcu.c |  19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 162fc32a296d -r 6cd900d5e0c5 sys/kern/subr_pcu.c
--- a/sys/kern/subr_pcu.c       Sat Aug 01 02:04:55 2020 +0000
+++ b/sys/kern/subr_pcu.c       Sat Aug 01 02:05:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pcu.c,v 1.22 2020/06/06 18:13:01 thorpej Exp $    */
+/*     $NetBSD: subr_pcu.c,v 1.23 2020/08/01 02:05:45 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2011, 2014 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.22 2020/06/06 18:13:01 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.23 2020/08/01 02:05:45 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -89,6 +89,17 @@
 extern const pcu_ops_t * const pcu_ops_md_defs[];
 
 /*
+ * pcu_available_p: true if lwp is allowed to use PCU state.
+ */
+static inline bool
+pcu_available_p(struct lwp *l)
+{
+
+       /* XXX Not sure this is safe unless l is locked!  */
+       return (l->l_flag & (LW_SYSTEM|LW_SYSTEM_FPU)) != LW_SYSTEM;
+}
+
+/*
  * pcu_switchpoint: release PCU state if the LWP is being run on another CPU.
  * This routine is called on each context switch by by mi_switch().
  */
@@ -135,7 +146,7 @@
         * due to an error in the LWP creation path before it ever runs.
         */
        KASSERT(l == curlwp || l->l_stat == LSIDL ||
-               ((l->l_flag & LW_SYSTEM) && pcu_valid == 0));
+               (!pcu_available_p(l) && pcu_valid == 0));
 
        if (__predict_true(pcu_valid == 0)) {
                /* PCUs are not in use. */
@@ -174,7 +185,7 @@
         * with a different LWP (forking a system LWP or doing a coredump of
         * a process with multiple threads) and we need to deal with that.
         */
-       KASSERT(l == curlwp || (((l->l_flag & LW_SYSTEM) ||
+       KASSERT(l == curlwp || ((!pcu_available_p(l) ||
            (curlwp->l_proc == l->l_proc && l->l_stat == LSSUSPENDED)) &&
            pcu_valid == 0));
 



Home | Main Index | Thread Index | Old Index