public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@redhat.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-arch@vger.kernel.org
Subject: Re: clear_user_highpage()
Date: Wed, 11 Aug 2004 17:23:24 -0700	[thread overview]
Message-ID: <20040811172324.33f351bf.davem@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0408111654440.1839@ppc970.osdl.org>

On Wed, 11 Aug 2004 17:00:37 -0700 (PDT)
Linus Torvalds <torvalds@osdl.org> wrote:

> You didn't read my message. If it doesn't crap on the caches when you do 
> the stores, it _will_ crap on the bus both when you do the stores _and_ 
> when you actually read the page.

I understand what you're saying.

> In other words, you will have taken _more_ of a hit later on. It's just 
> that it won't be a nice profile hit, it will be a nasty "everything runs 
> slower later".
> 
> Caches work best when you have good temporal locality. You are removing 
> that locality, and thus you are making your caches _less_ efficient.
> 
> That's a very _fundamental_ argument. 

Here is some more data.

If I use the cache bypassing stores on sparc64 for clear page (which I
do and always have), it takes roughly 4400 cycles to clear a page out
on a 750Mhz cpu regardless of whether the page is in the L2 cache or
not.

Conversely, I played with a version that did not do cache bypass and
for a cache hit it was phenominal, about twice as fast, but for the
cache miss case it was very slow, some 20,000 cycles.  I played around
with trying to prefetch the data into the L2 cache, that didn't help
much in the miss case at all.

Also, when the user takes that first write fault on the anonymous
page, it typically access the first several bytes (it is usually a
malloc chunk or similar), it doesn't trypically walk the entire page.
So to me, bringing the whole thing in seems inefficient.  Let the
process bring the cache lines in, when it's really needed, which (for
all the cache lines in that page) is not necessarily when the write
fault occurs and we clear the page out.  If it happened to be in the
L2 cache at clear_user_highpage() time, it'll stay there during the
clearing and that's great too.

Is that logic fundamentally flawed?

> Larger caches will happen. My argument will get only more relevant. Your 
> approach will force cache misses and tons of memory bus traffic. 

I agree with you.  But I believe, given the data above wrt. sparc64,
it is a profitable scheme at least on that platform.

You definitely have piqued my interest in some things.  I'll try out
the expensive clear_user_highpage() that brings the data into the L2
cache always, and see if that makes kernel builds faster.  Although
I think the fact that clear_user_highpage() will be 5 times slower on
the L2 miss case might nullify any gains bringing the data in always
for the user might give.

We'll see.

  parent reply	other threads:[~2004-08-12  0:24 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-11 23:15 clear_user_highpage() David S. Miller
2004-08-11 23:31 ` clear_user_highpage() Benjamin Herrenschmidt
2004-08-11 23:55   ` clear_user_highpage() David S. Miller
2004-08-12  0:03     ` clear_user_highpage() Benjamin Herrenschmidt
2004-08-12  1:18       ` clear_user_highpage() William Lee Irwin III
2004-08-12  2:11       ` clear_user_highpage() Andi Kleen
2004-08-12  9:23         ` clear_user_highpage() Martin Schwidefsky
2004-08-11 23:46 ` clear_user_highpage() Linus Torvalds
2004-08-11 23:53   ` clear_user_highpage() David S. Miller
2004-08-12  0:00     ` clear_user_highpage() Linus Torvalds
2004-08-12  0:06       ` clear_user_highpage() Benjamin Herrenschmidt
2004-08-12  0:24         ` clear_user_highpage() David S. Miller
2004-08-12  0:23       ` David S. Miller [this message]
2004-08-12  1:46         ` clear_user_highpage() Linus Torvalds
2004-08-12  2:51           ` clear_user_highpage() David S. Miller
2004-08-16  1:58         ` clear_user_highpage() Paul Mackerras
2004-08-12  2:08       ` clear_user_highpage() Andi Kleen
2004-08-12  2:45         ` clear_user_highpage() David S. Miller
2004-08-12  9:09           ` clear_user_highpage() Andi Kleen
2004-08-12 19:50             ` clear_user_highpage() David S. Miller
2004-08-12 20:00               ` clear_user_highpage() Andi Kleen
2004-08-12 20:30                 ` clear_user_highpage() David S. Miller
2004-08-12 21:34               ` clear_user_highpage() Matthew Wilcox
2004-08-13  8:16                 ` clear_user_highpage() David Mosberger
2004-08-12  0:00   ` clear_user_highpage() Benjamin Herrenschmidt
2004-08-12  0:21     ` clear_user_highpage() Linus Torvalds
2004-08-12  0:46   ` clear_user_highpage() William Lee Irwin III
2004-08-12  1:01     ` clear_user_highpage() David S. Miller
2004-08-12  2:18     ` clear_user_highpage() Linus Torvalds
2004-08-12  2:43       ` clear_user_highpage() David S. Miller
2004-08-12  4:19         ` clear_user_highpage() Linus Torvalds
2004-08-12  4:46           ` clear_user_highpage() William Lee Irwin III
2004-08-15  6:22             ` clear_user_highpage() Andrew Morton
2004-08-15  6:38               ` clear_user_highpage() William Lee Irwin III
2004-08-12  2:57       ` clear_user_highpage() David S. Miller
2004-08-12  3:20       ` clear_user_highpage() William Lee Irwin III
2004-08-13 21:41       ` clear_user_highpage() David S. Miller
2004-08-16 13:00         ` clear_user_highpage() David Mosberger
2004-08-22 19:51           ` clear_user_highpage() Linus Torvalds
2005-09-17 19:01             ` clear_user_highpage() Andi Kleen
2005-09-17 19:16               ` clear_user_highpage() Andi Kleen

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=20040811172324.33f351bf.davem@redhat.com \
    --to=davem@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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