Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix most zfs_arc_* mod params not actually being modifiable at runtime #8463

Merged

Conversation

jgottula
Copy link
Contributor

@jgottula jgottula commented Feb 27, 2019

Motivation and Context

Fix for #8405.

Description

Most of the zfs_arc_* module parameters do not have their values used by
the ARC code directly. Instead, there is a function, arc_tuning_update,
which is called during module initialization and periodically
thereafter, whose job is to fetch the module parameter values, clamp/
limit them appropriately, and then assign those values to a separate set
of internal variables that are actually referenced by the ARC code.

Commit 3ec34e5 featured an overhaul of arc_reclaim_thread, which is the
former location where the post-init-time calls to arc_tuning_update
would occur. The rework split the work previously done by the
arc_reclaim_thread into a pair of replacement threads; and
unfortunately, the call to arc_tuning_update fell through the cracks and
was lost in the reorganization.

This meant that changing almost any ARC-related zfs module parameter via
/sys/module/zfs/parameters/ would result in the module parameter value
itself appearing to change; however the modification would not actually
propagate to the ARC code and have any real effect.

This commit reinstates the post-init-time call to arc_tuning_update. It
is now called during arc_adjust_cb_check; this should be equivalent to
its former call location in arc_reclaim_thread.

How Has This Been Tested?

Has not been tested yet.

I plan to integrate this into my own zfs builds today or tomorrow to give it a quick test.

I've done some brief testing now which looked fine overall; see my comment below.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

Most of the zfs_arc_* module parameters do not have their values used by
the ARC code directly. Instead, there is a function, arc_tuning_update,
which is called during module initialization and periodically
thereafter, whose job is to fetch the module parameter values, clamp/
limit them appropriately, and then assign those values to a separate set
of internal variables that are actually referenced by the ARC code.

Commit 3ec34e5 featured an overhaul of arc_reclaim_thread, which is the
former location where the post-init-time calls to arc_tuning_update
would occur. The rework split the work previously done by the
arc_reclaim_thread into a pair of replacement threads; and
unfortunately, the call to arc_tuning_update fell through the cracks and
was lost in the reorganization.

This meant that changing almost any ARC-related zfs module parameter via
/sys/module/zfs/parameters/ would result in the module parameter value
itself appearing to change; however the modification would not actually
propagate to the ARC code and have any real effect.

This commit reinstates the post-init-time call to arc_tuning_update. It
is now called during arc_adjust_cb_check; this should be equivalent to
its former call location in arc_reclaim_thread.

Signed-off-by: Justin Gottula <justin@jgottula.com>
@jgottula
Copy link
Contributor Author

I've now had an opportunity to do a quick test. I used an Arch Linux system that previously had the master branch from ~2 weeks ago installed on it, and I compiled the latest master with this patch incorporated in and tried it out.

Setting module parameters like zfs_arc_max does indeed take effect now (as seen in /proc/spl/kstat/zfs/arcstats). Sometimes it seemed a bit sluggish to decide to read in the new parameter values; so I'm not sure if maybe it updates them less often now than it did back in the old code. (Didn't have an old build handy for comparison on that, so I really couldn't say whether it's significantly different.)

There weren't any crashes or any other indications of anything being majorly wrong.

@codecov
Copy link

codecov bot commented Feb 28, 2019

Codecov Report

Merging #8463 into master will decrease coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8463      +/-   ##
==========================================
- Coverage   78.62%   78.57%   -0.06%     
==========================================
  Files         380      380              
  Lines      116002   116003       +1     
==========================================
- Hits        91207    91147      -60     
- Misses      24795    24856      +61
Flag Coverage Δ
#kernel 79.13% <100%> (+0.11%) ⬆️
#user 67.27% <100%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6af7ba4...38e7c18. Read the comment docs.

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this fix. The timing here is the same as the only version so it should be just as sluggish as before. But if you're feeling ambitious this could be done by switching the relevant module options to use module_param_call instead of module_param. This would allow arc_tuning_update() to be run immediately on demand. A good example of this is the spa_slop_shift module option in module/zfs/spa_misc.c.

Copy link
Contributor

@tonyhutter tonyhutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks fine, but I agree that module_param_call would be a better approach.

@richardelling
Copy link
Contributor

Since you were able to test by hand, how about adding a ZTS test so that future regressions are avoided? This would be a very simple ZTS test, much simpler than most because there is nothing required other than zfs module load (no need to create pools). If you need help, please ask.

@behlendorf
Copy link
Contributor

A test case would be good. The best place to put it would be in tests/zfs-tests/tests/functional/arc/ we already have 2 basic tests for the dbufs and dbufstats there.

@behlendorf
Copy link
Contributor

I'd suggest we go ahead and merge this as-is to address the immediate issue. We can follow up time permitting with the suggested enhancements.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Mar 12, 2019
@behlendorf behlendorf merged commit cffa837 into openzfs:master Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants