From e780eaa45f97dd379900d269d1bb0c7b0b0af4d5 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 3 Oct 2023 10:38:30 +0300 Subject: [PATCH] meminfo: Print allocated physical memory percentage --- userspace/meminfo/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/userspace/meminfo/main.cpp b/userspace/meminfo/main.cpp index 222b1c2c..147fae24 100644 --- a/userspace/meminfo/main.cpp +++ b/userspace/meminfo/main.cpp @@ -82,8 +82,9 @@ int main() perror("read"); 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(" 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);