You are not logged in.

#1 2014-03-27 16:41:13

simendsjo
Member
Registered: 2012-09-27
Posts: 113

Make `tmpfs` usage show as ram usage

I'm using some `tmpfs` partitions, the biggest offender being `/tmp`. A problem I've encountered a couple of times is that RAM usage might increase without me noticing.
The problem is that no tools seems to add `tmpfs` usage to used RAM.

Is there a way around this?

Offline

#2 2014-03-27 17:29:15

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Make `tmpfs` usage show as ram usage

Moving to Kernel & Hardware...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2014-03-27 18:05:49

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Make `tmpfs` usage show as ram usage

I believe data in tmpfs is counted (by the kernel) either as cache or swap.

You could perhaps simply monitor the size of tmpfs filesystems with df.

Offline

#4 2014-03-27 18:10:16

simendsjo
Member
Registered: 2012-09-27
Posts: 113

Re: Make `tmpfs` usage show as ram usage

lucke wrote:

I believe data in tmpfs is counted (by the kernel) either as cache or swap.

You could perhaps simply monitor the size of tmpfs filesystems with df.

This is far from a problem in the regular case, but if I'm compiling in /tmp it grows quite quickly, and the OS never understands I'm running out of memory to begin swapping.

Offline

#5 2014-03-27 18:13:28

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Make `tmpfs` usage show as ram usage

Maybe your swappiness is set to 0 or a low value?

I try either not to use tmpfs on /tmp or not to compile in /tmp.

Offline

#6 2014-03-27 18:17:27

simendsjo
Member
Registered: 2012-09-27
Posts: 113

Re: Make `tmpfs` usage show as ram usage

lucke wrote:

Maybe your swappiness is set to 0 or a low value?

I try either not to use tmpfs on /tmp or not to compile in /tmp.

I have swappiness of 60, but I have 8GB RAM, so I don't swap often. In fact, I don't think it's swapped at all.
This is the reason why I have /tmp as ramfs too.

If it's not possible to make Linux count tmpfs as RAM usage, I guess I'll just have to be careful if using a tmpfs for something heavy.
I still think it should be possible though.. It's using RAM, so why shouldn't it handle it as such?

Offline

#7 2014-03-27 18:29:51

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Make `tmpfs` usage show as ram usage

What happens to your PC when you're compiling something big in /tmp?

It normally swaps out stuff that hasn't been touched for a while (with that while getting shorter the greater the memory pressure gets). Non-droppable cache should be seen as used RAM, and stuff from tmpfs should be swapped out if need be. But maybe the kernel doesn't see the need to swap anything (processes) out. And maybe it is unwilling to swap out stuff that is being worked on in tmpfs.

Offline

#8 2014-03-27 19:03:26

simendsjo
Member
Registered: 2012-09-27
Posts: 113

Re: Make `tmpfs` usage show as ram usage

lucke wrote:

What happens to your PC when you're compiling something big in /tmp?

It normally swaps out stuff that hasn't been touched for a while (with that while getting shorter the greater the memory pressure gets). Non-droppable cache should be seen as used RAM, and stuff from tmpfs should be swapped out if need be. But maybe the kernel doesn't see the need to swap anything (processes) out. And maybe it is unwilling to swap out stuff that is being worked on in tmpfs.

Doh! I just noticed that what I thought was the issue wasn't! I've set /tmp to 4GB while I have 8GB RAM! So the issue was actually lack of space on the file system.
I probably did this exactly to avoid eating up all the RAM when I set up the system.

The original question still stands, but the "reason" and how I found out about this doesn't hold.

Offline

#9 2014-03-27 19:17:00

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Make `tmpfs` usage show as ram usage

By default tmpfs filesystems are set to a half of RAM.

Offline

#10 2014-03-27 19:18:43

simendsjo
Member
Registered: 2012-09-27
Posts: 113

Re: Make `tmpfs` usage show as ram usage

lucke wrote:

By default tmpfs filesystems are set to a half of RAM.

Thanks, didn't know that. Looking at fstab, there's no indication of any size, and I see the other tmpfs's are 4GB too.

Offline

#11 2014-03-27 19:21:11

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Make `tmpfs` usage show as ram usage

Have a look at https://www.kernel.org/doc/Documentatio … /tmpfs.txt , if you haven't.

-edit-

If you want to see it swapping indeed, run "mount -o remount,size=90% /tmp", install dstat from the community repo, run "dstat -dmgs", copy whatever big you have to /tmp to fill it, observe dstat's output.

Last edited by lucke (2014-03-27 19:39:13)

Offline

Board footer

Powered by FluxBB