Re: how to get physical memory address from virtual memory address

Tim Roberts wrote:
"David Schwartz" <davids@xxxxxxxxxxxxx> wrote:
Hari wrote:
Hi ,

I am using Linux 2.4.20 Kernel. I am runing an application which will
malloc and returns a virtual memory address. I need to get the physical
memory address for that virtual memory address. How can I get that?
There isn't one. You haven't allocated any physical memory, so the
kernel doesn't give you any.

What?? This is entirely incorrect. EVERY valid virtual address has an
associated physical address. In the case of malloc-ed memory, that
physical address will be in physical memory.

Addressing the OP, while you are in user mode, the physical address can
change at any time. The only reliable way to get the physical address is
within a kernel driver.

Where does the physical memory come from when you turn on virtual memory
overcommits? Look at Documentation/vm/overcommit-accounting in your
kernel sources. Setting vm.overcommit_memory=1 is indeed useful in some
circumstances but can lead to unpredictable process deaths.

Dr. Douglas O'Neal
Manager, Bioinformatics Center
Delaware Biotechnology Institute
(302) 831-3456