I am currently writing my first kernel module to extract data from
the kernel and bring it into user-space. As I understand, FreeBSD
only loads pages of the text segment that it is about to use by
registering its handler for page faults, and bringing in more pages
from the binary as needed. I want to track this progress, and report
the amount of pages it brought in on process exit.

The current idea I have and the path I'm following is as follows:
I register a callback in my module using EVENTHANDLER_REGISTER,
using 'process_exit' name. That gives me the proc structure on exit,
I then try to find the information I need using the p_vmspace member,
and try using vm_tsize for the number of pages. But this is the
number of pages in the virtual address space of the text segment,
which does not correlate to how many pages were actually brought

For the context of this, I am trying to write a tiny utility, that
watches the execution of a process, and tracks how many pages were
actually used during its execution. It passes that knowledge to a
hopefully-to-be-written user-space utility that generates a new
binary using only those pages for the text segment. (If an execution
was to go outside that, a seg fault is okay.)

Any help is appreciated.

Thanks, Yan
freebsd-hackers@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"