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

implement mincore #966

Open
no92 opened this issue Jan 22, 2024 · 8 comments
Open

implement mincore #966

no92 opened this issue Jan 22, 2024 · 8 comments
Labels
trivial issue Requires only straightforward changes and not new logic.

Comments

@no92
Copy link
Member

no92 commented Jan 22, 2024

Implementing mincore for linux, managarm and probably most other sysdeps should be trivial and would fix warnings with some GTK apps.

@no92 no92 added the trivial issue Requires only straightforward changes and not new logic. label Jan 22, 2024
@jeremyelalouf
Copy link

Hi @no92,

I would love to contribute here, but I still have some questions regarding portability issues.

The goal is to implement the mincore function. Does it require a specific implementation for different sysdeps, or could one generic implementation suffice?

Additionally, it's possible that I lack knowledge in these subjects, but I am eager to learn. I have a strong background in C, and with a bit more context, I'm confident that I can make a meaningful contribution here!

Let me know! :)

@qookei
Copy link
Member

qookei commented Mar 3, 2024

We'd want to leave the actual implementation up to sysdeps. E.g. on Linux mincore is implemented via a system call, and other systems probably want to do their own thing.

@jeremyelalouf
Copy link

Okay, I see. Totally makes sense!

So here the goal would be to implement the function for all supported os ?

@qookei
Copy link
Member

qookei commented Mar 4, 2024

That's kinda out of scope for mlibc, I think Linux is the only system we support that currently implements an mincore syscall, and implementing it ourselves for everyone else would be quite a bit of work on our side. I don't think this even can be implemented without OS support, since it checks for page residency (whether accessing it will not require allocation or loading data from disk), not whether the page is mapped in in general, and pages becoming non-resident is supposed to be transparent, apart from maybe the time it takes to load it back in.

How mlibc deals with this is via sysdeps, which house the system-specific functions required by the various generic libc functions. Most sysdep functions are marked [[gnu::weak]], which means that if they're missing, they resolve to NULL at link time. The actual function that uses the sysdep then checks if that's the case, and if so, bails out with an ENOSYS error (or whatever's appropriate). Once a particular system adds a way to provide the sysdep for mincore, it can be added, and the generic function will just work on it.

Also, I've just had a look, and we apparently have mincore in mlibc itself? I might be missing something, but perhaps @no92 meant to make this issue on the Managarm repo? It'd still be appreciated if you took up the task of doing that, but that's probably gonna be a more involved project than just the mlibc side and the Linux sysdep. I apologize for the confusion if that's the case!

@no92
Copy link
Member Author

no92 commented Mar 4, 2024

Yeah I didn't notice the linux sysdep. I guess it would be nice to implement it for managarm, as we don't have many cases where a page wouldn't be resident in memory that shouldn't be too hard™.

@jeremyelalouf
Copy link

@no92 so it would not be in this repo but on the Managarm's one ?

@no92
Copy link
Member Author

no92 commented Mar 4, 2024

Managarm's sysdeps are implemented in this repo, under sysdeps/managarm.

@jeremyelalouf
Copy link

jeremyelalouf commented Mar 4, 2024

Okay, and you think that it's a good first issue ? @no92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
trivial issue Requires only straightforward changes and not new logic.
Projects
None yet
Development

No branches or pull requests

3 participants