(
size: usize,
hugepages: bool,
hugepage_size: Option<u64>,
)
| 1841 | } |
| 1842 | |
| 1843 | fn create_anonymous_file( |
| 1844 | size: usize, |
| 1845 | hugepages: bool, |
| 1846 | hugepage_size: Option<u64>, |
| 1847 | ) -> Result<FileOffset, Error> { |
| 1848 | let fd = Self::memfd_create( |
| 1849 | &ffi::CString::new("ch_ram").unwrap(), |
| 1850 | libc::MFD_CLOEXEC |
| 1851 | | if hugepages { |
| 1852 | libc::MFD_HUGETLB |
| 1853 | | if let Some(hugepage_size) = hugepage_size { |
| 1854 | /* |
| 1855 | * From the Linux kernel: |
| 1856 | * Several system calls take a flag to request "hugetlb" huge pages. |
| 1857 | * Without further specification, these system calls will use the |
| 1858 | * system's default huge page size. If a system supports multiple |
| 1859 | * huge page sizes, the desired huge page size can be specified in |
| 1860 | * bits [26:31] of the flag arguments. The value in these 6 bits |
| 1861 | * will encode the log2 of the huge page size. |
| 1862 | */ |
| 1863 | |
| 1864 | hugepage_size.trailing_zeros() << 26 |
| 1865 | } else { |
| 1866 | // Use the system default huge page size |
| 1867 | 0 |
| 1868 | } |
| 1869 | } else { |
| 1870 | 0 |
| 1871 | }, |
| 1872 | ) |
| 1873 | .map_err(Error::SharedFileCreate)?; |
| 1874 | |
| 1875 | // SAFETY: fd is valid |
| 1876 | let f = unsafe { File::from_raw_fd(fd) }; |
| 1877 | f.set_len(size as u64).map_err(Error::SharedFileSetLen)?; |
| 1878 | |
| 1879 | Ok(FileOffset::new(f, 0)) |
| 1880 | } |
| 1881 | |
| 1882 | fn open_backing_file( |
| 1883 | backing_file: &PathBuf, |
nothing calls this directly
no test coverage detected