Source-Changes-HG archive

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

[src/netbsd-6-0]: src/sys/kern Pull up following revision(s) (requested by ms...



details:   https://anonhg.NetBSD.org/src/rev/20afeb7dd4e7
branches:  netbsd-6-0
changeset: 774754:20afeb7dd4e7
user:      riz <riz%NetBSD.org@localhost>
date:      Fri Feb 08 20:28:22 2013 +0000

description:
Pull up following revision(s) (requested by msaitoh in ticket #790):
        sys/kern/kern_rndq.c: revision 1.7
  Set resource limit. The rnd_process_events() function is called every tick
and process the sample queue. Without limitation, if a lot of rnd_add_*()
are called, all kernel memory may be eaten up.

diffstat:

 sys/kern/kern_rndq.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 63913cfc1412 -r 20afeb7dd4e7 sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c      Fri Feb 08 20:22:44 2013 +0000
+++ b/sys/kern/kern_rndq.c      Fri Feb 08 20:28:22 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rndq.c,v 1.1.2.2 2012/04/20 23:35:20 riz Exp $    */
+/*     $NetBSD: kern_rndq.c,v 1.1.2.2.4.1 2013/02/08 20:28:22 riz Exp $        */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1.2.2 2012/04/20 23:35:20 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1.2.2.4.1 2013/02/08 20:28:22 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -405,7 +405,17 @@
        rnd_mempc = pool_cache_init(sizeof(rnd_sample_t), 0, 0, 0,
                                    "rndsample", NULL, IPL_VM,
                                    NULL, NULL, NULL);
-       /* Mix *something*, *anything* into the pool to help it get started.
+
+       /*
+        * Set resource limit. The rnd_process_events() function
+        * is called every tick and process the sample queue.
+        * Without limitation, if a lot of rnd_add_*() are called,
+        * all kernel memory may be eaten up.
+        */
+       pool_cache_sethardlimit(rnd_mempc, RND_POOLBITS, NULL, 0);
+
+       /*
+        * Mix *something*, *anything* into the pool to help it get started.
         * However, it's not safe for rnd_counter() to call microtime() yet,
         * so on some platforms we might just end up with zeros anyway.
         * XXX more things to add would be nice.



Home | Main Index | Thread Index | Old Index