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 ARC behavior on 32-bit systems #6734

Merged
merged 1 commit into from Oct 10, 2017

Conversation

behlendorf
Copy link
Contributor

@behlendorf behlendorf commented Oct 7, 2017

Description

With the addition of the ABD changes consumption of the virtual address space has been greatly reduced. This exposed an issue on CONFIG_HIGHMEM systems where free memory was being calculated incorrectly. Functionally this didn't cause any major problems prior to ABD because a lack of available virtual address space was used as an indicator of low memory.

This patch makes the following changes to address the issue andin the process realigns the code further with OpenZFS. There are no substantive changes in behavior for 64-bit systems.

  • Added CONFIG_HIGHMEM case to the arc_all_memory() and arc_free_memory() functions to only consider low memory pages on CONFIG_HIGHMEM systems.

  • The arc_free_memory() function was updated to return bytes instead of pages to be consistent with the other helper functions. In user space we make up some reasonable values since currently only testing is performed in this context.

  • Adds three new values to the arcstats kstat to provide visibility in to the ARC's assessment of the memory situation: memory_all_bytes, memory_free_bytes, and memory_available_bytes.

  • Added kmem_reap() call to arc_available_memory() for 32-bit builds to realign code with OpenZFS.

  • Reduced size of test file in /async_destroy_001_pos.ksh to speed up test case. Multiple txgs are still required.

  • Move vdevs used by zpool_clear_001_pos and zpool_upgrade_002_pos to TEST_BASE_DIR location to speed up test cases.

Motivation and Context

Resolve 32-bit testing failures when running the ZTS. The async_destroy_001_pos test was particularly good at triggering a low memory situation which could trigger the OOM killer. More broadly speaking these changes should bring increased stability to 32-bit platforms. Tuning is still required to achieve good performance when operating with an ARC that is only 100MB in size.

How Has This Been Tested?

Locally by running various stress tests and observing the system.

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:

  • My code follows the ZFS on Linux code style requirements.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commit messages are properly formatted and contain Signed-off-by.
  • Change has been approved by a ZFS on Linux member.

@behlendorf behlendorf force-pushed the async-destroy branch 3 times, most recently from 323b6bf to 5e09305 Compare October 8, 2017 17:14
@codecov
Copy link

codecov bot commented Oct 8, 2017

Codecov Report

Merging #6734 into master will increase coverage by <.01%.
The diff coverage is 84.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6734      +/-   ##
==========================================
+ Coverage   74.12%   74.13%   +<.01%     
==========================================
  Files         295      295              
  Lines       93865    93866       +1     
==========================================
+ Hits        69581    69584       +3     
+ Misses      24284    24282       -2
Flag Coverage Δ
#kernel 74.36% <91.66%> (+0.19%) ⬆️
#user 63.32% <0%> (-0.19%) ⬇️
Impacted Files Coverage Δ
module/zfs/arc.c 85.25% <84.61%> (-0.06%) ⬇️
cmd/zed/agents/zfs_agents.c 75.78% <0%> (-15.63%) ⬇️
module/zfs/zfs_fm.c 83.92% <0%> (-8.34%) ⬇️
module/zfs/zfs_rlock.c 90.16% <0%> (-6.15%) ⬇️
module/zfs/vdev_file.c 82.02% <0%> (-2.25%) ⬇️
cmd/zed/zed_disk_event.c 81.15% <0%> (-2.18%) ⬇️
module/zfs/mmp.c 95.7% <0%> (-1.23%) ⬇️
module/zfs/vdev_raidz.c 97.03% <0%> (-1.03%) ⬇️
module/zfs/zio.c 92.42% <0%> (-0.89%) ⬇️
module/zfs/spa_errlog.c 93.07% <0%> (-0.77%) ⬇️
... and 38 more

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 4f23c5d...509c194. Read the comment docs.

@behlendorf behlendorf force-pushed the async-destroy branch 2 times, most recently from 779ef98 to e68dfec Compare October 9, 2017 16:51
@behlendorf behlendorf requested a review from tuxoko October 9, 2017 17:01
@behlendorf
Copy link
Contributor Author

Testing Update:

  • Patch passed 10 run of the ZTS run via buildbot without triggering any OOM issues. Without the patch the odds of hitting an issue which killed the buildslave process were high.

@dpquigl dpquigl self-assigned this Oct 10, 2017
@dpquigl dpquigl removed their assignment Oct 10, 2017
@behlendorf
Copy link
Contributor Author

Related to #5352

module/zfs/arc.c Outdated
#endif /* ZFS_GLOBAL_NODE_PAGE_STATE */
#endif /* CONFIG_HIGHMEM */
#else
return (spa_get_random(arc_all_memory() * 20 / 100));
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a /* KERNEL */ here just to make it clearer to read. I had a hard time figuring out what the spa_get_random was for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

