previous: >>108003055#define __NR_mincore 27https://man7.org/linux/man-pages/man2/mincore.2.htmli feel like i want to like this syscall. i've thought up a few use cases here and there, but it's pretty much all just toy examples. i haven't personally been able to use this one for anything of value.also, this part amuses me>Of course the information returned in vec is only a snapshot: pages that are not locked in memory can come and go at any moment, and the contents of vec may already be stale by the time this call returns.how would you use this syscall?relevant resources: man manman syscallshttps://man7.org/linux/man-pages/https://linux.die.net/man/https://elixir.bootlin.com/linux/https://elixir.bootlin.com/musl/https://elixir.bootlin.com/glibc/
#define __NR_mincore 27
man man
man syscalls
>>108013129Suppose you are writing a debugger, and you want to pretty print some pointer given to you by the user. how do you know it won't crash? two strategies: dereference it and catch the segv, or check beforehand. The latter is a great deal simpler to implement. Since the process is paused while the debugger runs, there's no danger of the memory becoming deallocated under your feet.
>>108013174that is indeed quite close to one of the toy examples i'd come up with! basically a way to completely eliminate null pointer (or similar) segfaults. would be quite slow, though. there's a reason it's not done this way by default!
>>108013174>there's no danger of the memory becoming deallocated under your feetIt can get swapped out though
>>108015135in this scenario, we'd only care whether it was mapped, since a pagefault is fine, but a segfault is bad
bampu
>results immediately become stale and may not be true by the time you access those pagesLiterally useless.
>>108013129explain when you'd actually use this?
>>108018002Disk cache tweaking. vmtouch uses it, for example.
>>108013129hm, I've pronounced it min-core so far, but I suppose m-in-core is the etymology. sounds bad, though, so I'll continue saying min-core!>>108013174>>108015489the syscall checks whether addresses are resident though, not whether they're mapped, so this test would produce false negatives
>>108020913Maybe you could look at EFAULT vs ENOMEM
>>108021078interesting approach. Although I don't see how EFAULT would help, as it's set in relation to vec.
>>108020913you'd only check the return code against ENOMEM and would ignore the vec arguments