udev: Add ZRAM recompression by default #13
Merged
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.
Since we already have
CONFIG_ZRAM_MULTI_COMP
enabled in our kernel, I thought that we could provide by default recompressions to ZRAM. Double compression will save more memory for those pages that cannot be compressed with Zstd (since we use it by default), in this PR I decided to set double compression only for idle pages, since huge pages were reverted with the commit 48f40a5. The re-compression algorithm can be changed in the future, for now I stopped at LZ4.This was done as a udev rule as a temporary solution, since it is better to have this feature directly in the zram-generator, but until it is absent we will limit ourselves to this rule.
It also works only for kernel versions 6.2 and higher, for versions of the kernel below this should not create due to the checks (I tested at linux-zen 6.1, no errors).
Note: I know that recompression may cause additional CPU overhead, but I don't think it will be too critical. Additionally, we can limit this via the
threshold
parameter. Anyway, it's interesting to hear your opinion @sirlucjan @ptr1337