[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Physical memory size allocated for each process!
On Thu, Nov 13, 2003 at 10:55:57PM +0100, Jan Hudec wrote:
|On Thu, Nov 13, 2003 at 08:19:36 -0400, Allan.Bezerra@indt.org.br wrote:
|> Hi all,
|>
|> I was trying to get the stack, heap, data and code size separately allocated in physical memory but I did not manage to get them from /proc.
|>
|> I took a look the linux kernel source 2.6, but I did not discover any variables or structures about stack, heap, data and code size allocated in physical memory.
|>
|> I just found those information allocated in virtual memory.
|>
|> Please, could anybody help me?
|
|AFAIK there is no such information collected anywhere. AFACT it's
|actualy impossible. When process allocates memory, kernel only adds an
|entry into it's page table. The allocation is accounted for, but the
|allocated page does not exist anywhere -- it's only a promiss.
. and this is the demand paging. What you say is not true at all.
If you look at sys_brk (mm/mmap.c) you will find the following
assignment:
mm->brk = brk;
(where brk is the start heap address)
so .. one more time: please refer to the struct mm_struct
in include/sched.h
(BE AWARE:this struct appears in struct task_struct, the process
descriptor)
on every stack/heap grow/shrink the mm struct values of a given process
are correctly updated with no need to wait for a "demand page".
|The page is actualy allocated in a page fault handler when the process
|tries to access it.
yes, this is true .. but even if a page fault doesn't occours
the process descriptor (its mm struct) is updated correctly whenever
a new VMA is added.
|It does not bother to look, whether it's a code,
|data, stack, etc. page. It only looks whether the page exists and from
|what file (or swap) it should be loaded.
Be AWARE: The stack is not mmapped.
--
Daniele.
"I could have made money this way, and perhaps amused myself writing code.
But I knew that at the end of my career, I would look back on years of
building walls to divide people, and feel I had spent my life making the
world a worse place."
Richard Stallman
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/