Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements to /proc/meminfo #1672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion fs/proc/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,26 @@ static int proc_show_meminfo(struct proc_entry *UNUSED(entry), struct proc_data
struct mem_usage usage = get_mem_usage();
show_kb(buf, "MemTotal: ", usage.total);
show_kb(buf, "MemFree: ", usage.free);
show_kb(buf, "MemAvailable: ", usage.available);
show_kb(buf, "MemShared: ", usage.free);
show_kb(buf, "Active: ", usage.active);
show_kb(buf, "Inactive: ", usage.inactive);
show_kb(buf, "SwapCached: ", 0);
// a bunch of crap busybox top needs to see or else it gets stack garbage
show_kb(buf, "Shmem: ", 0);
show_kb(buf, "Buffers: ", 0);
show_kb(buf, "Cached: ", 0);
show_kb(buf, "Cached: ", usage.cached);
show_kb(buf, "SwapTotal: ", 0);
show_kb(buf, "SwapFree: ", 0);
show_kb(buf, "Dirty: ", 0);
show_kb(buf, "Writeback: ", 0);
show_kb(buf, "AnonPages: ", 0);
show_kb(buf, "Mapped: ", 0);
show_kb(buf, "Slab: ", 0);
// Stuff that doesn't map elsehwere
show_kb(buf, "Swapins: ", usage.swapins);
show_kb(buf, "Swapouts: ", usage.swapouts);
show_kb(buf, "WireCount: ", usage.wirecount);
Comment on lines +45 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So one thing that concerns me is that procfs is part of the Linux kernel ABI, and adding arbitrary stuff to it may break things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, as I recall, I was just replicating what I saw in /proc/meminfo on a 32 bit Intel VM I setup.

Or am I misunderstanding?

return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions platform/darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ struct mem_usage get_mem_usage() {
struct mem_usage usage;
usage.total = basic.max_mem;
usage.free = vm.free_count * vm_page_size;
usage.available = basic.memory_size;
usage.cached = vm.speculative_count * vm_page_size;
usage.active = vm.active_count * vm_page_size;
usage.inactive = vm.inactive_count * vm_page_size;
usage.wirecount = vm.wire_count * vm_page_size;
usage.swapins = vm.swapins * vm_page_size;
usage.swapouts = vm.swapouts * vm_page_size;
return usage;
}

Expand Down
5 changes: 5 additions & 0 deletions platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ struct cpu_usage get_cpu_usage(void);
struct mem_usage {
uint64_t total;
uint64_t free;
uint64_t available;
uint64_t cached;
uint64_t active;
uint64_t inactive;
uint64_t swapins;
uint64_t swapouts;
uint64_t wirecount;
};
struct mem_usage get_mem_usage(void);

Expand Down