meminfo: Print allocated physical memory percentage

This commit is contained in:
Bananymous 2023-10-03 10:38:30 +03:00
parent 44cb0af64f
commit e780eaa45f
1 changed files with 2 additions and 1 deletions

View File

@ -82,8 +82,9 @@ int main()
perror("read"); perror("read");
else else
{ {
size_t percent_times_100 = 10000 * meminfo.phys_pages / meminfo.virt_pages;
printf(" vmem: %zu pages (%zu bytes)\n", meminfo.virt_pages, meminfo.page_size * meminfo.virt_pages); printf(" vmem: %zu pages (%zu bytes)\n", meminfo.virt_pages, meminfo.page_size * meminfo.virt_pages);
printf(" pmem: %zu pages (%zu bytes)\n", meminfo.phys_pages, meminfo.page_size * meminfo.phys_pages); printf(" pmem: %zu pages (%zu bytes) %zu.%02zu%%\n", meminfo.phys_pages, meminfo.page_size * meminfo.phys_pages, percent_times_100 / 100, percent_times_100 % 100);
} }
close(fd); close(fd);