svn commit: r344903 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Alexander Motin
mav at FreeBSD.org
Thu Mar 7 22:56:40 UTC 2019
Author: mav
Date: Thu Mar 7 22:56:39 2019
New Revision: 344903
URL: https://svnweb.freebsd.org/changeset/base/344903
Log:
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.
MFC after: 1 week
Modified:
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Thu Mar 7 22:51:58 2019 (r344902)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Thu Mar 7 22:56:39 2019 (r344903)
@@ -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
More information about the svn-src-all
mailing list