Re: page cache - process memory - disk read

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


Date: 26 Sep 2005 06:44:29 -0700

Hi Tommy ,

Thanks for your help.I think if i go on working on this issue,i will
clarify whether ocfs really uses direct io or not on my system:

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

-They are not mapped if you are simply doing read{v}/write{v} type
-I/O. Disk file content is placed into the kernel page cache and
-*copied* to your program buffer. If you are performing asynchronous
-I/O, this copy might not take place and the data can be written
-directly into the application buffer.

Do you mean the heap segment by saying program buffer and application
buffer?

char *buf ; buf=malloc(1000);

this buf is allocated inside the heap segment . And i think it does not
matter what i put inside it. I can store some file data inside the buf
, but since it is allocated inside the heap as anonymous page, it can
be paged out to the swap disk if necessary .

> 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 .
Sorry, no. Just because a page gets marked as dirty doesn't mean
that it every sees the swap device.

Imagine that the os wants to use the memory of buf in above. Doesnt it
first write it to the swap disk? (isnt it an inactive_dirty page ?) How
could it be possible to reuse this page without writing its contents to
the swap file?

-Ordinary file I/O always takes two copy operations:

-1) Disk content is copied from the media into kernel memory, the page
- cache; often by DMA hardware on the disk controller, so this is
- relatively fast.
-2) Bytes are copied between the kernel page cache and the application
- buffer by the kernel equivalent of memcpy(3). This is much slower
- than copy #1 above.
-Various schemes exist to speed up or eliminate copy #2. Check into
-asynchronous I/O, for an example.

How could copy#2 be faster than copy1? (I think here the copy1 is done
after the data is read from the disk.)

My system doe not support async io , here do you mean kernel asycnio?

At the same time , i have the same topic under the solaris group .:

http://groups.google.com/group/comp.unix.solaris/browse_frm/thread/2595574ca91042ff/c414cc52b5e17ed3?lnk=st&q=hopehope_123&rnum=1#c414cc52b5e17ed3

Kind Regards,
tolga



Relevant Pages

  • Re: syncronizing between two file descriptors open on the same file
    ... can collect data until some buffer is full and only then writes things ... cally to the disk, the data are then at least in a kernel buffer (you ... that's only needed for the higher level functions like fwriteto ...
    (comp.os.linux.development.apps)
  • Re: Software RAID-5 attempt to access beyond end of device...
    ... The reiserfs is on top of an lvm2 on top of a raid5 ... >information that has previously been stored on disk. ... Sep 7 20:32:04 cu kernel: Buffer I/O error on device dm-0, ... PCI: PCI BIOS revision 2.10 entry at 0xf1150, ...
    (Linux-Kernel)
  • Re: Spontaneous reboots
    ... yet I keep experiencing spontaneous reboots and crashes. ... > I have postfix handling mail and use cyrus-imap with virtual ... Page fault while in kernel mode ... > Disk errors: ...
    (freebsd-questions)
  • [PATCH 3/3] Add ext3 data=guarded mode
    ... buffer onto a list of things that must be written before a commit. ... a workqueue where the real work of updating the on disk i_size is done. ... When we start tracking guarded buffers on a given inode, ... and it also takes a reference on the buffer head. ...
    (Linux-Kernel)
  • Re: [PATCH RFC] ext3 data=guarded v6
    ... Fixup locking while deleting an orphan entry. ... Fixup O_DIRCECT disk i_size updates ... buffer onto a list of things that must be written before a commit. ... When we start tracking guarded buffers on a given inode, ...
    (Linux-Kernel)