Skip to content

Commit d5ee03b

Browse files
authored
SSV-24185: Fix the number of zvol I/O threads to align with 50% of the maximum available logical CPUs. (#99)
1 parent 47b53a9 commit d5ee03b

File tree

10 files changed

+31
-18
lines changed

10 files changed

+31
-18
lines changed

include/os/windows/zfs/sys/kstat_windows.h

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ typedef struct windows_kstat {
149149
kstat_named_t zfs_total_memory_limit;
150150
kstat_named_t zfs_removal_suspend_progress;
151151
kstat_named_t cpu_avx_supported;
152+
kstat_named_t zvol_io_threads;
152153
} windows_kstat_t;
153154

154155

@@ -259,6 +260,7 @@ extern uint64_t zfs_initialize_value;
259260
extern int zfs_autoimport_disable;
260261
extern int zfs_removal_suspend_progress;
261262
extern int cpu_avx_supported;
263+
extern int zvol_threads;
262264

263265
int kstat_windows_init(void *);
264266
void kstat_windows_fini(void);

module/os/windows/zfs/arc_os.c

+2
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ arc_kstat_update_windows(kstat_t *ksp, int rw)
695695
zfs_arc_p_min_shift = ks->arc_zfs_arc_p_min_shift.value.ui64;
696696
zfs_arc_average_blocksize =
697697
ks->arc_zfs_arc_average_blocksize.value.ui64;
698+
zvol_threads = ks->zvol_io_threads.value.ui32;
698699

699700
#ifdef _KERNEL
700701
if (ks->zfs_total_memory_limit.value.ui64 > total_memory &&
@@ -729,6 +730,7 @@ arc_kstat_update_windows(kstat_t *ksp, int rw)
729730
ks->arc_zfs_arc_p_min_shift.value.ui64 = zfs_arc_p_min_shift;
730731
ks->arc_zfs_arc_average_blocksize.value.ui64 =
731732
zfs_arc_average_blocksize;
733+
ks->zvol_io_threads.value.ui32 = zvol_threads;
732734

733735
#ifdef _KERNEL
734736
ks->zfs_total_memory_limit.value.ui64 = total_memory;

module/os/windows/zfs/zfs_kstat_windows.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ windows_kstat_t windows_kstat = {
172172
{ "zfs_autoimport_disable", KSTAT_DATA_UINT64 },
173173
{ "zfs_total_memory_limit", KSTAT_DATA_UINT64 },
174174
{ "zfs_removal_suspend_progress", KSTAT_DATA_INT32 },
175-
{ "cpu_avx_supported", KSTAT_DATA_UINT32 }
175+
{ "cpu_avx_supported", KSTAT_DATA_UINT32 },
176+
{ "zvol_io_threads", KSTAT_DATA_UINT32 }
176177
};
177178

178179

@@ -382,7 +383,6 @@ windows_kstat_update(kstat_t *ksp, int rw)
382383
ks->zfs_removal_suspend_progress.value.i32;
383384
cpu_avx_supported =
384385
ks->cpu_avx_supported.value.ui32;
385-
386386
} else {
387387

388388
/* kstat READ */
@@ -571,6 +571,8 @@ windows_kstat_update(kstat_t *ksp, int rw)
571571
zfs_removal_suspend_progress;
572572
ks->cpu_avx_supported.value.ui32 =
573573
cpu_avx_supported;
574+
ks->zvol_io_threads.value.ui32 =
575+
zvol_threads;
574576
}
575577
arc_kstat_update_windows(ksp, rw);
576578
return (0);

module/os/windows/zfs/zvol_os.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static uint32_t zvol_major = ZVOL_MAJOR;
4545
unsigned int zvol_request_sync = 0;
4646
unsigned int zvol_prefetch_bytes = (128 * 1024);
4747
unsigned long zvol_max_discard_blocks = 16384;
48-
unsigned int zvol_threads = 32;
48+
int zvol_threads = 0;
4949

5050
taskq_t *zvol_taskq;
5151

@@ -1028,14 +1028,21 @@ const static zvol_platform_ops_t zvol_windows_ops = {
10281028
int
10291029
zvol_init(void)
10301030
{
1031-
int threads = MIN(MAX(zvol_threads, 1), 1024);
1031+
int logical_ncpu_to_use = boot_ncpus / 2; // boot_ncpus is derived from KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS)
10321032

1033+
int threads = MIN(MAX((zvol_threads ? zvol_threads: logical_ncpu_to_use), 1), 1024);
1034+
1035+
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL,
1036+
"%s: number of zvol taskq threads to be created: %d, registry value: %d ncpus: %d\n",
1037+
__func__, threads, zvol_threads, boot_ncpus));
10331038
zvol_taskq = taskq_create(ZVOL_DRIVER, threads, maxclsyspri,
10341039
threads * 2, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
10351040
if (zvol_taskq == NULL) {
10361041
return (-ENOMEM);
10371042
}
10381043

1044+
zvol_threads = threads; // Update it so that kstat gets the current value
1045+
10391046
zvol_init_impl();
10401047
zvol_register_ops(&zvol_windows_ops);
10411048
return (0);

module/zfs/dbuf.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,8 @@ dbuf_read_verify_dnode_crypt(dmu_buf_impl_t *db, uint32_t flags)
14611461

14621462
DB_DNODE_EXIT(db);
14631463

1464-
TraceEvent(err > 0 ? 2:8, "%s:%d: Returning %d\n",
1465-
__func__, __LINE__, err);
1464+
// TraceEvent(err > 0 ? 2:8, "%s:%d: Returning %d\n",
1465+
// __func__, __LINE__, err);
14661466

14671467
return (err);
14681468
}
@@ -1565,8 +1565,8 @@ dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags,
15651565
mutex_exit(&db->db_mtx);
15661566
dmu_buf_unlock_parent(db, dblt, tag);
15671567

1568-
TraceEvent(err > 0 ? 2 : 8, "%s:%d: Returning %d\n",
1569-
__func__, __LINE__, err);
1568+
//TraceEvent(err > 0 ? 2 : 8, "%s:%d: Returning %d\n",
1569+
// __func__, __LINE__, err);
15701570

15711571
return (err);
15721572
}

