I apologize for the long question ahead but I needed to give some context to my problem.
So I'm writing a logger in the Linux kernel to extract memory characteristics like virtual address, the physical address of pages etc.
For sanity testing, I perform a malloc()
to allocate a certain amount of pages and then extract their virtual address and logical address to see if the allocations add up. I extract based on the pid of that process and after the occurrence of do_brk()
is invoked in the kernel.
It works great and accurately for lesser page allocations(~128) and the count of pages allocated is dead close to what I'm actually allocating(+2->3). However when I allocate a higher number of pages(~256 or more). Then it does not log anything. On looking at the raw logs, that pid doesn't show the allocations made. It does log it after repeated runs though. And the number of pages is exact.
The way I understand is that maybe Virtual memory is playing a part here and delegating this to another process(maybe kernel) to do a mmap(do_mmap) and allocating it there. So does anybody have any idea on identifying the actual process that does it?
Or another possibility could be that printk()
maybe not be able to keep up the generating logs itself. In which case it would explain why the logs spit out a few times and other times they don't.