Re: Caching behavior on Linux 2.4.18 for block devices

From: Robert Newson (ReapNewsB_at_bullet3.fsnet.oc.ku)
Date: 05/29/04


Date: Sat, 29 May 2004 20:28:15 GMT

Victor Nazarov wrote:

> Yipkei Kwok wrote:
>
>> Hi folks,
>>
>> On Linux 2.4.18, when a process requests a block that is already in
>
> What did you meant by request? Processes use system calls to talk to the
> kernel.
>
>> the block cache, does the kernel map the block cache containing that
>> block to the requesting process's address space OR copy the content to
>> the requesting process's address space?
>>
>> If the answer is the first one, what will happen if >1 processes are
>> sharing the block cache but 1 of them intends to modify the content?
>
> As I know, when process use read system call, kernel always copy
> required contents of one or several blocks from cache to buffer in
> process' adress space. So process can do almost everything with it's
> buffer.

I dunno if the Linux kernel uses it, but there has been in the past (in
another *nix) a "copy-on-write" flag associated with pages - useful during
fork(): when a process forks, all pages are mapped into the parent and child
address spaces and marked as "copy-on-write"; only when either the parent or
child tries to write is the actual copy made. [Particularly useful with
fork() as that's more often than not shortly followed by an exec() which
would throw away all the just copied pages.]



Relevant Pages