Here's some fun stuff to take a look at if you want to poke around looking
at some VM data structures..
Lets look at a particular process's address space on my system:
# mdb -k
Loading modules: [ unix krtld genunix specfs ufs ip sctp usba uhci s1394 fctl
nca lofs audiosup zfs random nfs sppp ptm ipc crypto ]
> ::ps
S PID PPID PGID SID UID FLAGS ADDR NAME
...
R 1054 1036 753 753 90119 0x4a014000 ffffffff84d16560 mozilla-bin
...
Take the address of the proc structure, follow the process's address space
pointer, to walk the mapped segments in the process address space:
> ffffffff84d16560::print proc_t p_as |::walk seg |::seg
SEG BASE SIZE DATA OPS
ffffffff83047f38 0 1000 ffffffff83028780 segvn_ops
ffffffff847e4ca8 8030000 18000 ffffffff847e5768 segvn_ops
ffffffff847e4bd0 8050000 3c000 ffffffff847e5630 segvn_ops
ffffffff847e4870 809b000 6000 ffffffff847e5150 segvn_ops
ffffffff847e9878 80a1000 35f000 ffffffff847e8898 segvn_ops
ffffffff847e4558 8400000 1000000 ffffffff847e3c50 segvn_ops
ffffffff856c8e10 f9e20000 1000 ffffffff856c9078 segvn_ops
...
Taking a look at the first segvn segment's private data, we can get the pointer
to the vnode (or the anon_map), in the case of anonymous memory:
> ffffffff83028780::print "struct segvn_data"
{
lock = {
_opaque = [ 0 ]
}
segp_slock = {
_opaque = [ 0 ]
}
pageprot = 0
prot = 0xd
maxprot = 0xf
type = 0x2
offset = 0
vp = 0xffffffff83116140
anon_index = 0
amp = 0
vpage = 0
cred = 0xffffffff81ca31e0
swresv = 0
advice = 0
pageadvice = 0
flags = 0x90
softlockcnt = 0
policy_info = {
mem_policy = 0x1
mem_reserved = 0
}
}
The ->vp pointer is the vnode, off of which hanges a list of page_t
structures...
Looking at a few interesting fields of struct vnode:
> 0xffffffff83116140::print vnode_t v_pages v_path
v_pages = 0xfffffffffb533238
v_path = 0xffffffff8301a358 "/lib/libw.so.1"
Looks like a mapping for libw. :)
v_pages is a list of page_t's which you can pointer chase. But even
easier is to use mdb's page walker... just give it the address of the vnode:
> 0xffffffff83116140::walk page
fffffffffb533238
... which isn't too exciting in this example...as the vnode has only a single
page.
> fffffffffb533238::print page_t
{
p_offset = 0
p_vnode = 0xffffffff83116140
p_selock = 0
p_selockpad = 0
p_hash = 0xfffffffff7d83a18
...
}
So you get the idea. ::print is really your friend here, and it's helpful
keeping a browser window with cvs.opensolaris.org handy while you are pointer
chasing.
Have fun.
-Eric
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code