summaryrefslogtreecommitdiffstats
path: root/module/zfs/multilist.c
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2017-02-15 15:49:33 -0800
committerBrian Behlendorf <[email protected]>2017-02-15 15:49:33 -0800
commitc30e58c4628de46c36870cdedea9052711092a85 (patch)
tree5f98615d10e325a5d006c6c7e24a0e96cdd61223 /module/zfs/multilist.c
parent3d3fe9f9bb4364718cb8c54d8c86bccc84ae3141 (diff)
zfs_arc_num_sublists_per_state should be common to all multilists
The global tunable zfs_arc_num_sublists_per_state is used by the ARC and the dbuf cache, and other users are planned. We should change this tunable to be common to all multilists. This tuning may be overridden on a per-multilist basis. Reviewed-by: Pavel Zakharov <[email protected]> Reviewed-by: Dan Kimmel <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matthew Ahrens <[email protected]> Closes #5764
Diffstat (limited to 'module/zfs/multilist.c')
-rw-r--r--module/zfs/multilist.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/module/zfs/multilist.c b/module/zfs/multilist.c
index e02a4bae3..fa927b43b 100644
--- a/module/zfs/multilist.c
+++ b/module/zfs/multilist.c
@@ -13,7 +13,7 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 2013, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2013, 2017 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -24,6 +24,12 @@
#include <sys/spa.h>
/*
+ * This overrides the number of sublists in each multilist_t, which defaults
+ * to the number of CPUs in the system (see multilist_create()).
+ */
+int zfs_multilist_num_sublists = 0;
+
+/*
* Given the object contained on the list, return a pointer to the
* object's multilist_node_t structure it contains.
*/
@@ -62,9 +68,9 @@ multilist_d2l(multilist_t *ml, void *obj)
* requirement, but a general rule of thumb in order to garner the
* best multi-threaded performance out of the data structure.
*/
-void
-multilist_create(multilist_t *ml, size_t size, size_t offset, unsigned int num,
- multilist_sublist_index_func_t *index_func)
+static void
+multilist_create_impl(multilist_t *ml, size_t size, size_t offset,
+ unsigned int num, multilist_sublist_index_func_t *index_func)
{
int i;
@@ -91,6 +97,26 @@ multilist_create(multilist_t *ml, size_t size, size_t offset, unsigned int num,
}
/*
+ * Initialize a new sublist, using the default number of sublists
+ * (the number of CPUs, or at least 4, or the tunable
+ * zfs_multilist_num_sublists).
+ */
+void
+multilist_create(multilist_t *ml, size_t size, size_t offset,
+ multilist_sublist_index_func_t *index_func)
+{
+ int num_sublists;
+
+ if (zfs_multilist_num_sublists > 0) {
+ num_sublists = zfs_multilist_num_sublists;
+ } else {
+ num_sublists = MAX(boot_ncpus, 4);
+ }
+
+ multilist_create_impl(ml, size, offset, num_sublists, index_func);
+}
+
+/*
* Destroy the given multilist object, and free up any memory it holds.
*/
void
@@ -373,3 +399,14 @@ multilist_link_active(multilist_node_t *link)
{
return (list_link_active(link));
}
+
+#if defined(_KERNEL) && defined(HAVE_SPL)
+
+/* BEGIN CSTYLED */
+
+module_param(zfs_multilist_num_sublists, int, 0644);
+MODULE_PARM_DESC(zfs_multilist_num_sublists,
+ "Number of sublists used in each multilist");
+
+/* END CSTYLED */
+#endif