module/zfs/dsl_crypt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ spa_keystore_wkey_hold_dd(spa_t *spa, dsl_dir_t *dd, void *tag,
437437
rw_exit(&spa->spa_keystore.sk_wkeys_lock);
438438

439439
*wkey_out = NULL;
440-
TraceEvent(ret > 0 ? 2 : 8, "%s:%d: Returning %d\n",
441-
__func__, __LINE__, ret);
440+
//TraceEvent(ret > 0 ? 2 : 8, "%s:%d: Returning %d\n",
441+
// __func__, __LINE__, ret);
442442

443443
return (ret);
444444
}

module/zfs/space_map.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ space_map_iterate(space_map_t *sm, uint64_t end, sm_cb_t callback, void *arg)
191191
dmu_buf_rele(db, FTAG);
192192
}
193193

194-
TraceEvent(error > 0 ? 2 : 8, "%s:%d: Returning %d\n",
195-
__func__, __LINE__, error);
194+
//TraceEvent(error > 0 ? 2 : 8, "%s:%d: Returning %d\n",
195+
// __func__, __LINE__, error);
196196
return (error);
197197
}
198198

module/zfs/zap.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ zap_deref_leaf(zap_t *zap, uint64_t h, dmu_tx_t *tx, krw_t lt, zap_leaf_t **lp)
640640
ZAP_HASH_IDX(h, zap_leaf_phys(*lp)->l_hdr.lh_prefix_len) ==
641641
zap_leaf_phys(*lp)->l_hdr.lh_prefix);
642642

643-
TraceEvent(err > 0 ? 2 : 8, "%s:%d: Returning %d\n",
644-
__func__, __LINE__, err);
643+
// TraceEvent(err > 0 ? 2 : 8, "%s:%d: Returning %d\n",
644+
// __func__, __LINE__, err);
645645
return (err);
646646
}
647647

module/zfs/zap_micro.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ zap_lockdir_by_dnode(dnode_t *dn, dmu_tx_t *tx,
611611
dmu_buf_rele(db, tag);
612612
}
613613

614-
TraceEvent(err > 0 ? 2 : 8, "%s:%d: Returning %d\n",
615-
__func__, __LINE__, err);
614+
//TraceEvent(err > 0 ? 2 : 8, "%s:%d: Returning %d\n",
615+
// __func__, __LINE__, err);
616616
return (err);
617617
}
618618

module/zfs/zfs_ioctl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -7494,8 +7494,8 @@ pool_status_check(const char *name, zfs_ioc_namecheck_t type,
74947494
spa_close(spa, FTAG);
74957495
}
74967496

7497-
TraceEvent(error > 0 ? 2 : 8, "%s:%d: Returning with error %d\n",
7498-
__func__, __LINE__, error);
7497+
//TraceEvent(error > 0 ? 2 : 8, "%s:%d: Returning with error %d\n",
7498+
// __func__, __LINE__, error);
74997499
return (error);
75007500
}
75017501

0 commit comments

Comments
 (0)