Show full process argument list instead only executable name Some systems have same executable running multiple times, executed with different command line arguments. These may be difficult to distinguish from each other if we don't see also the arguments. Show the whole argument list for each processes as this usually what we want to see. Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
parse: Fix out of bound access Make sure the copy length is at least one shorter than the buffer size. This isn't strictly required as we would be forcefully NULL terminating the string aynway, but this silences the compiler warning we are getting with modern versions of gcc. Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Reverse list printing order The process and mapping lists are often very long and rarely fit entirely on the screen. Usually we are most interested in the largest entries, the ones that now get printed in the beginning of the list. This is cumbersome as it therefore requires quite a bit of scrolling to see what you really want. Reverse the list printing order so that the tool becomes more friendly to the end user. Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
parse_maps: Fix issues with white space in file names If there is any white space character in the file name field, sscanf would only copy the file name part until the first white space and leave out everything else. The fix is trivial; we will use the %n with sscanf to find out all the chars before the file name part and then skip that part when using strncpy to copy the file name. Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
print_page_stats: Reserve 7 digits for page count alignment If there are mappings that are larger than 4 gigabytes, 6 digits is not enough for the output. 7 digits is enough until 40 gigabytes, which should probably be enough in most of users. If someone has got more than 40 gigabytes of ram and wants to have nicely aligned page usage prints, I'm happy to implement some sort of dynamic alignmenting for it.. Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
pf_insert: Return matching node on insert When a matching entry is found from the rb_tree, the insert function should return the found entry from the tree to the caller. This is also explicitly documented in the code. However, the code incorrectly returned NULL instead. Fix the code to return the match as it should do. Without this fix identical pageframe entries are never located. Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
pagemap.h: Do not use hardcoded maximum number of kpageflags The kpageflag definitions are subject to change. It is better to have a dynamic maximum defined for this. Furthermore, the previous maximum was actually wrong. The KSM pages were never shown even if such pages were present on the system. Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Revert "Fix bug when showing process shared mappings" This reverts commit 52cf500b2f5cbe16f991990d50ec990ab9540b97. The previous commit was causing the allocated pages reported by the '-s' option to be doubled. That is clearly wrong. As I can not remember anymore what I was thinking when I wrote the commit and I can only see how wrong it is, I see no reason to not revert it. Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
update_kpageflags: Ensure file descriptors are closed correctly on error If only opening only other of the files fails, the successfully opened file was not closed. This scenario is extremely unlikely, but should be fixed never the less. Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
Fix bug when showing process shared mappings The way page table tree is walked through nowadays requires that the process map data is incremented every time the page table tree is processed. Otherwise the last time the tree is processed, the counters are overwritten with the last values, which is most likely zeros. Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
print_pid_stats: Revert order of pageframe tree and process list are traversed The pageframe tree is usually quite big, in order of dozens of megabytes. The process list on the other hand is usually quite small, usually in the order of tens of kilobytes. The process list thus can fit entirely in L2 (or even in L1) cache whereas the pageframe tree most likely does not fit in any cache at all. Therefore, when calculating the pid statistics, walking through the page frame tree as many times as there are processes in the process list will likely cause very big traffic to the memory bus. Changing the ordering of the loops will significantly increase cache locality and reduce the memory bus traffic, decreasing the execution times a lot. Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>