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 <pavel.zakharov@delphix.com>
Reviewed-by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #5764
This commit is contained in:
Matthew Ahrens
2017-02-15 15:49:33 -08:00
committed by Brian Behlendorf
parent 3d3fe9f9bb
commit c30e58c462
6 changed files with 58 additions and 37 deletions
+41 -4
View File
@@ -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>
@@ -23,6 +23,12 @@
/* needed for spa_get_random() */
#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;
@@ -90,6 +96,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.
*/
@@ -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