Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src-all/rev/9f9b4e466042
branches:  trunk
changeset: 936592:9f9b4e466042
user:      Taylor R Campbell <riastradh%NetBSD.org@localhost>
date:      Fri Jul 31 03:06:02 2020 +0000

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

diffstat:

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

diffs (39 lines):

diff -r 14228ccdcddb -r 9f9b4e466042 sys/kern/subr_pcu.c
--- a/sys/kern/subr_pcu.c       Fri Jul 31 02:02:15 2020 +0000
+++ b/sys/kern/subr_pcu.c       Fri Jul 31 03:06:02 2020 +0000
@@ -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