-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Replace mem.page_size with mem.min_page_size and mem.max_page_size #4082
Comments
how about: // page_sizes.len is guaranteed > 0
// page_sizes guaranteed in order smallest to largest
// "max" and "min" is page_sizes[0] and page_sizes[page_sizes.len-1]
// on arm with 4 page sizes
const page_sizes: []const usize = [_]usize{ 0x1000, 0x10000, 0x100000, 0x1000000 }; // 4K, 65K, 1M, 1G
// a default is always needed could be comptime set to something other than smallest
const default_page_size = page_sizes[0]; posix BUFSIZ is for io and doesn't belong in |
What is the status of this proposal? |
no the linked issue explains that |
Along with the original proposal I am tagging along this change as well:
|
Taking a swing at this but I have a couple questions.
I'm leaning more towards @mikdusan and this comment's ideas. |
I wonder, where those expectations come from. Kernels provide the default size and, if available, a user-configurable size for large pages and one needs Kernel or CPU-level privilege to do stuff in the MMU etc. I would propose instead a 1. portable large table abstraction (which are unfortunately named different in different Kernels), 2. making possible page sizes from the hardware available at comptime and 3. provide probing functionality for such large page abstractions. Background: One can configure or compile Kernels with different page size support and not all Kernels provide the page API: Hermit has no reliable page size and neither an api for it. See hermit-os/kernel#815. |
Quoting @daurnimator from #3815:
This PR removes
mem.page_size
and replaces it with minimums and maximums. Originally I attempted to create a global variablepage_size
, but I realised that this would not work when zig's own startup routines are not used (e.g. when zig is used to create a static library). There is no linux syscall to get the current page size if you don't have access to the auxiliary vector, so a hacky solution would be required (e.g. using the knowledge thatmadvise
returnsEINVAL
on non-page aligned arguments, and doing a search for the page size)This PR introduces
mem.bufsiz
as a reasonable "default size" for buffers. The name is taken from the posix constantBUFSIZ
.Additionally, on linux we now
assert
that the page size in the auxiliary vector matches expectations.This proposal solves #2564
The text was updated successfully, but these errors were encountered: