Skip to content
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

[task]: Introduce namespaces io manage system resources #193

Open
wants to merge 17 commits into
base: monolithic
Choose a base branch
from

Conversation

Azure-stars
Copy link
Contributor

No description provided.

@Azure-stars Azure-stars force-pushed the monolithic branch 2 times, most recently from 7ab1d2a to 801de3c Compare October 23, 2024 02:30
@Azure-stars Azure-stars force-pushed the monolithic branch 2 times, most recently from 572dcea to 4bd7557 Compare November 13, 2024 13:08
@Azure-stars Azure-stars force-pushed the monolithic branch 2 times, most recently from e38cb09 to aabfe88 Compare November 21, 2024 02:17
modules/axruntime/src/lib.rs Outdated Show resolved Hide resolved
modules/axns/src/lib.rs Outdated Show resolved Hide resolved
RwLock::new(fd_table)
};
def_resource! {
#[allow(non_camel_case_types)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean #[allow(non_camel_case_types)], when we remove it then such warnings will appear:

Structure `FD_TABLE` should have UpperCamelCase name, e.g. `FdTable`

Copy link
Member

@equation314 equation314 Feb 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add it before line 227:

macro_rules! def_resource {
( $( $(#[$attr:meta])* $vis:vis static $name:ident: $ty:ty = $default:expr; )+ ) => {
$(
$(#[$attr])*
$vis struct $name { __value: () }

api/arceos_posix_api/src/imp/mod.rs Outdated Show resolved Hide resolved
modules/axfs/tests/test_fatfs.rs Outdated Show resolved Hide resolved
@@ -90,6 +90,12 @@ fn kernel_image_regions() -> impl Iterator<Item = MemRegion> {
flags: MemRegionFlags::RESERVED | MemRegionFlags::READ,
name: ".rodata",
},
MemRegion {
paddr: virt_to_phys((_sinit_array as usize).into()),
size: _einit_array as usize - _sinit_array as usize,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use __init_array_start and __init_array_end only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But __init_array_end segment may be not aligned to 4K size.

.init_array : ALIGN(4K) {
    _sinit_array = .;
    __init_array_start = .;
    *(.init_array .init_array.*)
    __init_array_end = .;
    . = ALIGN(4K);
    _einit_array = .;
}

And the linker scripts in Unikraft are below:

OTHER SECTIONS (aligned to 0x8)
/* Constructor tables (read-only) */
. = ALIGN(0x8);
_ctors = .;
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}

. = ALIGN(0x8);
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
_ectors = .;
. = ALIGN(__PAGE_SIZE);

Then it enumerate all function pointers from __init_array_start to __init_array_end and invokes them.

Should we manually align this region to 4K like this?

MemRegion {
    paddr: virt_to_phys((__init_array_start as usize).into()).align_down_4k(),
    size: VirtAddr::from_usize(__init_array_end as usize).align_up_4k()
        - VirtAddr::from_usize(__init_array_start as usize).align_down_4k(),
    flags: MemRegionFlags::RESERVED | MemRegionFlags::READ,
    name: ".init_array",
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can put the init_array section between .data and .tdata so that it will be mapped when we map _sdata.._edata.

@@ -37,6 +37,10 @@ pub fn new_kernel_aspace() -> AxResult<AddrSpace> {
axconfig::KERNEL_ASPACE_SIZE,
)?;
for r in axhal::mem::memory_regions() {
if r.size == 0 {
info!("Skip zero-size memory region: {:?}", r);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the empty region check in map_linear/map_alloc/unmap/protect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But how should we know which empty segments need to be returned normally or report error if we put empty region check in these func?

modules/axfs/Cargo.toml Outdated Show resolved Hide resolved
api/arceos_posix_api/Cargo.toml Outdated Show resolved Hide resolved
@Azure-stars
Copy link
Contributor Author

They will be solved in #224

@Azure-stars Azure-stars force-pushed the monolithic branch 3 times, most recently from 63732c8 to f542419 Compare February 14, 2025 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants