-
Notifications
You must be signed in to change notification settings - Fork 36
支持大页分配 #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
支持大页分配 #54
Conversation
325bb1b
to
6a3b6a8
Compare
a7dd997
to
f2fc8e7
Compare
Cargo.toml
Outdated
starry-core = { path = "./core" } | ||
starry-api = { path = "./api" } | ||
|
||
page_table_multiarch = { git = "https://github.com/Mivik/page_table_multiarch.git", rev = "19ededd" } |
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.
Why add this? We have patched it in this TOML.
api/Cargo.toml
Outdated
|
||
starry-core.workspace = true | ||
|
||
page_table_multiarch.workspace = true |
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.
We can directly add this dependency, like page_table_multiarch = "0.5"
api/src/imp/mm/mmap.rs
Outdated
use axerrno::{LinuxError, LinuxResult}; | ||
use axhal::paging::MappingFlags; | ||
use axtask::{TaskExtRef, current}; | ||
use linux_raw_sys::general::{ |
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.
Can we directly use linux_raw_sys::general::*
?
api/src/imp/mm/mmap.rs
Outdated
|
||
// The check uses bitwise operations to | ||
// verify that exactly one of the two mutually exclusive mapping flags is set | ||
if (map_flags.bits() & (MAP_PRIVATE | MAP_SHARED)).count_ones() != 1 { |
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.
Use map_flags.contains(MappingFlags::SHARED | MappingFlags::PRIVATE)
api/src/imp/mm/mmap.rs
Outdated
|
||
let start = memory_addr::align_down_4k(addr); | ||
let end = memory_addr::align_up_4k(addr + length); | ||
let page_size = match (flags & MAP_HUGETLB, flags & MAP_HUGE_MASK << MAP_HUGE_SHIFT) { |
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.
You can use if else
to let the logic more clear
api/src/ptr.rs
Outdated
let page_start = start.align_down_4k(); | ||
let page_end = (start + layout.size()).align_up_4k(); | ||
aspace.populate_area(page_start, page_end - page_start)?; | ||
aspace.populate_area(page_start, page_end - page_start, PageSize::Size4K)?; |
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.
Here we will remove the alignment argument because the area has its own alignment.
scripts/get_deps.sh
Outdated
|
||
test ! -d "$AX_ROOT" && echo "Cloning repositories ..." || true | ||
test ! -d "$AX_ROOT" && git clone https://github.com/oscomp/arceos "$AX_ROOT" --depth=1 || true | ||
test ! -d "$AX_ROOT" && git clone https://github.com/Ticonderoga2017/arceos "$AX_ROOT" --depth=1 || true |
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.
update it
0ca0916
to
4fcfcf7
Compare
…ocating multiple consecutive 1GB huge pages.
api/src/imp/mm/mmap.rs
Outdated
|
||
let start = memory_addr::align_down_4k(addr); | ||
let end = memory_addr::align_up_4k(addr + length); | ||
let page_size = if flags & MAP_HUGETLB == 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.
Can you use map_flags
? And you can add more flags for MmapFlags
type:
starry-next/api/src/imp/mm/mmap.rs
Lines 53 to 66 in 130f09e
struct MmapFlags: u32 { | |
/// Share changes | |
const SHARED = MAP_SHARED; | |
/// Changes private; copy pages on write. | |
const PRIVATE = MAP_PRIVATE; | |
/// Map address must be exactly as requested, no matter whether it is available. | |
const FIXED = MAP_FIXED; | |
/// Don't use a file. | |
const ANONYMOUS = MAP_ANONYMOUS; | |
/// Don't check for reservations. | |
const NORESERVE = MAP_NORESERVE; | |
/// Allocation is for a stack. | |
const STACK = MAP_STACK; | |
} |
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.
Then you can use MmapFlags.contains() function and avoid operations over the i32
type.
api/src/imp/mm/mmap.rs
Outdated
// TODO: check illegal flags for mmap | ||
// An example is the flags contained none of MAP_PRIVATE, MAP_SHARED, or MAP_SHARED_VALIDATE. | ||
let map_flags = MmapFlags::from_bits_truncate(flags); | ||
if map_flags.contains(MmapFlags::from_bits_truncate(MAP_PRIVATE | MAP_SHARED)) { |
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.
Rewrite it as below:
if map_flags.contains(MmapFlags::SHARED | MmapFlags::PRIVATE) {
return Err(LinuxError::EINVAL);
}
api/src/imp/mm/mmap.rs
Outdated
let page_size = if flags & MAP_HUGETLB == 0 { | ||
PageSize::Size4K | ||
} else { | ||
match flags & MAP_HUGE_MASK << MAP_HUGE_SHIFT { |
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.
You can use MAP_HUGE_1GB
or MAP_HUGE_256MB
from linux_raw_sys::general
api/src/imp/mm/mmap.rs
Outdated
let mut aspace = process_data.aspace.lock(); | ||
let length = memory_addr::align_up_4k(length); | ||
let start_addr = VirtAddr::from(addr); | ||
let length = memory_addr::align_up_4k(length); |
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.
Why move it?
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.
And you can import align_up
and align_up_4k
at the global scope.
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.
set use memory_addr::{align_up_4k, align_up}
And please add the updated commit hash for arceos backbone. |
Add |
api/Cargo.toml
Outdated
ctor_bare = "0.2.1" | ||
flatten_objects = "0.2.3" | ||
num_enum = { version = "0.7", default-features = false } | ||
page_table_multiarch = "0.5" |
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.
Remove this dependency because PageSize
can be provided by axhal::paging
api/src/imp/mm/mmap.rs
Outdated
use memory_addr::{VirtAddr, VirtAddrRange}; | ||
use linux_raw_sys::general::*; | ||
use memory_addr::{MemoryAddr, VirtAddr, VirtAddrRange}; | ||
use page_table_multiarch::PageSize; |
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.
use axhal::paging::PageSize;
api/src/imp/mm/mmap.rs
Outdated
let mut aspace = process_data.aspace.lock(); | ||
let length = memory_addr::align_up_4k(length); | ||
let start_addr = VirtAddr::from(addr); | ||
let length = memory_addr::align_up_4k(length); |
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.
set use memory_addr::{align_up_4k, align_up}
scripts/get_deps.sh
Outdated
|
||
AX_ROOT=.arceos | ||
COMMIT=c747ba8 | ||
COMMIT=b55bc93 |
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.
update the commit to the latest commit: oscomp/arceos@54d5739
fea706b
to
8bd0a8a
Compare
1. Support hugepage mmap. 2. Modify the testcase to avoid panic when allocating multiple consecutive 1GB huge pages.
根据内核代码进行了部分修改,重点修改测例,对以下方面进行测试: