1

I know that /proc is a pseudo filesystem which makes it impossible to use inotify API.

Some parts of /proc can be monitored with select/poll API (like /proc/mounts). So I'm wondering is it possible to monitor /proc/pid/statm in that way?

Since all the data found in /proc/pid/statm is generated by the kernel on the fly my guess is that select/poll wouldn't work. So is there any other solution available for me to accomplish what I want, except from reading /proc/pid/statm periodically?

Ognjen
  • 35
  • 8
  • Explicitly check when memory is provided to a process -- i.e. page is allocated, area is `mmap()`ed, etc. You may do that in SystemTap. If you wish an example, I can post it as answer. – myaut May 14 '15 at 07:37
  • I'm interested in 6th entry in /proc/pid/statm which is data+stack. By looking at that entry I can reliably find USS for watched process. I don't want to track RSS or PSS, so I'm wondering could your method distinguish between mmap()-ed pages for loaded shared libraries and user allocates pages? – Ognjen May 14 '15 at 09:11
  • have you tried to look at `/proc/self/maps`? My method can distinguish that, but can you specify, what you seek for: heap, stack, data, mmapped-files, anon? – myaut May 14 '15 at 10:05
  • I'll try to clarify it. I want to track other process memory usage, but only memory that is allocated inside tracked process for its own usage will be counted. That includes stack, heap and some pages in shared memory (for example when malloc() allocates from there see http://stackoverflow.com/questions/3479330/how-is-malloc-implemented-internally). Basically I want to track changes in USS of other process as soon as change happens. – Ognjen May 14 '15 at 10:14

0 Answers0