Re: Viewing virtual memory locations from the command line ??

2009-09-15 Thread Bryn M. Reeves
On Mon, 2009-09-14 at 14:32 -0400, William Case wrote:
 Hi;
 
 I can use gnome-system-monitor with the Ctrl-M key to view memory
 addresses for various processes.  It will show me a pop-up window with |
 VM Start | VM End | VM Size | Flags | VM Offset | etc.
 
 What would be the command line equivalent ?  

cat /proc/pid/maps

E.g.: http://pastebin.com/m3f70e9bb

The columns are vmstart-vmend, perms, offset, device major:minor, inode
number and path (if one exists). See the man proc for more information
or the file filesystems/proc.txt in the kernel documentation directory.

Kernels since 2.6.14 also include an option for a smaps file which
gives additional information on the RSS and status of pages for each
mapped segment.

 Besides user process addresses, I would like to see kernel processes
 addresses on stdout.  My understanding is that Virtual Memory for the
 kernel map to the same addresses as their physical addresses, so either
 view would do.  Also, my understanding is that Virtual Memory creates a
 buffer in physical memory where it keeps the VM structure; similarly for
 a DMA buffer.  I would like to view them as well -- at least once.

Not sure what you're looking for here - the maps and smaps files only
make sense for user space processes since kernel threads do not have
their own address space (the mm field in the relevant task struct is
NULL). All code running in kernel mode uses the same more-or-less flat
address space (although there's a fixed offset between most kernel
virtual addresses and the corresponding physical address - see the
PAGE_OFFSET constant). There is a limited window of addresses used for
dynamic kernel mappings (vmalloc) but the majority of the kernel's
address space is statically mapped and does not change over time.

There are system-wide files in /proc like meminfo, slabinfo, buddyinfo,
pagetypeinfo, vmallocinfo, vmstat and zoneinfo that provide information
on the state of various memory related subsystems in the kernel - see
the proc documentation for more details.

You can also use tools like crash[1] or systemtap[2] to look at the
behavior of a running system and examine the values of kernel data
structures as they change.

 To avoid anyone spending a lot of time on long explanations, I just need
 someone to point me in the right direction re: commands.  If I have
 stated some mis-assumptions here, don't worry about it.  I have several
 kernel and architecture texts and I am just starting my closer look.

Have a look at the notes on linux-mm.org, e.g.:

http://linux-mm.org/VirtualMemory

There's also a very good introduction to all this in the early chapters
of Understanding the Linux Kernel by Bovet and Cesati:

http://oreilly.com/catalog/978059628/

[1] http://people.redhat.com/anderson/
[2] http://sourceware.org/systemtap/

Regards,
Bryn.


-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: [Bulk] Re: Viewing virtual memory locations from the command line ??

2009-09-15 Thread William Case
Hi Bryn;

On Tue, 2009-09-15 at 10:34 +0100, Bryn M. Reeves wrote:
 On Mon, 2009-09-14 at 14:32 -0400, William Case wrote:
  Hi;
  

Thanks.  That was a very thorough answer.  Luckily, I have
'Understanding the Linux Kernel' by Bovet and Cesati.  In fact, it was
in preparation to reading/studying their text that I wanted to draw an
outline of memory use!

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Viewing virtual memory locations from the command line ??

2009-09-14 Thread William Case
Hi;

I can use gnome-system-monitor with the Ctrl-M key to view memory
addresses for various processes.  It will show me a pop-up window with |
VM Start | VM End | VM Size | Flags | VM Offset | etc.

What would be the command line equivalent ?  

I am assuming that such a command line equivalent would have more
refinements than gnome-system-monitor.  I have tried ps, vmstat,
cat /proc/*/stat, but have not been able to get what I want to see  --
the actual address and offset.

Besides user process addresses, I would like to see kernel processes
addresses on stdout.  My understanding is that Virtual Memory for the
kernel map to the same addresses as their physical addresses, so either
view would do.  Also, my understanding is that Virtual Memory creates a
buffer in physical memory where it keeps the VM structure; similarly for
a DMA buffer.  I would like to view them as well -- at least once.

I have three reasons for doing this;

1) I am currently looking closer at how RAM memory is used.  And, like
the guy from Missouri said seeing is believing.

2) I want to draw a representation of what is in memory at any given
time, just to fix memory operations better in my mind

3) My frustration level is almost boiling over after having spent the
morning trying to find a command line command that will show me
addresses.  Now I just want to know how, or if, it can be done from the
command line.

To avoid anyone spending a lot of time on long explanations, I just need
someone to point me in the right direction re: commands.  If I have
stated some mis-assumptions here, don't worry about it.  I have several
kernel and architecture texts and I am just starting my closer look.

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines