Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Mar 2019 00:58:39 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r345122 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201903140058.x2E0wdqD082710@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Mar 14 00:58:39 2019
New Revision: 345122
URL: https://svnweb.freebsd.org/changeset/base/345122

Log:
  MFC r344903: Improve entropy for ZFS taskqueue selection.
  
  I just found that at least on Skylake CPUs cpu_ticks() never returns odd
  values, only even, and possibly has even bigger step (176/2?), that makes
  its lower bits very bad entropy source, leaving half of taskqueues unused.
  Switch to sbinuptime(), closer to upstreams, mitigates the problem by the
  rate conversion working as kind of hash function.  In case that is somehow
  not enough (timer rate is too low or too divisible) mix in curcpu.

Modified:
  stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==============================================================================
--- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Thu Mar 14 00:57:54 2019	(r345121)
+++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Thu Mar 14 00:58:39 2019	(r345122)
@@ -1070,7 +1070,8 @@ spa_taskq_dispatch_ent(spa_t *spa, zio_type_t t, zio_t
 		tq = tqs->stqs_taskq[0];
 	} else {
 #ifdef _KERNEL
-		tq = tqs->stqs_taskq[cpu_ticks() % tqs->stqs_count];
+		tq = tqs->stqs_taskq[(u_int)(sbinuptime() + curcpu) %
+		    tqs->stqs_count];
 #else
 		tq = tqs->stqs_taskq[gethrtime() % tqs->stqs_count];
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903140058.x2E0wdqD082710>