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

proc: fix MemAvailable in /proc/meminfo to exclude tmpfs files #615

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

kyeongy
Copy link
Contributor

@kyeongy kyeongy commented Oct 3, 2023

The "total_cache" from memory.stat of cgroup includes the memory used by tmpfs files ("total_shmem"). Considering it as available memory is wrong because files created on a tmpfs file system cannot be simply reclaimed.

So the available memory is calculated with the sum of:

  • Memory the kernel knows is free
  • Memory that contained in the kernel active file LRU, that can be reclaimed if necessary
  • Memory that is contained in the kernel non-active file LRU, that can be reclaimed if necessary

The "total_cache" from memory.stat of cgroup includes
the memory used by tmpfs files ("total_shmem"). Considering
it as available memory is wrong because files created
on a tmpfs file system cannot be simply reclaimed.

So the available memory is calculated with the sum of:
 * Memory the kernel knows is free
 * Memory that contained in the kernel active file LRU,
   that can be reclaimed if necessary
 * Memory that is contained in the kernel non-active file
   LRU, that can be reclaimed if necessary

Signed-off-by: Kyeong Yoo <kyeong.yoo@alliedtelesis.co.nz>
Copy link
Member

@hallyn hallyn left a comment

Choose a reason for hiding this comment

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

Seems right to me.

@mihalicyn
Copy link
Member

Considering it as available memory is wrong because files created on a tmpfs file system cannot be simply reclaimed.

It can be reclaimed in fact (to the swap).

But anyways, this change looks good to me.

Thanks!

@stgraber stgraber merged commit 35ab918 into lxc:main Oct 4, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants