Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Eliminate curcpu_available() hack.



details:   https://anonhg.NetBSD.org/src/rev/336b73b207be
branches:  trunk
changeset: 932468:336b73b207be
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri May 08 00:54:44 2020 +0000

description:
Eliminate curcpu_available() hack.

The entropy subsystem is no longer used before curcpu() and curlwp
are available on x86.

diffstat:

 sys/kern/kern_entropy.c |  36 +++++++++---------------------------
 1 files changed, 9 insertions(+), 27 deletions(-)

diffs (106 lines):

diff -r 32a2e98cd216 -r 336b73b207be sys/kern/kern_entropy.c
--- a/sys/kern/kern_entropy.c   Fri May 08 00:53:25 2020 +0000
+++ b/sys/kern/kern_entropy.c   Fri May 08 00:54:44 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_entropy.c,v 1.15 2020/05/08 00:53:25 riastradh Exp $      */
+/*     $NetBSD: kern_entropy.c,v 1.16 2020/05/08 00:54:44 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.15 2020/05/08 00:53:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.16 2020/05/08 00:54:44 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -255,19 +255,6 @@
 static void    rndsource_to_user_est(struct krndsource *, rndsource_est_t *);
 
 /*
- * curcpu_available()
- *
- *     True if we can inspect the current CPU.  Early on this may not
- *     work.  XXX On most if not all ports, this should work earlier.
- */
-static inline bool
-curcpu_available(void)
-{
-
-       return true;
-}
-
-/*
  * entropy_timer()
  *
  *     Cycle counter, time counter, or anything that changes a wee bit
@@ -279,10 +266,6 @@
        struct bintime bt;
        uint32_t v;
 
-       /* Very early on, cpu_counter32() may not be available.  */
-       if (!curcpu_available())
-               return 0;
-
        /* If we have a CPU cycle counter, use the low 32 bits.  */
 #ifdef __HAVE_CPU_COUNTER
        if (__predict_true(cpu_hascounter()))
@@ -777,7 +760,7 @@
        uint32_t pending;
        int s;
 
-       KASSERTMSG(!curcpu_available() || !cpu_intr_p(),
+       KASSERTMSG(!cpu_intr_p(),
            "use entropy_enter_intr from interrupt context");
        KASSERTMSG(howmany(nbits, NBBY) <= len,
            "impossible entropy rate: %u bits in %zu-byte string", nbits, len);
@@ -1268,7 +1251,7 @@
                mutex_enter(&E->lock);
 
        /* Count up request for entropy in interrupt context.  */
-       if (curcpu_available() && cpu_intr_p())
+       if (cpu_intr_p())
                entropy_extract_intr_evcnt.ev_count++;
 
        /* Wait until there is enough entropy in the system.  */
@@ -1627,7 +1610,7 @@
 
        if (E->sourcelock)
                return false;
-       E->sourcelock = (curcpu_available() ? curlwp : (void *)1);
+       E->sourcelock = curlwp;
        return true;
 }
 
@@ -1643,9 +1626,8 @@
 
        KASSERT(E->stage == ENTROPY_COLD || mutex_owned(&E->lock));
 
-       KASSERTMSG(E->sourcelock == (curcpu_available() ? curlwp : (void *)1),
-           "lwp %p releasing lock held by %p",
-           (curcpu_available() ? curlwp : (void *)1), E->sourcelock);
+       KASSERTMSG(E->sourcelock == curlwp, "lwp %p releasing lock held by %p",
+           curlwp, E->sourcelock);
        E->sourcelock = NULL;
        if (E->stage >= ENTROPY_WARM)
                cv_broadcast(&E->cv);
@@ -1661,7 +1643,7 @@
 rnd_sources_locked(void)
 {
 
-       return E->sourcelock == (curcpu_available() ? curlwp : (void *)1);
+       return E->sourcelock == curlwp;
 }
 
 /*
@@ -1820,7 +1802,7 @@
         * take note of whether it consumed the full sample; if not,
         * use entropy_enter, which always consumes the full sample.
         */
-       if (curcpu_available() && cpu_intr_p()) {
+       if (curlwp && cpu_intr_p()) {
                fullyused = entropy_enter_intr(buf, len, entropybits);
        } else {
                entropy_enter(buf, len, entropybits);



Home | Main Index | Thread Index | Old Index