linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Nick Piggin <npiggin@suse.de>, Hugh Dickins <hugh@veritas.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	tee@sgi.com, holt@sgi.com, Andrea Arcangeli <andrea@suse.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [rfc] no ZERO_PAGE?
Date: Wed, 4 Apr 2007 10:02:36 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0704040950570.6730@woody.linux-foundation.org> (raw)
In-Reply-To: <20070404183220.2455465b.dada1@cosmosbay.com>


On Wed, 4 Apr 2007, Eric Dumazet wrote:
> 
> But results on an Intel Pentium-M are interesting, in particular 2) & 3)
> 
> If a page is first allocated as page_zero then cow to a full rw page, this is more expensive.
> (2660 cycles instead of 2300)

Yes, you have an extra TLB flush there at a minimum (if the page didn't 
exist at all before, you don't have to flush).

That said, the big cost tends to be the clearing of the page. Which is why 
the "bring in zero page" is so much faster than anything else - it's the 
only case that doesn't need to clear the page.

So you should basically think of your numbers like this:
 - roughly 900 cycles is the cost of the page fault and all the 
   "basic software" side in the kernel
 - roughly 1400 cycles to actually do the "memset" to clear the page (and 
   no, that's *not* the cost of memory accesses per se - it's very likely 
   already in the L2 cache or similar, we just need to clear it and if 
   it wasn't marked exclusive need to do a bus cycle to invalidate it on 
   any other CPU's).

with small variation depending on what the state was before of the cache 
in particular (for example, the TLB flush cost, but also: when you do

> 4) memset 4096 bytes to 0x55:
> Poke_full (addr=0x804f000, len=4096): 2719 cycles

This only adds ~600 cycles to memset the same 4kB that cost ~1400 cycles 
before, but that's *probably* largely because it was now already dirty in 
the L2 and possibly the L1, so it's quite possible that this is really 
just a cache effect, because now it's entirely exclusive in the caches so 
you don't need to do any probing on the bus at all).

Also note: in the end, page faults are usually fairly unusual. You do them 
once, and then use the page a lot after that. That's not *always* true, of 
course. Some malloc()/free() patterns of big areas that are not used for 
long will easily cause constant mmap/munmap, and a lot of page faults.

The worst effect of page faults tends to be for short-lived stuff. Notably 
things like "system()" that executes a shell just to execute something 
else. Almost *everything* in that path is basically "use once, then throw 
away", and page fault latency is interesting.

So this is one case where it might be interesting to look at what lmbench 
reports for the "fork/exit", "fork/exec" and "shell exec" numbers before 
and after. 

			Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-04-04 17:02 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-29  7:58 [rfc][patch 1/2] mm: dont account ZERO_PAGE Nick Piggin
2007-03-29  7:58 ` [rfc][patch 2/2] mips: reinstate move_pte Nick Piggin
2007-03-29 17:49   ` Linus Torvalds
2007-03-29 13:10 ` [rfc][patch 1/2] mm: dont account ZERO_PAGE Hugh Dickins
2007-03-30  1:46   ` Nick Piggin
2007-03-30  2:59     ` Robin Holt
2007-03-30  3:09       ` Nick Piggin
2007-03-30  9:23         ` Robin Holt
2007-03-30  2:40   ` Nick Piggin
2007-04-04  3:37     ` [rfc] no ZERO_PAGE? Nick Piggin
2007-04-04  9:45       ` Hugh Dickins
2007-04-04 10:24         ` Nick Piggin
2007-04-04 12:27           ` Andrea Arcangeli
2007-04-04 13:55             ` Dan Aloni
2007-04-04 14:14               ` Andrea Arcangeli
2007-04-04 14:44                 ` Dan Aloni
2007-04-04 15:03                   ` Hugh Dickins
2007-04-04 15:34                     ` Andrea Arcangeli
2007-04-04 15:41                       ` Hugh Dickins
2007-04-04 16:07                         ` Andrea Arcangeli
2007-04-04 16:14                         ` Linus Torvalds
2007-04-04 15:27                   ` Andrea Arcangeli
2007-04-04 16:15                     ` Dan Aloni
2007-04-04 16:48                       ` Andrea Arcangeli
2007-04-04 12:45           ` Hugh Dickins
2007-04-04 13:05             ` Andrea Arcangeli
2007-04-04 13:32               ` Hugh Dickins
2007-04-04 13:40                 ` Andrea Arcangeli
2007-04-04 15:35       ` Linus Torvalds
2007-04-04 15:48         ` Andrea Arcangeli
2007-04-04 16:09           ` Linus Torvalds
2007-04-04 16:23             ` Andrea Arcangeli
2007-04-04 16:10           ` Hugh Dickins
2007-04-04 16:31             ` Andrea Arcangeli
2007-04-04 22:07           ` Valdis.Kletnieks
2007-04-04 16:32         ` Eric Dumazet
2007-04-04 17:02           ` Linus Torvalds [this message]
2007-04-04 19:15         ` Andrew Morton
2007-04-04 20:11         ` David Miller, Linus Torvalds
2007-04-04 20:50           ` Andrew Morton
2007-04-05  2:03           ` Nick Piggin
2007-04-05  5:23           ` Andrea Arcangeli
2007-04-04 22:05         ` Valdis.Kletnieks
2007-04-05  0:27           ` Linus Torvalds
2007-04-05  1:25             ` Valdis.Kletnieks
2007-04-05  2:30             ` Nick Piggin
2007-04-05  5:37               ` William Lee Irwin III
2007-04-05 17:23                 ` Valdis.Kletnieks
2007-04-05  4:47         ` Nick Piggin

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=Pine.LNX.4.64.0704040950570.6730@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrea@suse.de \
    --cc=dada1@cosmosbay.com \
    --cc=holt@sgi.com \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=npiggin@suse.de \
    --cc=tee@sgi.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