From: Daniel Phillips <phillips@bonn-fries.net>
To: Linus Torvalds <torvalds@transmeta.com>,
Rik van Riel <riel@conectiva.com.br>
Cc: Josh MacDonald <jmacd@CS.Berkeley.EDU>,
<linux-kernel@vger.kernel.org>, <reiserfs-list@namesys.com>,
<reiserfs-dev@namesys.com>
Subject: Re: Note describing poor dcache utilization under high memory pressure
Date: Mon, 28 Jan 2002 21:01:29 +0100 [thread overview]
Message-ID: <E16VHy5-0000Bz-00@starship.berlin> (raw)
In-Reply-To: <Pine.LNX.4.33.0201281005480.1609-100000@penguin.transmeta.com>
In-Reply-To: <Pine.LNX.4.33.0201281005480.1609-100000@penguin.transmeta.com>
On January 28, 2002 07:21 pm, Linus Torvalds wrote:
> On Mon, 28 Jan 2002, Rik van Riel wrote:
> >
> > I'd be interested to know exactly how much overhead -rmap is
> > causing for both page faults and fork (but I'm sure one of
> > the regular benchmarkers can figure that one out while I fix
> > the RSS limit stuff ;))
>
> I doubt it is noticeable on page faults (the cost of maintaining the list
> at COW should be basically zero compared to all the other costs), but I've
> seen several people reporting fork() overheads of ~300% or so.
>
> Which is not that surprising, considering that most of the fork overhead
> by _far_ is the work to copy the page tables, and rmap makes them three
> times larger or so.
>
> And I agree that COW'ing the page tables may not actually help. But it
> might be worth it even _without_ rmap, so it's worth a look.
True. I've been working on this question fairly intensively since around
Christmas. At that time I came up with the algorithm attached below, which I
circulated to a number of people, including Alan (who thought it would work)
and Rik. (Rik, please be more thorough about quoting your sources ;-).
I've been a little slow to 'publish' this on lkml because I wanted a working
prototype first, as proof of concept. My efforts to dragoon one or more of
the notably capable kernelnewbies crowd into coding it haven't been
particularly successful, perhaps due to the opacity of the code in question
(pgtable.h et al). So I've begun coding it myself, and it's rather slow
going, again because of the opacity of the code. Oh, and the difficult
nature of the problem itself, since it requires understanding pretty much all
of Unix memory management semantics first, including the bizarre (and useful)
properties of process forking.
The good news is, the code changes required do fit very cleanly into the
current design. Changes are required in three places I've identified so far:
copy_page_range
Intead of copying the page tables, just increment their use counts
zap_page_range:
If a page table is shared according to its use count, just decrement
the use count and otherwise leave it alone.
handle_mm_fault:
If a page table is shared according to its use count and the faulting
instruction is a write, allocate a new page table and do the work that
would have normally been done by copy_page_range at fork time.
Decrement the use count of the (perhaps formerly) shared page table.
I'd cheerfully hand this coding effort off to someone more familiar with this
particular neck of the kernel woods - you, Davem and Marcelo come to mind,
but if nobody bites I'll just continue working on it at my own pace. I
consider this work a potentially important evolutionary step, since it could
possibly lead to a breakup of the current VM logjam.
Here's the original writeup I circulated earlier this month:
Lazy page table instantiation algorithm
---------------------------------------
This algorithm implements page table sharing between page directories, with
a view to reducing the amount of work required at fork time for a child to
inherit its parent's memory. With this algorithm, only a single page (the
page directory) is copied at fork time.
This work is aimed at making Rik's rmap design practical, i.e., by eliminating
the current high cost of creating potentially millions of pte_chain list nodes
at fork time. However, the usefulness of this approach is not limited to
rmap -
it should speed up fork in the current vm as well, by copying only one page to
the child (the page directory) instead of all page table pages, and by
instantiating only those page tables that refer to pages the child actually
writes to.
The algorithm relies on a page table's use count, which specifies how many
page directories point at it. A page table can be shared by several page
directories until one of its non-shared pages is written. Then the page and
its page table are 'privatized', i.e., a copy of the page is entered into a
copy of the page table (and the page's pte_chain is extended).
In this way, instantiation of page tables does not happen at fork time, but
later, when pages referenced by page tables are privatized. Furthermore,
only page tables that need to be instantiated are instantiated, as opposed
to the current algorithm, which instantiates all page tables at fork time.
Algorithm
---------
On fork:
- Increment the use counts on all page tables mapped by the page directory
- Copy the page directory to the child
On page privatize:
- If the page table has use count greater than one, privatize the page
table. At this time, extend all the pte_chains to include the privatized
page table. Reduce the use count on the original page table by one and
set the use count of the new page table to one.
On process termination:
- Decrement the use counts on all page tables mapped by the page directory;
free those with zero use count.
With this lazy page table instantiation, a simple reverse-mapping memory
management scheme becomes much more attractive, because the overhead of
creating reverse links to ptes has been reduced (to only the page tables that
need it) and is not done at fork time.
--
Daniel
next prev parent reply other threads:[~2002-01-28 19:58 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-28 17:13 Josh MacDonald
2002-01-28 17:39 ` Linus Torvalds
2002-01-28 18:01 ` Rik van Riel
2002-01-28 18:21 ` Linus Torvalds
2002-01-28 18:37 ` Rik van Riel
2002-01-28 19:28 ` William Lee Irwin III
2002-01-28 20:01 ` Daniel Phillips [this message]
2002-01-28 21:33 ` Rick Stevens
2002-01-28 21:43 ` Rik van Riel
2002-01-28 22:00 ` Rick Stevens
2002-01-28 22:43 ` Daniel Phillips
2002-01-28 23:06 ` Rick Stevens
2002-01-28 23:51 ` [OT] " jepler
2002-01-29 2:30 ` IPmonger
2002-01-29 12:02 ` Karl & Betty Schendel
2002-01-28 22:26 ` Daniel Phillips
2002-01-28 22:34 ` Brian Gerst
2002-01-28 23:08 ` Daniel Phillips
2002-01-28 22:39 ` Daniel Phillips
2002-01-28 23:12 ` Rick Stevens
2002-01-28 23:27 ` Daniel Phillips
2002-01-28 22:01 ` Momchil Velikov
2002-01-28 22:19 ` Daniel Phillips
2002-01-29 1:29 ` Oliver Xymoron
2002-01-29 1:37 ` [reiserfs-list] " Valdis.Kletnieks
2002-01-29 1:45 ` Daniel Phillips
2002-01-29 8:39 ` Momchil Velikov
2002-01-29 8:55 ` Daniel Phillips
2002-01-29 9:20 ` William Lee Irwin III
2002-01-29 9:55 ` Daniel Phillips
2002-01-29 10:18 ` Momchil Velikov
2002-01-29 19:55 ` William Lee Irwin III
2002-01-29 20:08 ` Linus Torvalds
2002-01-29 20:39 ` William Lee Irwin III
2002-01-29 20:49 ` Linus Torvalds
2002-01-29 21:01 ` William Lee Irwin III
2002-01-29 9:20 ` Momchil Velikov
2002-01-29 10:27 ` Daniel Phillips
2002-01-29 11:54 ` Helge Hafting
2002-01-29 12:33 ` Daniel Phillips
2002-01-30 9:07 ` Horst von Brand
2002-01-30 10:55 ` Daniel Phillips
2002-01-30 14:46 ` Rik van Riel
2002-01-30 14:59 ` Daniel Phillips
2002-01-30 15:54 ` Rik van Riel
2002-01-30 16:34 ` Daniel Phillips
2002-01-29 10:59 ` Rik van Riel
2002-01-29 11:28 ` Daniel Phillips
2002-01-29 11:38 ` Rik van Riel
2002-01-29 12:01 ` Daniel Phillips
2002-01-29 16:57 ` Oliver Xymoron
2002-01-29 17:25 ` Rik van Riel
2002-01-29 20:48 ` Daniel Phillips
2002-01-29 21:00 ` Oliver Xymoron
2002-01-29 21:08 ` Linus Torvalds
2002-01-29 21:13 ` Oliver Xymoron
2002-01-29 21:50 ` Linus Torvalds
2002-01-29 22:02 ` Oliver Xymoron
2002-01-29 22:10 ` Linus Torvalds
2002-01-29 22:53 ` Daniel Phillips
2002-01-29 22:53 ` Daniel Phillips
2002-01-29 23:02 ` Oliver Xymoron
2002-01-29 23:21 ` Daniel Phillips
2002-01-28 19:25 ` [reiserfs-dev] " Hans Reiser
2002-01-28 23:52 ` Daniel Phillips
2002-01-29 0:16 ` Hans Reiser
2002-01-29 0:30 ` Alexander Viro
2002-01-29 10:46 ` Hans Reiser
2002-01-29 14:50 ` Chris Mason
2002-01-29 21:10 ` Hans Reiser
2002-01-30 7:11 ` Oliver Xymoron
2002-01-30 9:57 ` Hans Reiser
2002-01-29 17:28 ` Josh MacDonald
2002-01-29 18:44 ` [reiserfs-list] " Andreas Dilger
2002-01-29 19:55 ` Andrew Morton
2002-01-30 7:17 ` Oliver Xymoron
2002-01-30 7:32 ` [reiserfs-list] Re: [reiserfs-dev] Re: Note describing poordcache " Andrew Morton
2002-01-30 7:52 ` Oliver Xymoron
2002-01-30 10:03 ` Hans Reiser
2002-01-30 10:07 ` [reiserfs-dev] Re: Note describing poor dcache " Horst von Brand
2002-01-29 18:29 ` Horst von Brand
2002-01-29 0:51 ` Daniel Phillips
2002-01-29 1:32 ` Daniel Phillips
2002-01-28 22:46 ` Alex Bligh - linux-kernel
2002-01-29 17:27 ` Josh MacDonald
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E16VHy5-0000Bz-00@starship.berlin \
--to=phillips@bonn-fries.net \
--cc=jmacd@CS.Berkeley.EDU \
--cc=linux-kernel@vger.kernel.org \
--cc=reiserfs-dev@namesys.com \
--cc=reiserfs-list@namesys.com \
--cc=riel@conectiva.com.br \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®