Discussion:
evicting pages
(too old to reply)
Tom Brubaker
2005-04-08 20:24:48 UTC
Permalink
Am I correct in assuming that only Pageable Pages can evict other Pageable
Pages? Similarly, can we assume that Alloc_Page (but not
Alloc_Pageable_Page) will always find a free page to allocate?

-Tom-
Tim Finley
2005-04-08 22:44:31 UTC
Permalink
Post by Tom Brubaker
Am I correct in assuming that only Pageable Pages can evict other Pageable
Pages? Similarly, can we assume that Alloc_Page (but not
Alloc_Pageable_Page) will always find a free page to allocate?
-Tom-
Well I don't think that Alloc_Page should ever involve itself in the
pageing system you've implemented. To me it seems like Alloc_Page is the
basic unit of memory allocation in Geekos (I think that Malloc eventually
boils down to Alloc_Page at some point). So Alloc_Page should always give
you the next available page on the free list and if there are not pages
left, Alloc_Page should cause a crash since you are out of memory.

So anyways, I agree with you that swapping should only deal with pages
that are flagged as pageable. I'm fairly sure that you could implement a
kernel in (mostly) pageable memory with some effort, but we are not trying
to do that here.

Tim
Iulian Neamtiu
2005-04-09 00:32:35 UTC
Permalink
Post by Tim Finley
Well I don't think that Alloc_Page should ever involve itself in the
pageing system you've implemented.
Well it gets in because directories and page tables are allocated via
Alloc_Page()...Suppose you've spawned a process that eats up the freelist,
(rec 3300 for instance) and you try to spwan another process before
that rec 3300 exits/frees pages. Where will you take pages for the page
tables and page directories from ?
Post by Tim Finley
To me it seems like Alloc_Page is the
basic unit of memory allocation in Geekos (I think that Malloc eventually
boils down to Alloc_Page at some point).
Not exactly. See that line at the beginning
"X KB memory detected, Y pages in freelist, Z bytes in kernel heap" ?
Alloc_Page() returns you pages from the freelist and Malloc() takes memory
from the kernel heap. They don't overlap.
Post by Tim Finley
So Alloc_Page should always give
you the next available page on the free list and if there are not pages
left, Alloc_Page should cause a crash since you are out of memory.
So anyways, I agree with you that swapping should only deal with pages
that are flagged as pageable. I'm fairly sure that you could implement a
kernel in (mostly) pageable memory with some effort, but we are not trying
to do that here.
Tim
Iulian Neamtiu
2005-04-09 00:23:39 UTC
Permalink
Post by Tom Brubaker
Am I correct in assuming that only Pageable Pages can evict other Pageable
Pages?
Yep, that's guaranteed by the
g_pageList[i].flags & PAGE_PAGEABLE
test in Find_Page_To_Page_Out()
Post by Tom Brubaker
Similarly, can we assume that Alloc_Page (but not
Alloc_Pageable_Page) will always find a free page to allocate?
I'm afraid that's not true. If you're out of free pages and
call Alloc_Page() it will return 0, in which case you need to evict.

How about this trick : If Alloc_Page() returns 0, call
Alloc_Pageable_Page() which is never supposed to fail (unless you're out
of swapping space, but in that case it's OK to halt) and then force
the page non-pageable via
Get_Page((ulong_t) paddr)->flags &= ~(PAGE_PAGEABLE)


Iulian
Continue reading on narkive:
Loading...