nigelargriffiths / AIX-Performance-Tools-Roll-Your-Own

Examples C code on using the AIX Perfstat Library as used in nmon, njmon and nimon
4 stars 1 forks source link

getprocs64.c - page size wrong ? #1

Open mawelo opened 1 week ago

mawelo commented 1 week ago

In AIX the page size can vary from process to process. AIX supports multiple page sizes (typically 4 KB and 16 KB, but it can also support larger page sizes in specific configurations, such as 64 KB, 1 MB, or 16 MB depending on hardware and OS configuration). Therefore e.g. to calculate the resident set size (RSS) accurately, you need to retrieve the page size specific to each process. So in my opinion this line is problematic: (int)procs[i].pi_size4, / convert pages to KBytes */

nigelargriffiths commented 1 week ago

Hi, Interesting question - here are my comments. First. a single process can have multiple pages sizes and the kernel can migrate between the page sizes on the fly. Second, the getprocs() and getproces64() system calls pre-date AIX having multiple page sizes by many years, so this is not reflected in the data returned by these functions. The pi_size from the hearer file: unsigned long pi_size; / size of image (pages) / is in number of 4KB pages. A bit of a shame it does not actually state that but then the C comment pre-dates any ideas of multiple page sizes.

I would expect the functions to to the maths for us to return the 4KB page count. This is so that older programs using the data structure do not have to change and will not fail on news AIX releases. If you doubt that then you could raise an AIX support case.

mawelo commented 5 days ago

Hi Nigel, thank you very much for your reply. I believe you are correct in your assessment regarding the functions to match for us to return the 4KB page number. Based on your reasoning, this seems perfectly logical to me and very well-founded.