page cache - process memory - disk read

From: hopehope_123 (hopehope_123_at_yahoo.com)
Date: 09/23/05

  • Next message: hopehope_123: "Re: swap device io"
    Date: 22 Sep 2005 22:47:31 -0700
    
    

    Hi Gurus ,

    I need to understand the interaction between the page cache (which is
    used for file systemn data cache) , and virtual memory map of a process
    which uses data from the cache.

    Where does the pages which are read from the disk is mapped inside a
    process?

    Imagine a simple c program:

         char *buf;

         buf = (char *)malloc(1000);

    This buf is allocated inside the heap , or in detail it is first
    reserved (in swap file) ,and on demand , it is allocated (inside the
    phy.ram)

         Then imagine that the code has the following line:

         *buf = 65 ;

    So i modifed the contents the buffer.

    As far as i know , if the pages which are modified like this , needs to
    be written to the swap disk in order to be reused again .

    So if these pages pageout by the os , they are written to the swap
    file.

          Now consider that ,i start to read data files by using read ,or
    readv or pread system calls. ( readv and pread are the io calls which
    oracle or other database systems uses on unix)

    fdes=open("/data/spss/x1.dat",O_RDONLY);

    while (fdes)

    {

     printf("%d\n",read(fdes, buf,sz));

    }

    I wonder how things happen now.

    How the data blocks which are cached inside the page cache mapped to
    the process?

    If the file is read first time by this process , the file must be read
    from the disk. Then the blocks are cached inside the page cache. The
    page cache has no backing storage inside the swap file ,

    but instead it is directly mapped from the data file itself.

    (Is this correct?)

    When my process reads data from the disk , then does the page that is
    inside the page cache copied into the process map ? Or is it shared and
    no copy takes place?

     

    Kind Regards,

    tolga


  • Next message: hopehope_123: "Re: swap device io"

    Relevant Pages

    • Re: Is Greenspun enough?
      ... Most OSes memory map executables directly from the file system so code doesn't pollute the file cache or swap space. ...
      (comp.lang.lisp)
    • Re: Is Greenspun enough?
      ... Most OSes memory map executables directly from the file ... >> system so code doesn't pollute the file cache or swap space. ... but executables have a twist. ...
      (comp.lang.lisp)
    • Re: IA64 Linux VM performance woes.
      ... > At first the throughtput we are getting without file cache bypass is at around ... you're used to IRIX (or ever used the 2.6 layer). ... > and eventually all memory gets occupied by FS pages. ... That suggests you may be running with not much swap. ...
      (comp.sys.sgi.admin)
    • VM/Swap performance ideas
      ... I know it's slashdot, but this guy has a valid idea. ... You'll see that this person is proposing to allow disk cache pages to ... exist in ram for a given amount of time before dropping them in favor ... good solution to retrieving data in swap. ...
      (Linux-Kernel)
    • RE: why swap at all?
      ... If I have 16GB of ram should I use swap? ... from cache is nice, but having glibc in cache is also nice.) ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)