3 ms·
You don't need to run mincore() on target pids - you just need to write a tool that opens(O_RDONLY) and mmaps(PROT_READ) each library file, then calls mincore()
by caf 12y ago
You don't need to run mincore() on target pids - you just need to write a tool that opens(O_RDONLY) and mmaps(PROT_READ) each library file, then calls mincore() on each page in the mapping to find out which pages of the library are loaded shared.
The results of mincore() in one process with a shared mapping of a file are enough to tell you how much of that file is loaded shared system-wide.
- zvrba 12y agoAh, good point! Though I think I'll do a dlopen on each file to mimic whatever the loader usually does. I'll do it as a weekend-project :)
- caf 12y agoIn case it helps, here's my little utility (which just shows how much of a file is in core): https://github.com/keaston/fincore https://github.com/keaston/fincore
- zvrba 12y agoJust found out that physical page information is exposed through /proc: https://www.kernel.org/doc/Documentation/vm/pagemap.txt https://www.kernel.org/doc/Documentation/vm/pagemap.txt