Fix for ARC sysctls ignored at runtime
This change leverage module_param_call() to run arc_tuning_update()
immediately after the ARC tunable has been updated as suggested in
cffa837
code review.
A simple test case is added to the ZFS Test Suite to prevent future
regressions in functionality.
This is a backport of #9489 provided from:
https://github.com/zfsonlinux/zfs/pull/9776#issuecomment-569418370
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
This commit is contained in:
parent
9791683901
commit
e05c965d5b
|
@ -296,6 +296,7 @@
|
|||
#include <sys/vmsystm.h>
|
||||
#include <sys/zpl.h>
|
||||
#include <linux/page_compat.h>
|
||||
#include <linux/mod_compat.h>
|
||||
#endif
|
||||
#include <sys/callb.h>
|
||||
#include <sys/kstat.h>
|
||||
|
@ -7554,8 +7555,10 @@ arc_state_multilist_index_func(multilist_t *ml, void *obj)
|
|||
|
||||
/*
|
||||
* Called during module initialization and periodically thereafter to
|
||||
* apply reasonable changes to the exposed performance tunings. Non-zero
|
||||
* zfs_* values which differ from the currently set values will be applied.
|
||||
* apply reasonable changes to the exposed performance tunings. Can also be
|
||||
* called explicitly by param_set_arc_*() functions when ARC tunables are
|
||||
* updated manually. Non-zero zfs_* values which differ from the currently set
|
||||
* values will be applied.
|
||||
*/
|
||||
static void
|
||||
arc_tuning_update(void)
|
||||
|
@ -9389,6 +9392,35 @@ l2arc_stop(void)
|
|||
}
|
||||
|
||||
#if defined(_KERNEL)
|
||||
static int
|
||||
param_set_arc_long(const char *buf, zfs_kernel_param_t *kp)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = param_set_long(buf, kp);
|
||||
if (error < 0)
|
||||
return (SET_ERROR(error));
|
||||
|
||||
arc_tuning_update();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
param_set_arc_int(const char *buf, zfs_kernel_param_t *kp)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = param_set_int(buf, kp);
|
||||
if (error < 0)
|
||||
return (SET_ERROR(error));
|
||||
|
||||
arc_tuning_update();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
EXPORT_SYMBOL(arc_buf_size);
|
||||
EXPORT_SYMBOL(arc_write);
|
||||
EXPORT_SYMBOL(arc_read);
|
||||
|
@ -9398,20 +9430,25 @@ EXPORT_SYMBOL(arc_add_prune_callback);
|
|||
EXPORT_SYMBOL(arc_remove_prune_callback);
|
||||
|
||||
/* BEGIN CSTYLED */
|
||||
module_param(zfs_arc_min, ulong, 0644);
|
||||
module_param_call(zfs_arc_min, param_set_arc_long, param_get_long,
|
||||
&zfs_arc_min, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_min, "Min arc size");
|
||||
|
||||
module_param(zfs_arc_max, ulong, 0644);
|
||||
module_param_call(zfs_arc_max, param_set_arc_long, param_get_long,
|
||||
&zfs_arc_max, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_max, "Max arc size");
|
||||
|
||||
module_param(zfs_arc_meta_limit, ulong, 0644);
|
||||
module_param_call(zfs_arc_meta_limit, param_set_arc_long, param_get_long,
|
||||
&zfs_arc_meta_limit, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_meta_limit, "Meta limit for arc size");
|
||||
|
||||
module_param(zfs_arc_meta_limit_percent, ulong, 0644);
|
||||
module_param_call(zfs_arc_meta_limit_percent, param_set_arc_long,
|
||||
param_get_long, &zfs_arc_meta_limit_percent, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_meta_limit_percent,
|
||||
"Percent of arc size for arc meta limit");
|
||||
|
||||
module_param(zfs_arc_meta_min, ulong, 0644);
|
||||
module_param_call(zfs_arc_meta_min, param_set_arc_long, param_get_long,
|
||||
&zfs_arc_meta_min, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_meta_min, "Min arc metadata");
|
||||
|
||||
module_param(zfs_arc_meta_prune, int, 0644);
|
||||
|
@ -9424,20 +9461,23 @@ MODULE_PARM_DESC(zfs_arc_meta_adjust_restarts,
|
|||
module_param(zfs_arc_meta_strategy, int, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_meta_strategy, "Meta reclaim strategy");
|
||||
|
||||
module_param(zfs_arc_grow_retry, int, 0644);
|
||||
module_param_call(zfs_arc_grow_retry, param_set_arc_int, param_get_int,
|
||||
&zfs_arc_grow_retry, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_grow_retry, "Seconds before growing arc size");
|
||||
|
||||
module_param(zfs_arc_p_dampener_disable, int, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_p_dampener_disable, "disable arc_p adapt dampener");
|
||||
|
||||
module_param(zfs_arc_shrink_shift, int, 0644);
|
||||
module_param_call(zfs_arc_shrink_shift, param_set_arc_int, param_get_int,
|
||||
&zfs_arc_shrink_shift, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_shrink_shift, "log2(fraction of arc to reclaim)");
|
||||
|
||||
module_param(zfs_arc_pc_percent, uint, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_pc_percent,
|
||||
"Percent of pagecache to reclaim arc to");
|
||||
|
||||
module_param(zfs_arc_p_min_shift, int, 0644);
|
||||
module_param_call(zfs_arc_p_min_shift, param_set_arc_int, param_get_int,
|
||||
&zfs_arc_p_min_shift, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_p_min_shift, "arc_c shift to calc min/max arc_p");
|
||||
|
||||
module_param(zfs_arc_average_blocksize, int, 0444);
|
||||
|
@ -9446,7 +9486,8 @@ MODULE_PARM_DESC(zfs_arc_average_blocksize, "Target average block size");
|
|||
module_param(zfs_compressed_arc_enabled, int, 0644);
|
||||
MODULE_PARM_DESC(zfs_compressed_arc_enabled, "Disable compressed arc buffers");
|
||||
|
||||
module_param(zfs_arc_min_prefetch_ms, int, 0644);
|
||||
module_param_call(zfs_arc_min_prefetch_ms, param_set_arc_int, param_get_int,
|
||||
&zfs_arc_min_prefetch_ms, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_min_prefetch_ms, "Min life of prefetch block in ms");
|
||||
|
||||
module_param(zfs_arc_min_prescient_prefetch_ms, int, 0644);
|
||||
|
@ -9480,14 +9521,17 @@ MODULE_PARM_DESC(l2arc_feed_again, "Turbo L2ARC warmup");
|
|||
module_param(l2arc_norw, int, 0644);
|
||||
MODULE_PARM_DESC(l2arc_norw, "No reads during writes");
|
||||
|
||||
module_param(zfs_arc_lotsfree_percent, int, 0644);
|
||||
module_param_call(zfs_arc_lotsfree_percent, param_set_arc_int, param_get_int,
|
||||
&zfs_arc_lotsfree_percent, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_lotsfree_percent,
|
||||
"System free memory I/O throttle in bytes");
|
||||
|
||||
module_param(zfs_arc_sys_free, ulong, 0644);
|
||||
module_param_call(zfs_arc_sys_free, param_set_arc_long, param_get_long,
|
||||
&zfs_arc_sys_free, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_sys_free, "System free memory target size in bytes");
|
||||
|
||||
module_param(zfs_arc_dnode_limit, ulong, 0644);
|
||||
module_param_call(zfs_arc_dnode_limit, param_set_arc_long, param_get_long,
|
||||
&zfs_arc_dnode_limit, 0644);
|
||||
MODULE_PARM_DESC(zfs_arc_dnode_limit, "Minimum bytes of dnodes in arc");
|
||||
|
||||
module_param(zfs_arc_dnode_limit_percent, ulong, 0644);
|
||||
|
|
|
@ -33,7 +33,8 @@ tests = ['alloc_class_001_pos', 'alloc_class_002_neg', 'alloc_class_003_pos',
|
|||
tags = ['functional', 'alloc_class']
|
||||
|
||||
[tests/functional/arc]
|
||||
tests = ['dbufstats_001_pos', 'dbufstats_002_pos', 'dbufstats_003_pos']
|
||||
tests = ['dbufstats_001_pos', 'dbufstats_002_pos', 'dbufstats_003_pos',
|
||||
'arcstats_runtime_tuning']
|
||||
tags = ['functional', 'arc']
|
||||
|
||||
[tests/functional/atime]
|
||||
|
|
|
@ -2,6 +2,7 @@ pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/arc
|
|||
dist_pkgdata_SCRIPTS = \
|
||||
cleanup.ksh \
|
||||
setup.ksh \
|
||||
arcstats_runtime_tuning.ksh \
|
||||
dbufstats_001_pos.ksh \
|
||||
dbufstats_002_pos.ksh \
|
||||
dbufstats_003_pos.ksh
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/ksh -p
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2019, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/perf/perf.shlib
|
||||
|
||||
function cleanup
|
||||
{
|
||||
# Set tunables to their recorded actual size and then to their original
|
||||
# value: this works for previously unconfigured tunables.
|
||||
log_must set_tunable64 zfs_arc_min "$MINSIZE"
|
||||
log_must set_tunable64 zfs_arc_min "$ZFS_ARC_MIN"
|
||||
log_must set_tunable64 zfs_arc_max "$MAXSIZE"
|
||||
log_must set_tunable64 zfs_arc_max "$ZFS_ARC_MAX"
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
ZFS_ARC_MAX="$(get_tunable zfs_arc_max)"
|
||||
ZFS_ARC_MIN="$(get_tunable zfs_arc_min)"
|
||||
MINSIZE="$(get_min_arc_size)"
|
||||
MAXSIZE="$(get_max_arc_size)"
|
||||
|
||||
log_assert "ARC tunables should be updated dynamically"
|
||||
|
||||
for size in $((MAXSIZE/4)) $((MAXSIZE/3)) $((MAXSIZE/2)) $MAXSIZE; do
|
||||
log_must set_tunable64 zfs_arc_max "$size"
|
||||
log_must test "$(get_max_arc_size)" == "$size"
|
||||
log_must set_tunable64 zfs_arc_min "$size"
|
||||
log_must test "$(get_min_arc_size)" == "$size"
|
||||
done
|
||||
|
||||
log_pass "ARC tunables can be updated dynamically"
|
|
@ -373,6 +373,23 @@ function get_directory
|
|||
echo $directory
|
||||
}
|
||||
|
||||
function get_min_arc_size
|
||||
{
|
||||
if is_linux; then
|
||||
typeset -l min_arc_size=`awk '$1 == "c_min" { print $3 }' \
|
||||
/proc/spl/kstat/zfs/arcstats`
|
||||
else
|
||||
typeset -l min_arc_size=$(dtrace -qn 'BEGIN {
|
||||
printf("%u\n", `arc_stats.arcstat_c_min.value.ui64);
|
||||
exit(0);
|
||||
}')
|
||||
fi
|
||||
|
||||
[[ $? -eq 0 ]] || log_fail "get_min_arc_size failed"
|
||||
|
||||
echo $min_arc_size
|
||||
}
|
||||
|
||||
function get_max_arc_size
|
||||
{
|
||||
if is_linux; then
|
||||
|
|
Loading…
Reference in New Issue