Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys/rump/librump/rumpkern Pull up following revision(s) (...
details: https://anonhg.NetBSD.org/src/rev/c44f22954e1e
branches: netbsd-7
changeset: 798268:c44f22954e1e
user: martin <martin%NetBSD.org@localhost>
date: Mon Aug 18 13:26:54 2014 +0000
description:
Pull up following revision(s) (requested by riastradh in ticket #35):
sys/rump/librump/rumpkern/hyperentropy.c: revision 1.6
sys/rump/librump/rumpkern/hyperentropy.c: revision 1.7
sys/rump/librump/rumpkern/hyperentropy.c: revision 1.4
sys/rump/librump/rumpkern/hyperentropy.c: revision 1.5
Call rnd_add_data asynchronously for the rump hyperentropy callback.
Avoids recursion rnd_getmore -> rnd_add_data -> rnd_getmore, which is
silly but I don't have time to fix it properly right now.
add sys/atomic.h and order headers correctly
Fix header ordering
<sys/param.h> comes first, per /usr/share/misc/style.
diffstat:
sys/rump/librump/rumpkern/hyperentropy.c | 37 +++++++++++++++++++++++++++----
1 files changed, 32 insertions(+), 5 deletions(-)
diffs (80 lines):
diff -r d5a8b7cc293a -r c44f22954e1e sys/rump/librump/rumpkern/hyperentropy.c
--- a/sys/rump/librump/rumpkern/hyperentropy.c Mon Aug 18 12:42:27 2014 +0000
+++ b/sys/rump/librump/rumpkern/hyperentropy.c Mon Aug 18 13:26:54 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hyperentropy.c,v 1.3 2014/08/10 16:44:36 tls Exp $ */
+/* $NetBSD: hyperentropy.c,v 1.3.2.1 2014/08/18 13:26:54 martin Exp $ */
/*
* Copyright (c) 2014 Antti Kantee. All Rights Reserved.
@@ -26,9 +26,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hyperentropy.c,v 1.3 2014/08/10 16:44:36 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperentropy.c,v 1.3.2.1 2014/08/18 13:26:54 martin Exp $");
#include <sys/param.h>
+#include <sys/atomic.h>
#include <sys/kmem.h>
#include <sys/rnd.h>
@@ -37,10 +38,12 @@
#include "rump_private.h"
static krndsource_t rndsrc;
+static volatile unsigned hyperentropy_wanted;
+static void *feedrandom_softint;
#define MAXGET (RND_POOLBITS/NBBY)
static void
-feedrandom(size_t bytes, void *arg)
+feedrandom(size_t bytes)
{
uint8_t *rnddata;
size_t dsize;
@@ -52,18 +55,42 @@
kmem_intr_free(rnddata, MAXGET);
}
+static void
+feedrandom_intr(void *cookie __unused)
+{
+
+ feedrandom(atomic_swap_uint(&hyperentropy_wanted, 0));
+}
+
+static void
+feedrandom_cb(size_t bytes, void *cookie __unused)
+{
+ unsigned old, new;
+
+ do {
+ old = hyperentropy_wanted;
+ new = ((MAXGET - old) < bytes? MAXGET : (old + bytes));
+ } while (atomic_cas_uint(&hyperentropy_wanted, old, new) != old);
+
+ softint_schedule(feedrandom_softint);
+}
+
void
rump_hyperentropy_init(void)
{
if (rump_threads) {
- rndsource_setcb(&rndsrc, feedrandom, &rndsrc);
+ feedrandom_softint =
+ softint_establish(SOFTINT_CLOCK|SOFTINT_MPSAFE,
+ feedrandom_intr, NULL);
+ KASSERT(feedrandom_softint != NULL);
+ rndsource_setcb(&rndsrc, feedrandom_cb, &rndsrc);
rnd_attach_source(&rndsrc, "rump_hyperent", RND_TYPE_VM,
RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
} else {
/* without threads, just fill the pool */
rnd_attach_source(&rndsrc, "rump_hyperent", RND_TYPE_VM,
RND_FLAG_COLLECT_VALUE);
- feedrandom(RND_POOLBITS/NBBY, NULL);
+ feedrandom(MAXGET);
}
}
Home |
Main Index |
Thread Index |
Old Index