[comp.arch] Fork handling in reverse mapped maps, was Re: Phys vs Virtual Addr Caches

johnl@ima.ISC.COM (John R. Levine) (08/02/87)

In article <4420001@hpihoah.HP.COM> ross@hpihoah.HP.COM (Ross LaFetra) writes:
>[discussing the HP 9000/840:]
>The problem on consistency with shared memory isn't much of a problem.  Since
>the machine supports a large number of spaces (32 bit segments of virtual
>memory), you can assign each piece of shared memory its own virtual space.
>There are 65536 spaces on the 840, so you are not likely to run out soon.
>Thus, you can avoid the need to assign a two virtual addresses to the same
>physical address.  This is prohibited on HPPA machine (by software convention).

What do you do about handling fork() calls efficiently? The ROSETTA
translation chip in the IBM RT PC has a roughly milar design, with a zillion
large segments. It has a reverse-mapped page table with no provision for
aliasing, which makes it impossible to assign two virtual pages to the same
physical page. This works just fine for shared code and shared data, but is a
complete loser when you do a fork(). After a fork, you know that one of the
two processes will probably do an exec() soon and throw away its entire
address space, but it might not. So you'd like to have the data and stack in
both processes map to the same pages, and make copies of pages as needed. As
soon as one page changes, you have two different segments, and you really want
to double map all of the unchanged pages into both segments.

In the RT PC, they came up with a crock: Each double mapped page is mapped
into one of the segments, and the corresponding frame in the other segment is
set to fault. When the faulting frame is referenced, it makes a copy of the
page and maps it in. This implements copy-on-touch rather than copy-on write,
but it's a lot better than the alternative, which would either be to copy the
whole segment on a fork, or else to do a lot of page remapping at context
switch time.

How does HP address this?
-- 
John R. Levine, Javelin Software Corp., Cambridge MA +1 617 494 1400
{ ihnp4 | decvax | cbosgd | harvard | yale }!ima!johnl, Levine@YALE.something
The Iran-Contra affair:  None of this would have happened if Ronald Reagan
were still alive.