[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1729729122208664.jpg (153 KB, 1023x932)
153 KB
153 KB JPG
previous: >>108003055

#define __NR_mincore            27

https://man7.org/linux/man-pages/man2/mincore.2.html

i 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 man

man syscalls

https://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/
>>
>>108013129
Suppose 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.
>>
>>108013174
that 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 feet
It can get swapped out though
>>
>>108015135
in 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 pages
Literally useless.
>>
>>108013129
explain when you'd actually use this?
>>
>>108018002
Disk cache tweaking. vmtouch uses it, for example.
>>
>>108013129
hm, 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
>>108015489
the syscall checks whether addresses are resident though, not whether they're mapped, so this test would produce false negatives
>>
>>108020913
Maybe you could look at EFAULT vs ENOMEM
>>
>>108021078
interesting approach. Although I don't see how EFAULT would help, as it's set in relation to vec.
>>
>>108020913
you'd only check the return code against ENOMEM and would ignore the vec arguments



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.