-
Notifications
You must be signed in to change notification settings - Fork 54
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
Added configuration option for setting mem_limit in /sys/block/zramX/… #192
Conversation
…mem_limit, needed in cases when zram device size is big with compression ratios that can't be fit in RAM yet zram device does not report as being full. Option is "zram-resident-limit = " and syntax is same as with setting 'zram-size ='. Tested on my system and works as expected, additional test may be needed.
man/zram-generator.conf.md
Outdated
|
||
Sets the maximum resident memory limit of the zram device as a function of *MemTotal*, available as the `ram` variable. | ||
|
||
Arithmetic operators (^%/\*-+), e, π, SI suffixes, log(), int(), ceil(), floor(), round(), abs(), min(), max(), and trigonometric functions are supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Same format as zram-size
.", merge with next para at the end
man/zram-generator.conf.md
Outdated
|
||
Arithmetic operators (^%/\*-+), e, π, SI suffixes, log(), int(), ceil(), floor(), round(), abs(), min(), max(), and trigonometric functions are supported. | ||
|
||
Defaults to *0* meaning there is no limit, usefull to set when having zram device bigger than available RAM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Defaults to 0 (no limit)."
src/config.rs
Outdated
self.mem_limit = (match self.zram_resident_limit.as_ref() { | ||
Some(zs) => { | ||
zs.1.from(&zs.2.ps) | ||
.eval(&zs.2, &mut RamNs(memtotal_mb as f64)) | ||
.with_context(|| format!("{} zram-resident-limit", self.name)) | ||
.and_then(|f| { | ||
if f >= 0. { | ||
Ok(f) | ||
} else { | ||
Err(anyhow!("{}: zram-resident-limit={} < 0", self.name, f)) | ||
} | ||
})? | ||
} | ||
None => 0.0, | ||
} * 1024. | ||
* 1024.) as u64; | ||
|
||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this clearly duplicates the else in set_disksize_if_enabled()
; lift it out
let mut sl = fasteval::Slab::new(); | ||
dev.zram_resident_limit = Some(( | ||
value.to_string(), | ||
fasteval::Parser::new() | ||
.parse_noclear(value, &mut sl.ps) | ||
.with_context(|| format!("{} zram-resident-limit", dev.name))?, | ||
sl, | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clear copy-paste of the "zram-size"
branch
zram-generator.conf.example
Outdated
# zram-resident-limit=ram/8, then the resident space on RAM won't | ||
# exceed 64MiB. Recomended value is ram / 2. | ||
# | ||
# The default is "0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
zram-generator.conf.example
Outdated
# The maximum size of resident memory of zram device, as function of | ||
# MemTotal, both in MB. For example, if the machine has 1GiB, and | ||
# zram-resident-limit=ram/8, then the resident space on RAM won't | ||
# exceed 64MiB. Recomended value is ram / 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cite? by whom?
zram-generator.conf.example
Outdated
# MemTotal, both in MB. For example, if the machine has 1GiB, and | ||
# zram-resident-limit=ram/8, then the resident space on RAM won't | ||
# exceed 64MiB. Recomended value is ram / 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
math wrong I think?
zram-generator.conf.example
Outdated
@@ -19,6 +19,14 @@ host-memory-limit = 9048 | |||
# The default is "min(ram / 2, 4096)". | |||
zram-size = min(ram / 10, 2048) | |||
|
|||
# The maximum size of resident memory of zram device, as function of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The maximum memory resident for this zram device, as a function of MemTotal, both in MB." Also format this like the sexion above :v
Pushed new changes. |
…mem_limit, needed in cases when
zram device size is big with compression ratios that can't be fit in RAM yet zram device does not report as being full. Option is "zram-resident-limit = " and syntax is same as with setting 'zram-size ='. Tested on my system and works as expected, additional test may be needed.