Sat Apr 11 16:32:07 2015 UTC ()
Fix ASSERT(x == y | z).  Interpret nthreads as pct when requested.

Reduces the number of threads created by zfs to a slightly less
insane value.

XXX This whole taskq business is questionable, and we really really
should not have copies of external code outside dist/ and without
vendor branches to record provenance and local changes.


(riastradh)
diff -r1.4 -r1.5 src/external/cddl/osnet/sys/kern/taskq.c

cvs diff -r1.4 -r1.5 src/external/cddl/osnet/sys/kern/taskq.c (expand / switch to context diff)
--- src/external/cddl/osnet/sys/kern/taskq.c 2015/04/11 00:13:04 1.4
+++ src/external/cddl/osnet/sys/kern/taskq.c 2015/04/11 16:32:07 1.5
@@ -1,4 +1,4 @@
-/*	$NetBSD: taskq.c,v 1.4 2015/04/11 00:13:04 riastradh Exp $	*/
+/*	$NetBSD: taskq.c,v 1.5 2015/04/11 16:32:07 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -905,7 +905,8 @@
 	uint_t bsize;	/* # of buckets - always power of 2 */
 
 	ASSERT(instance == 0);
-	ASSERT(flags == TASKQ_PREPOPULATE | TASKQ_NOINSTANCE);
+	ASSERT(!ISSET(flags, TASKQ_CPR_SAFE));
+	ASSERT(!ISSET(flags, TASKQ_DYNAMIC));
 
 	/*
 	 * TASKQ_CPR_SAFE and TASKQ_DYNAMIC flags are mutually exclusive.
@@ -919,7 +920,10 @@
 	ASSERT(bsize >= 1);
 	bsize = MIN(bsize, taskq_maxbuckets);
 
-	tq->tq_maxsize = nthreads;
+	ASSERT(!(flags & TASKQ_DYNAMIC));
+	if (flags & TASKQ_THREADS_CPU_PCT)
+		/* nthreads is % of CPUs we want to use.  */
+		nthreads = (ncpus*nthreads)/100;
 
 	(void) strncpy(tq->tq_name, name, TASKQ_NAMELEN + 1);
 	tq->tq_name[TASKQ_NAMELEN] = '\0';