@@ -6947,7 +6971,7 @@ arc_memory_throttle(uint64_t reserve, uint64_t txg)
* continue to let page writes occur as quickly as possible.
*/
if (current_is_kswapd()) {
if (page_load > MAX(ptob(minfree), available_memory) / 4) {
if (page_load > MAX(arc_sys_free / 4, available_memory) / 4) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These two numbers seem very different. One is the number of free pages in bytes the other seems to be the number of 32 bit words? Is this really the comparison?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these values are in fact in bytes and this PR doesn't make any real change here. It only removes the minfree local and the needless btop() -> ptob() conversion. This is logic was adapted from OpenZFS and is intended to act as a throttle when there is significant memory pressure.

That said, according the codecov report this page_load block was never run during the ZTS. I find that pretty suspicious so we should revisit this, bit it may be that we simply never put enough memory pressure on the system. But let's address that in a different PR if needed so we can avoid making any functional changes in this one.

With the addition of the ABD changes consumption of the virtual
address space has been greatly reduced.  This exposed an issue on
CONFIG_HIGHMEM systems where free memory was being calculated
incorrectly.  Functionally this didn't cause any major problems
prior to ABD because a lack of available virtual address space
was used as an indicator of low memory.

This patch makes the following changes to address the issue and
in the process realigns the code further with OpenZFS.  There
are no substantive changes in behavior for 64-bit systems.

* Added CONFIG_HIGHMEM case to the arc_all_memory() and
  arc_free_memory() functions to only consider low memory pages
  on CONFIG_HIGHMEM systems.

* The arc_free_memory() function was updated to return bytes
  instead of pages to be consistent with the other helper
  functions.  In user space we make up some reasonable values
  since currently only testing is performed in this context.

* Adds three new values to the arcstats kstat to provide visibility
  in to the ARC's assessment of the memory situation:
  memory_all_bytes, memory_free_bytes, and memory_available_bytes.

* Added kmem_reap() call to arc_available_memory() for 32-bit
  builds to realign code with OpenZFS.

* Reduced size of test file in /async_destroy_001_pos.ksh to
  speed up test case.  Multiple txgs are still required.

* Move vdevs used by zpool_clear_001_pos and zpool_upgrade_002_pos
  to TEST_BASE_DIR location to speed up test cases.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes openzfs#5352
@behlendorf behlendorf merged commit 70f0228 into openzfs:master Oct 10, 2017
@behlendorf behlendorf added this to PR Needed in 0.7.3 Oct 10, 2017
aerusso pushed a commit to aerusso/zfs that referenced this pull request Oct 11, 2017
With the addition of the ABD changes consumption of the virtual
address space has been greatly reduced.  This exposed an issue on
CONFIG_HIGHMEM systems where free memory was being calculated
incorrectly.  Functionally this didn't cause any major problems
prior to ABD because a lack of available virtual address space
was used as an indicator of low memory.

This patch makes the following changes to address the issue and
in the process realigns the code further with OpenZFS.  There
are no substantive changes in behavior for 64-bit systems.

* Added CONFIG_HIGHMEM case to the arc_all_memory() and
  arc_free_memory() functions to only consider low memory pages
  on CONFIG_HIGHMEM systems.

* The arc_free_memory() function was updated to return bytes
  instead of pages to be consistent with the other helper
  functions.  In user space we make up some reasonable values
  since currently only testing is performed in this context.

* Adds three new values to the arcstats kstat to provide visibility
  in to the ARC's assessment of the memory situation:
  memory_all_bytes, memory_free_bytes, and memory_available_bytes.

* Added kmem_reap() call to arc_available_memory() for 32-bit
  builds to realign code with OpenZFS.

* Reduced size of test file in /async_destroy_001_pos.ksh to
  speed up test case.  Multiple txgs are still required.

* Move vdevs used by zpool_clear_001_pos and zpool_upgrade_002_pos
  to TEST_BASE_DIR location to speed up test cases.

Reviewed-by: David Quigley <david.quigley@intel.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes openzfs#5352
Closes openzfs#6734
tonyhutter pushed a commit that referenced this pull request Oct 16, 2017
With the addition of the ABD changes consumption of the virtual
address space has been greatly reduced.  This exposed an issue on
CONFIG_HIGHMEM systems where free memory was being calculated
incorrectly.  Functionally this didn't cause any major problems
prior to ABD because a lack of available virtual address space
was used as an indicator of low memory.

This patch makes the following changes to address the issue and
in the process realigns the code further with OpenZFS.  There
are no substantive changes in behavior for 64-bit systems.

* Added CONFIG_HIGHMEM case to the arc_all_memory() and
  arc_free_memory() functions to only consider low memory pages
  on CONFIG_HIGHMEM systems.

* The arc_free_memory() function was updated to return bytes
  instead of pages to be consistent with the other helper
  functions.  In user space we make up some reasonable values
  since currently only testing is performed in this context.

* Adds three new values to the arcstats kstat to provide visibility
  in to the ARC's assessment of the memory situation:
  memory_all_bytes, memory_free_bytes, and memory_available_bytes.

* Added kmem_reap() call to arc_available_memory() for 32-bit
  builds to realign code with OpenZFS.

* Reduced size of test file in /async_destroy_001_pos.ksh to
  speed up test case.  Multiple txgs are still required.

* Move vdevs used by zpool_clear_001_pos and zpool_upgrade_002_pos
  to TEST_BASE_DIR location to speed up test cases.

Reviewed-by: David Quigley <david.quigley@intel.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #5352
Closes #6734
@tonyhutter tonyhutter moved this from PR Needed to Merged to 0.7.3 in 0.7.3 Oct 16, 2017
@behlendorf behlendorf deleted the async-destroy branch April 19, 2021 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
0.7.3
Merged to 0.7.3
Development

Successfully merging this pull request may close these issues.

None yet

2 participants