[haiku-gsoc] Re: Basic Idea (swap file)
- From: ingo_weinhold@xxxxxx
- To: haiku-gsoc@xxxxxxxxxxxxx
- Date: Mon, 16 Jun 2008 18:13:41 +0200
Replying on the list...
On 2008-06-16 at 16:42:08 [+0200], Zhao Shuai <upczhsh@xxxxxxx> wrote:
> >OK, thank. So how do you plan to implement it?
>
> Several members will be added to struct anonymous_store to represent one
> swap file.
> The most 2 important fields will be:
> vnode *vnode; //represent the swap file
> short *swap_map; //Pointer to an array of counters, one for each
> page slot in the
> // swap file. 0: the page slot is free,
> >0:page slot in use
What do the swap_map elements count? Apparently it's supposed to be some kind
of usage counter, but how would a single slot be used more than once?
> A global array tells how many swap files in the system:
> #define MAX_SWAPFILES 32
> anonymous_store swap_info[MAX_SWAPFILES];
That's a conceptual misunderstanding. Haiku has a store per cache, not per
swap file. You need to manage swap files via separate structures and in some
way reference them by the stores. Please re-read the proposal for a simple
swap file implementation, I wrote earlier. It's probably not particulary
efficient or elaborated, but it demonstrates how the different entities are
related.
> When a page is swapped out, replace it's page table entry with a
> constructed one:
> the PRESENT bit(bit 0) will be zeroed(means it's invald), bit 1-25 gives
> the
> page slot index in the swap,bit 26-31 gives the swap file index in the
> swap_info
> array. In this way we can retrieve a page in the swap area when page
> faults.
This is not going to work with Haiku's VM. For one it's architecture specific
and might not work in a similar way on other architectures. More importantly,
though, a page belongs to cache and it doesn't have to be mapped in any
address space at the point it is swapped out.
CU, Ingo
Other related posts:
- » [haiku-gsoc] Re: Basic Idea (swap file)