Skip to content

Commit

Permalink
Update all default taskq settings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
behlendorf committed Jun 25, 2015
1 parent ef56b07 commit aa9af22
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 37 deletions.
5 changes: 0 additions & 5 deletions include/sys/vdev_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#ifndef _SYS_VDEV_FILE_H
#define _SYS_VDEV_FILE_H



#include <sys/vdev.h>

#ifdef __cplusplus
Expand All @@ -39,9 +37,6 @@ typedef struct vdev_file {
vnode_t *vf_vnode;
} vdev_file_t;

extern void vdev_file_init(void);
extern void vdev_file_fini(void);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 0 additions & 1 deletion lib/libzpool/taskq.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags,
taskq_ent_t *t)
{
ASSERT(func != NULL);
ASSERT(!(tq->tq_flags & TASKQ_DYNAMIC));

/*
* Mark it as a prealloc'd task. This is important
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5002,7 +5002,7 @@ arc_init(void)
bzero(&arc_eviction_hdr, sizeof (arc_buf_hdr_t));

arc_prune_taskq = taskq_create("arc_prune", max_ncpus, minclsyspri,
max_ncpus, INT_MAX, TASKQ_PREPOPULATE);
max_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC);

arc_ksp = kstat_create("zfs", 0, "arcstats", "misc", KSTAT_TYPE_NAMED,
sizeof (arc_stats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL);
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dsl_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ dsl_pool_open_impl(spa_t *spa, uint64_t txg)
cv_init(&dp->dp_spaceavail_cv, NULL, CV_DEFAULT, NULL);

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

return (dp);
}
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/metaslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ metaslab_group_create(metaslab_class_t *mc, vdev_t *vd)
mg->mg_activation_count = 0;

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

return (mg);
}
Expand Down
8 changes: 4 additions & 4 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ static const char *const zio_taskq_types[ZIO_TASKQ_TYPES] = {
const zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES] = {
/* ISSUE ISSUE_HIGH INTR INTR_HIGH */
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* NULL */
{ ZTI_N(8), ZTI_NULL, ZTI_BATCH, ZTI_NULL }, /* READ */
{ ZTI_BATCH, ZTI_N(5), ZTI_N(16), ZTI_N(5) }, /* WRITE */
{ ZTI_P(4, 8), ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* FREE */
{ ZTI_N(8), ZTI_NULL, ZTI_P(12, 8), ZTI_NULL }, /* READ */
{ ZTI_BATCH, ZTI_N(5), ZTI_P(12, 8), ZTI_N(5) }, /* WRITE */
{ ZTI_P(12, 8), ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* FREE */
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* CLAIM */
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* IOCTL */
};
Expand Down Expand Up @@ -844,7 +844,7 @@ spa_taskqs_init(spa_t *spa, zio_type_t t, zio_taskq_type_t q)
uint_t count = ztip->zti_count;
spa_taskqs_t *tqs = &spa->spa_zio_taskq[t][q];
char name[32];
uint_t i, flags = 0;
uint_t i, flags = TASKQ_DYNAMIC;
boolean_t batch = B_FALSE;

if (mode == ZTI_MODE_NULL) {
Expand Down
2 changes: 0 additions & 2 deletions module/zfs/spa_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,6 @@ spa_init(int mode)
dmu_init();
zil_init();
vdev_cache_stat_init();
vdev_file_init();
zfs_prop_init();
zpool_prop_init();
zpool_feature_init();
Expand All @@ -1844,7 +1843,6 @@ spa_fini(void)

spa_evict_all();

vdev_file_fini();
vdev_cache_stat_fini();
zil_fini();
dmu_fini();
Expand Down
4 changes: 2 additions & 2 deletions module/zfs/txg.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ txg_dispatch_callbacks(dsl_pool_t *dp, uint64_t txg)
* Commit callback taskq hasn't been created yet.
*/
tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb",
100, minclsyspri, max_ncpus, INT_MAX,
TASKQ_THREADS_CPU_PCT | TASKQ_PREPOPULATE);
max_ncpus, minclsyspri, max_ncpus, max_ncpus * 2,
TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
}

cb_list = kmem_alloc(sizeof (list_t), KM_SLEEP);
Expand Down
21 changes: 2 additions & 19 deletions module/zfs/vdev_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
* Virtual device vector for files.
*/

static taskq_t *vdev_file_taskq;

static void
vdev_file_hold(vdev_t *vd)
{
Expand Down Expand Up @@ -200,7 +198,7 @@ vdev_file_io_start(zio_t *zio)
* the sync must be dispatched to a different context.
*/
if (spl_fstrans_check()) {
VERIFY3U(taskq_dispatch(vdev_file_taskq,
VERIFY3U(taskq_dispatch(system_taskq,
vdev_file_io_fsync, zio, TQ_SLEEP), !=, 0);
return;
}
Expand All @@ -216,7 +214,7 @@ vdev_file_io_start(zio_t *zio)
return;
}

VERIFY3U(taskq_dispatch(vdev_file_taskq, vdev_file_io_strategy, zio,
VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, zio,
TQ_SLEEP), !=, 0);
}

Expand All @@ -239,21 +237,6 @@ vdev_ops_t vdev_file_ops = {
B_TRUE /* leaf vdev */
};

void
vdev_file_init(void)
{
vdev_file_taskq = taskq_create("vdev_file_taskq", 100, minclsyspri,
max_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_THREADS_CPU_PCT);

VERIFY(vdev_file_taskq);
}

void
vdev_file_fini(void)
{
taskq_destroy(vdev_file_taskq);
}

/*
* From userland we access disks just like files.
*/
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ zvol_init(void)
mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL);

zvol_taskq = taskq_create(ZVOL_DRIVER, zvol_threads, maxclsyspri,
zvol_threads, INT_MAX, TASKQ_PREPOPULATE);
zvol_threads * 2, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
if (zvol_taskq == NULL) {
printk(KERN_INFO "ZFS: taskq_create() failed\n");
error = -ENOMEM;
Expand Down

0 comments on commit aa9af22

Please sign in to comment.