Skip to content

Commit

Permalink
fdctl: configure large pages without alloc program
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcgee-jump committed Jul 10, 2023
1 parent 47f87c5 commit 4804daa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/app/fdctl/src/commands/configure/large_pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::fs;

use super::*;
use crate::security::*;
use crate::utility::*;
use crate::Config;

const NAME: &str = "large-pages";
Expand All @@ -26,13 +25,14 @@ fn explain_init_permissions(_: &Config) -> Vec<Option<String>> {
}

fn step(config: &mut Config) {
let bin = &config.binary_dir;

for (size, _, expected_pages) in [
for (_, page_size, expected_pages) in [
("huge", 2048, config.shmem.min_kernel_huge_pages),
("gigantic", 1048576, config.shmem.min_kernel_gigantic_pages),
] {
run!("{bin}/fd_shmem_cfg alloc {expected_pages} {size} 0");
let page_path = format!("/sys/devices/system/node/node0/hugepages/hugepages-{page_size}kB");

super::shmem::try_defragment_memory();
std::fs::write(page_path, expected_pages.to_string()).unwrap();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/fdctl/src/commands/configure/shmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn explain_fini_permissions(_: &Config) -> Vec<Option<String>> {
)]
}

fn try_defragment_memory() {
pub(crate) fn try_defragment_memory() {
std::fs::write("/proc/sys/vm/compact_memory", "1").unwrap();
std::thread::sleep(std::time::Duration::from_millis(250));
}
Expand Down

0 comments on commit 4804daa

Please sign in to comment.