Skip to content

Commit aa9af22

Browse files
committed
Update all default taskq settings
Over the years the default values for the taskqs used on Linux have differed slightly from illumos. In the vast majority of cases this was done to avoid creating an obnoxious number of idle threads which would pollute the process listing. With the addition of support for dynamic taskqs all multi-threaded queues should be created as dynamic taskqs. This allows us to get the best of both worlds. * The illumos default values for the I/O pipeline can be restored. These values are known to work well for most workloads. The only exception is the zio write interrupt taskq which is changed to ZTI_P(12, 8). At least under Linux more threads has been shown to improve performance, see commit 7e55f4e. * Reduces the number of idle threads on the system when it's not under heavy load. The maximum number of threads will only be created when they are required. * Remove the vdev_file_taskq and rely on the system_taskq instead which is now dynamic and may have up to 64-threads. Again this brings us back inline with upstream. * Tasks dispatched with taskq_dispatch_ent() are allowed to use dynamic taskqs. The Linux taskq implementation supports this. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tim Chase <tim@chase2k.com> Closes #3507
1 parent ef56b07 commit aa9af22

File tree

10 files changed

+12
-37
lines changed

10 files changed

+12
-37
lines changed

include/sys/vdev_file.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#ifndef _SYS_VDEV_FILE_H
2828
#define _SYS_VDEV_FILE_H
2929

30-
31-
3230
#include <sys/vdev.h>
3331

3432
#ifdef __cplusplus
@@ -39,9 +37,6 @@ typedef struct vdev_file {
3937
vnode_t *vf_vnode;
4038
} vdev_file_t;
4139

42-
extern void vdev_file_init(void);
43-
extern void vdev_file_fini(void);
44-
4540
#ifdef __cplusplus
4641
}
4742
#endif

