lkml.org 
[lkml]   [1998]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: swap cache
Hi,

On Thu, 17 Dec 1998 11:09:34 -0500 (GMT), Prasun Kapoor
<prasun@wipinfo.soft.net> said:

>> Stephen:
>> No, we can't do that. The swap cache allows us to have multiple
>> processes sharing the same page of swap (think of a process which gets
>> partially swapped out and which then forks).

...

> The pages that go to the swap are anonymous pages (stack, heap, data et
> al) and the way two procceses share these pages is when they
> are a parent-child pair. Based on how traditional fork() works,
> all such anonymous pages are shared by the parent and child on COW
> basis.

Yep.

> This to me looks like a cleaner implemetation, where fork takes care of
> COW functionality and hence sharing of clean swap pages.

That has nothing to do with it. Think about it for a minute. fork() is
how COW-shared pages are generated in the first place. Yep, we do
that.

What then happens if one of the related processes starts to page stuff
in _after_ the sharing has been set up in swap? What happens if we
start to swap in-core COW stuff out _after_ the sharing has been set up
in memory?

Umm, you're telling me that fork will take care of this clean page
sharing for me? I don't think so: fork is a dim and distant memory by
this point. The swap cache relates physical pages in memory to swap
pages on disk. It is the mechanism by which we maintain that clean
sharing you want, even after the fork, and even if some processes still
refer to the original page on swap but others have paged the data back
into memory.

>> Stephen Tweedie and all the others will explain better than I will, but
>> anyway: the swap cache allows *clean* pages to be in swap and memory at
>> the same time.

> I think all swap pages start off as dirty. eg first time one writes to
> malloc()ed memory, a physical page is allocated along with its backing
> swap. So once this dirty page is written to the swap, it becomes
> clean. Further writes make it dirty again. The point is the dirty bit is
> always sufficient to figure out whether the page needs to go to disk or
> not.

That misses the point: if the page is shared, we *cannot* let anybody
write to it. That's the ENTIRE point of copy-on-write. COW pages are
always clean and always readonly, by necessity, and that will never change.

> As far as sharing of clean swap pages goes, fork takes care of it.

As I've just explained, that is wishful thinking. We still have to
maintain the sharing beyond fork(), while potential sharers of the page
swap stuff pages and out independently of each other.

> Solaris has a new way of dealing with swap, where there is no one-to-one
> correspondence between an anonymous page and its backing store on disk.
> Also a part of RAM is used as swap file. I am not sure if linux also
> supports such implementation.

Think again. The swap cache *IS* a (partial) one-to-one correspondence
between anonymous pages in memory and backing store on disk. It's
nothing new.

--Stephen


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.058 / U:0.964 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site