Skip to contentSkip to conversation

Inconsistancies in /proc (status vs statm) leading to wrong documentation (proc.txt)

DISCUSSION Albert Cahalan 2 participants 6 messages Oct 9, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 10 lines · Eric Valette

I'm currently trying use mlockall for a soft RT application and was concerned by the memory usage of my (big) RT process. So I stated to look at /proc/<PID>/status and /proc/<PID>/statm and then to the documentation of statm (Documentation/filesystem/proc.txt) because unexplained values are rather useless.

The doc currently says :
-------------------------------------------------------------------------
Field Content
size total program size (pages) (same as VmSize in status)

The documentation is incorrect. It was written to match a buggy implementation in early 2.6.x kernels.

VmSize is the address space occupied, excluding memory-mapped IO. The statm value is the address space occupied.

Quoted 2 lines

May I suggest :
- To use consistent memory size units between status and statm,

No way. This would instantly break the "top" program.

#1 lore raw
Quoted 2 lines · Albert Cahalan

The documentation is incorrect. It was written to match a buggy implementation in early 2.6.x kernels.

Well the Documentation is said to matches 2.6.8-rc3 and is only 5 weeks old according to bitkeeper changesets... So at least the doc should be fixed.

Quoted 2 lines

VmSize is the address space occupied, excluding memory-mapped IO. The statm value is the address space occupied.

Why removing memory-mapped IO in one case (status) and not the other (statm)? Memory mapped IO, may of course reserve some physical memory pages for establishing the mmu->phys adress translation table (if any) but not really the amount of space mapped.

Quoted 4 lines
Quoted 2 lines

May I suggest :
- To use consistent memory size units between status and statm,

No way. This would instantly break the "top" program.

OK. Too bad because statm is hardly readable but I guess it is not for human then...

Thanks for responding,

-- eric

#2 lore raw
Quoted 8 lines · Eric Valette
Quoted 2 lines · Albert Cahalan

The documentation is incorrect. It was written to match a buggy implementation in early 2.6.x kernels.

Well the Documentation is said to matches 2.6.8-rc3 and is only 5 weeks old according to bitkeeper changesets... So at least the doc should be fixed.

Removal would be simpler.

Quoted 7 lines
Quoted 2 lines

VmSize is the address space occupied, excluding memory-mapped IO. The statm value is the address space occupied.

Why removing memory-mapped IO in one case (status) and not the other (statm)? Memory mapped IO, may of course reserve some physical memory pages for establishing the mmu->phys adress translation table (if any) but not really the amount of space mapped.

First of all, because that's the way it's been done. This interface goes back to the Linux 1.0.xx days.

Second of all, because you get more information this way. You can subtract to determine the address space used for IO alone.

I could go for another number: available address space. Then I could display percent used.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

May I suggest :
- To use consistent memory size units between status and statm,

No way. This would instantly break the "top" program.

OK. Too bad because statm is hardly readable but I guess it is not for human then...

Even the other files are only partly for humans. Minor changes will cause many tools to break.

#3 lore raw
Quoted 4 lines · Albert Cahalan
Quoted 1 line

Well the Documentation is said to matches 2.6.8-rc3 and is only 5 weeks old according to bitkeeper changesets... So at least the doc should be fixed.

Removal would be simpler.

I beg to disagree. statm catche eyes when you want to know precisely your memory usage or do you consider to be the single statm user via procps?

Quoted 3 lines

Second of all, because you get more information this way. You can subtract to determine the address space used for IO alone.

Sure but displaying it via status information would be much more simple furthermore I think it is incorrectly computed.

Quoted 2 lines

I could go for another number: available address space. Then I could display percent used.

The free command does provide the information I think so it must be somewhere else...

Quoted 2 lines

Even the other files are only partly for humans. Minor changes will cause many tools to break.

Sure but many people in the embedded wolrd need to know precisley process memory usage and possibly inside the program itsel not via top/ps/free/...

And if tools display wrong information for ages, then it can still be fixed...

Signature · 7 lines
   __
  /  `                   	Eric Valette
 /--   __  o _.          	6 rue Paul Le Flem
(___, / (_(_(__         	35740 Pace

Tel: +33 (0)2 99 85 26 76	Fax: +33 (0)2 99 85 26 76
E-mail: [email protected]
#4 lore raw
Quoted 11 lines · Eric Valette
Quoted 6 lines · Albert Cahalan
Quoted 3 lines

Well the Documentation is said to matches 2.6.8-rc3 and is only 5 weeks old according to bitkeeper changesets... So at least the doc should be fixed.

Removal would be simpler.

I beg to disagree. statm catche eyes when you want to know precisely your memory usage or do you consider to be the single statm user via procps?

Not quite, but close. Those that know are willing to read the kernel code, including that of past releases, can certainly use the statm file.

Quoted 5 lines
Quoted 2 lines

I could go for another number: available address space. Then I could display percent used.

The free command does provide the information I think so it must be somewhere else...

Not at all. The free command is not per-process, and doesn't ever deal with address space. It deals with RAM.

For example, on a typical i386 box, you have almost 3 GB of address space available. (minus a bit at the top for syscall handling, and perhaps minus a page at address 0) The portion of this in use is of interest.

Quoted 6 lines
Quoted 2 lines

Even the other files are only partly for humans.
Minor changes will cause many tools to break.

Sure but many people in the embedded wolrd need to know precisley process memory usage and possibly inside the program itsel not via top/ps/free/...

For that, go directly to /proc/*/maps and be happy. You may also want the RSS from /proc/*/status.

#5 lore raw
Quoted 3 lines · Albert Cahalan

Not quite, but close. Those that know are willing
to read the kernel code, including that of past
releases, can certainly use the statm file.

Sure but it while doing that after readding the official documentation that the trouble began...

Quoted 1 line

For that, go directly to /proc/*/maps and be happy.

That's a good point. Very usefull for knowing which dynamic library account for what size. I start wondering if dynamic libraries and mlockall works well toghether..

Quoted 1 line

You may also want the RSS from /proc/*/status.

Well RSS = VmSize after mlockall I guess

Thanks for the maps hint,

-- eric