lib/libzpool/taskq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags,
178178
taskq_ent_t *t)
179179
{
180180
ASSERT(func != NULL);
181-
ASSERT(!(tq->tq_flags & TASKQ_DYNAMIC));
182181

183182
/*
184183
* Mark it as a prealloc'd task. This is important

module/zfs/arc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5002,7 +5002,7 @@ arc_init(void)
50025002
bzero(&arc_eviction_hdr, sizeof (arc_buf_hdr_t));
50035003

50045004
arc_prune_taskq = taskq_create("arc_prune", max_ncpus, minclsyspri,
5005-
max_ncpus, INT_MAX, TASKQ_PREPOPULATE);
5005+
max_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
50065006

50075007
arc_ksp = kstat_create("zfs", 0, "arcstats", "misc", KSTAT_TYPE_NAMED,
50085008
sizeof (arc_stats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL);

module/zfs/dsl_pool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ dsl_pool_open_impl(spa_t *spa, uint64_t txg)
171171
cv_init(&dp->dp_spaceavail_cv, NULL, CV_DEFAULT, NULL);
172172

173173
dp->dp_iput_taskq = taskq_create("z_iput", max_ncpus, minclsyspri,
174-
max_ncpus * 8, INT_MAX, TASKQ_PREPOPULATE);
174+
max_ncpus * 8, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
175175

176176
return (dp);
177177
}

module/zfs/metaslab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ metaslab_group_create(metaslab_class_t *mc, vdev_t *vd)
492492
mg->mg_activation_count = 0;
493493

494494
mg->mg_taskq = taskq_create("metaslab_group_taskq", metaslab_load_pct,
495-
minclsyspri, 10, INT_MAX, TASKQ_THREADS_CPU_PCT);
495+
minclsyspri, 10, INT_MAX, TASKQ_THREADS_CPU_PCT | TASKQ_DYNAMIC);
496496

497497
return (mg);
498498
}

module/zfs/spa.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ static const char *const zio_taskq_types[ZIO_TASKQ_TYPES] = {
127127
const zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES] = {
128128
/* ISSUE ISSUE_HIGH INTR INTR_HIGH */
129129
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* NULL */
130-
{ ZTI_N(8), ZTI_NULL, ZTI_BATCH, ZTI_NULL }, /* READ */
131-
{ ZTI_BATCH, ZTI_N(5), ZTI_N(16), ZTI_N(5) }, /* WRITE */
132-
{ ZTI_P(4, 8), ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* FREE */
130+
{ ZTI_N(8), ZTI_NULL, ZTI_P(12, 8), ZTI_NULL }, /* READ */
131+
{ ZTI_BATCH, ZTI_N(5), ZTI_P(12, 8), ZTI_N(5) }, /* WRITE */
132+
{ ZTI_P(12, 8), ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* FREE */
133133
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* CLAIM */
134134
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* IOCTL */
135135
};
@@ -844,7 +844,7 @@ spa_taskqs_init(spa_t *spa, zio_type_t t, zio_taskq_type_t q)
844844
uint_t count = ztip->zti_count;
845845
spa_taskqs_t *tqs = &spa->spa_zio_taskq[t][q];
846846
char name[32];
847-
uint_t i, flags = 0;
847+
uint_t i, flags = TASKQ_DYNAMIC;
848848
boolean_t batch = B_FALSE;
849849

850850
if (mode == ZTI_MODE_NULL) {

module/zfs/spa_misc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,6 @@ spa_init(int mode)
18291829
dmu_init();
18301830
zil_init();
18311831
vdev_cache_stat_init();
1832-
vdev_file_init();
18331832
zfs_prop_init();
18341833
zpool_prop_init();
18351834
zpool_feature_init();
@@ -1844,7 +1843,6 @@ spa_fini(void)
18441843

18451844
spa_evict_all();
18461845

1847-
vdev_file_fini();
18481846
vdev_cache_stat_fini();
18491847
zil_fini();
18501848
dmu_fini();

module/zfs/txg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@ txg_dispatch_callbacks(dsl_pool_t *dp, uint64_t txg)
445445
* Commit callback taskq hasn't been created yet.
446446
*/
447447
tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb",
448-
100, minclsyspri, max_ncpus, INT_MAX,
449-
TASKQ_THREADS_CPU_PCT | TASKQ_PREPOPULATE);
448+
max_ncpus, minclsyspri, max_ncpus, max_ncpus * 2,
449+
TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
450450
}
451451

452452
cb_list = kmem_alloc(sizeof (list_t), KM_SLEEP);

module/zfs/vdev_file.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
* Virtual device vector for files.
3737
*/
3838

39-
static taskq_t *vdev_file_taskq;
40-
4139
static void
4240
vdev_file_hold(vdev_t *vd)
4341
{
@@ -200,7 +198,7 @@ vdev_file_io_start(zio_t *zio)
200198
* the sync must be dispatched to a different context.
201199
*/
202200
if (spl_fstrans_check()) {
203-
VERIFY3U(taskq_dispatch(vdev_file_taskq,
201+
VERIFY3U(taskq_dispatch(system_taskq,
204202
vdev_file_io_fsync, zio, TQ_SLEEP), !=, 0);
205203
return;
206204
}
@@ -216,7 +214,7 @@ vdev_file_io_start(zio_t *zio)
216214
return;
217215
}
218216

219-
VERIFY3U(taskq_dispatch(vdev_file_taskq, vdev_file_io_strategy, zio,
217+
VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, zio,
220218
TQ_SLEEP), !=, 0);
221219
}
222220

@@ -239,21 +237,6 @@ vdev_ops_t vdev_file_ops = {
239237
B_TRUE /* leaf vdev */
240238
};
241239

242-
void
243-
vdev_file_init(void)
244-
{
245-
vdev_file_taskq = taskq_create("vdev_file_taskq", 100, minclsyspri,
246-
max_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_THREADS_CPU_PCT);
247-
248-
VERIFY(vdev_file_taskq);
249-
}
250-
251-
void
252-
vdev_file_fini(void)
253-
{
254-
taskq_destroy(vdev_file_taskq);
255-
}
256-
257240
/*
258241
* From userland we access disks just like files.
259242
*/

module/zfs/zvol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ zvol_init(void)
16321632
mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL);
16331633

16341634
zvol_taskq = taskq_create(ZVOL_DRIVER, zvol_threads, maxclsyspri,
1635-
zvol_threads, INT_MAX, TASKQ_PREPOPULATE);
1635+
zvol_threads * 2, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
16361636
if (zvol_taskq == NULL) {
16371637
printk(KERN_INFO "ZFS: taskq_create() failed\n");
16381638
error = -ENOMEM;

0 commit comments

Comments
 (0)