#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
#[derive(Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub enum TransparentHugePageRegularMemoryChoice
{
Never,
Always,
Advise,
}
impl Default for TransparentHugePageRegularMemoryChoice
{
#[inline(always)]
fn default() -> Self
{
TransparentHugePageRegularMemoryChoice::Never
}
}
impl TransparentHugePageRegularMemoryChoice
{
#[inline(always)]
fn to_value(self) -> &'static [u8]
{
use self::TransparentHugePageRegularMemoryChoice::*;
match self
{
Never => b"never\n" as &[u8],
Always => b"always\n" as &[u8],
Advise => b"madvise\n" as &[u8],
}
}
pub fn change_transparent_huge_pages_usage(self, sys_path: &SysPath, transparent_huge_page_shared_memory_choice: TransparentHugePageSharedMemoryChoice, use_zero_page: bool) -> io::Result<()>
{
sys_path.transparent_huge_memory_file_path("use_zero_page").write_value(use_zero_page)?;
transparent_huge_page_shared_memory_choice.change_transparent_huge_pages_usage(sys_path)?;
sys_path.transparent_huge_memory_file_path("enabled").write_value(self.to_value())
}
}