Re: fork: out of memory

Stephen C. Tweedie (sct@dcs.ed.ac.uk)
30 Nov 1997 17:09:08 +0000


Hi,

"Theodore Y. Ts'o" <tytso@MIT.EDU> writes:

>
> From: alan@lxorguk.ukuu.org.uk (Alan Cox)
> Date: Sat, 29 Nov 1997 11:39:02 +0000 (GMT)
>
> Firstly there is no real way to say
>
> swap_out(physical_address);
>
> and work back to the virtual addresses and remap the pages.
>
> One of the things which BSD kernels have is an array of structures, one
> structure per page of physical memory, allocated at boot time.
> Obviously, this structure is very small and efficiently utilized, and
> even then it takes up a non-trivial amount of memory. However, it does
> seems to make a number of tasks much easier, since it allows you to go
> back from a physical address to how/where the page is used.

We already have this. The mem_map[] array is precisely such a structure,
and it contains (amongst other things) pointers to each page's mapped
inode, its page-ring of buffer_heads, and the swap location caching that
page.

To get back to all of the VM references to a single page takes more than
just this single page structure, however. We would have to scan the
entire mapping list for the inode owning page, or the appropriate ptes
for any processes owning the page if it is a data page. Fortunately,
the latter could be made a lot easier very simply, just by adding a
single new value to the struct page --- a single data page may be mapped
into multiple processes, but it ought to be at the same virtual address
in each, so having the VA will make it easier to locate the page.

However, we still have to scan all processes in this case. That is
always going to be the case for as long as we can have multiple maps
into any single page. The BSD page on its own structure is not
sufficient to provide this physical-to-virtual mapping.

Cheers,
Stephen.