mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
agent: Don't attempt to create directories for hugepage configuration
allocate_hugepages() constructs the path for the sysfs directory containing hugepage configuration, then attempts to create this directory if it does not exist. This doesn't make sense: sysfs is a view into kernel configuration, if the kernel has support for the hugepage size, the directory will already be there, if it doesn't, trying to create it won't help. For the same reason, attempting to create the "nr_hugepages" file itself is pointless, so there's no reason to call OpenOptions::create(true). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
934788eb53
commit
608e003abc
@ -335,20 +335,16 @@ fn allocate_hugepages(logger: &Logger, options: &[String]) -> Result<()> {
|
|||||||
|
|
||||||
// sysfs entry is always of the form hugepages-${pagesize}kB
|
// sysfs entry is always of the form hugepages-${pagesize}kB
|
||||||
// Ref: https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt
|
// Ref: https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt
|
||||||
let path = Path::new(SYS_FS_HUGEPAGES_PREFIX).join(format!("hugepages-{}kB", pagesize / 1024));
|
let path = Path::new(SYS_FS_HUGEPAGES_PREFIX)
|
||||||
|
.join(format!("hugepages-{}kB", pagesize / 1024))
|
||||||
if !path.exists() {
|
.join("nr_hugepages");
|
||||||
fs::create_dir_all(&path).context("create hugepages-size directory")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// write numpages to nr_hugepages file.
|
// write numpages to nr_hugepages file.
|
||||||
let path = path.join("nr_hugepages");
|
|
||||||
let numpages = format!("{}", size / pagesize);
|
let numpages = format!("{}", size / pagesize);
|
||||||
info!(logger, "write {} pages to {:?}", &numpages, &path);
|
info!(logger, "write {} pages to {:?}", &numpages, &path);
|
||||||
|
|
||||||
let mut file = OpenOptions::new()
|
let mut file = OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create(true)
|
|
||||||
.open(&path)
|
.open(&path)
|
||||||
.context(format!("open nr_hugepages directory {:?}", &path))?;
|
.context(format!("open nr_hugepages directory {:?}", &path))?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user