Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ffs Prefer cprng_fast32 over random. A good distribu...



details:   https://anonhg.NetBSD.org/src/rev/9bb854b90efe
branches:  trunk
changeset: 332143:9bb854b90efe
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Sep 08 20:52:37 2014 +0000

description:
Prefer cprng_fast32 over random. A good distribution even in the lower
bits beat any minor performance advantage randomo(9) might have,
especially given the disk IO involved.

diffstat:

 sys/ufs/ffs/ffs_alloc.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r 0088a82daf26 -r 9bb854b90efe sys/ufs/ffs/ffs_alloc.c
--- a/sys/ufs/ffs/ffs_alloc.c   Mon Sep 08 19:24:16 2014 +0000
+++ b/sys/ufs/ffs/ffs_alloc.c   Mon Sep 08 20:52:37 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_alloc.c,v 1.146 2014/07/25 08:24:31 dholland Exp $ */
+/*     $NetBSD: ffs_alloc.c,v 1.147 2014/09/08 20:52:37 joerg Exp $    */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.146 2014/07/25 08:24:31 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.147 2014/09/08 20:52:37 joerg Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -90,6 +90,7 @@
 #include <sys/syslog.h>
 #include <sys/vnode.h>
 #include <sys/wapbl.h>
+#include <sys/cprng.h>
 
 #include <miscfs/specfs/specdev.h>
 #include <ufs/ufs/quota.h>
@@ -697,7 +698,7 @@
         * Force allocation in another cg if creating a first level dir.
         */
        if (ITOV(pip)->v_vflag & VV_ROOT) {
-               prefcg = random() % fs->fs_ncg;
+               prefcg = cprng_fast32() % fs->fs_ncg;
                mincg = prefcg;
                minndir = fs->fs_ipg;
                for (cg = prefcg; cg < fs->fs_ncg; cg++)



Home | Main Index | Thread Index | Old Index