Kernel record keeping of pages of an open()ed file

Winnie Williams winnie at jane.Jpl.Nasa.Gov
Thu Dec 14 06:46:23 AEST 1989


    I've been working on a Sun3/50 running SunOS 4.0.1, with 4.0.1 source.
I've been trying to understand how the kernel is doing some of its
record keeping of pages.  
    I have a small application that is opening a file, and repeatedly
lseeking the size of a page, and writing a character.
I've tried a variation that mmap's the file too.  Whatever the case,
the application rapidly sucks up all the pages of memory, 
bringing the machine down to
its minimum free.  I've been setting off a routine within the kernel on
a timed basis to try and account for how many pages each process holds.
I'm walking through all the processes' proc structures, through a struct
as, a struct hat, a struct pmgrp, a struct pment, to a struct page.  In
this way counting the pages each struct has.  As my application runs
the total number of pages held by the processes goes to zero or one,
including the process for the application I'm speaking of.  So where
are the pages of my opened file?  I thought they might be associated
with the file table.  So, I set off another routine in the kernel to
walk through the list of file structures, if the structure was being used
for a vnode (DTYPE_VNODE), I walked its data ptr to a vnode structure.
If the vnode was being used for a file (VREG), I walked a pointer in it
to a list of pages it held.  But, I still have a couple hundred pages in 
the system unaccounted for.  I even tried marking pages as I walked to them
and then walking all the pages to verify how many I had marked.  
Does anyone know for sure how I can get
to the pages of my open'd file?  Maybe it's in one of the two places
I'm looking and I'm not going about it correctly. If someone can shed any
light on the subject, I'd love it.  I'm really perplexed by this.  Feel
free to e-mail me directly as this may get down into some nitty gritty
details.

Thanks.
Winifred I. Williams
Image Analysis Systems Group
Jet Propulsion Laboratory
winnie at elroy.jpl.nasa.gov



More information about the Comp.unix.wizards mailing list