dbuf: evict harder when under memory pressure #15659
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
In an OOM situation, there's no path for the kernel to signal to the dbuf cache that it should evict things, so it continues to operate as normal, oblivious to the fact that the world is burning down around it.
Absent such a signal, this commit instead just makes the evict thread keep going as long as the ARC is in distress.
Description
In
dbuf_evict_thread()
when deciding if there's more to evict, also callarc_reclaim_needed()
, and keep going if its true.This is made somewhat less necessary by #15511, since the dbuf cache will no longer be pinning vastly more memory than it should have been, but its still useful if there's a sudden demand for a huge amount of memory.
I don't know if this is the right approach. On the one hand, the ARC is accounting for a lot of memory in the system that it isn't directly responsible for, so asking it if it believes there is a problem seems reasonable. On the other hand, its not accounting for everything (eg kmem caches) and doesn't have a complete picture, and isn't able to evict a lot of things anyway.
This leads me to a design question: what is the ARCs role in overall memory management? Is it expected that its the source of truth for all memory ZFS is using? (and if so, why isn't it?). Or, is it only interested in its own memory usage? (and if so, why account for memory from other sources (eg dnodes)?). The answer is somewhere in between, but I haven't been able to draw the line.
If the ARC is supposed to be at the centre of it all, then possibly the better approach here would be for it to understand the dbuf cache more directly and signal it when it its time to drop things. But that also leads to madcap things, like the ARC also being able to evict kmem caches, so I'd appreciate some guidance on this question regardless of whether or not this PR is sensible.
How Has This Been Tested?
Minimal, mostly by causing OOM conditions (
tail -f /dev/zero
) and observing the cache kstats.Its quite possible to write a test that uses the same method, but first I wanted to make sure that the idea is right.
Types of changes
Checklist:
Signed-off-by
.