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

Fix linux filesystem cache calculation #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 5 additions & 4 deletions src/os/linux/linux_sigar.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,

int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
{
sigar_uint64_t buffers, cached, kern;
sigar_uint64_t kern = 0;
char buffer[BUFSIZ];

int status = sigar_file2str(PROC_MEMINFO,
Expand All @@ -336,10 +336,11 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
mem->free = sigar_meminfo(buffer, MEMINFO_PARAM("MemFree"));
mem->used = mem->total - mem->free;

buffers = sigar_meminfo(buffer, MEMINFO_PARAM("Buffers"));
cached = sigar_meminfo(buffer, MEMINFO_PARAM("Cached"));
/* Filesystem cache; the 'Cached' item includes swap-backed shmem */
kern += sigar_meminfo(buffer, MEMINFO_PARAM("Active(file)"));
kern += sigar_meminfo(buffer, MEMINFO_PARAM("Inactive(file)"));
kern += sigar_meminfo(buffer, MEMINFO_PARAM("SReclaimable"));

kern = buffers + cached;
mem->actual_free = mem->free + kern;
mem->actual_used = mem->used - kern;

Expand Down