Re: Thread implementations...
From: Stephen C. Tweedie <hidden>
Date: 1998-06-30 19:10:01
Hi, On 30 Jun 1998 01:19:18 -0500, ebiederm+eric@npwt.net (Eric W. Biederman) said:
Again the case was: I have a multithreaded web server serving up files. The web server mmaps each file, and calls madvise(file_start, file_len, MADV_SEQUENTIAL). The trick is that it may be serving the say file to two different clients simultaneously.
The actual sharing is not a problem; the cache is already safe against that even when doing readahead.
MADV_SEQUENTIAL implies readahead, and forget behind, but for a simple process.
Yep, the forget behind is the important stuff to get right, but all we need to do there is to unmap the pages from the process's address space: we don't need to actually flush the page cache. As long as the page cache can find these pages quickly if it needs to reuse the memory for something else, then there's no reason to actually forget the data there and then.
The forget behind is tricky and difficult to get right, but if we concentrate on aggressive readahead (in this we will probably be o.k.)
Not for very large files: the forget-behind is absolutely critical in that case. --Stephen