public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Valdis.Kletnieks@vt.edu
Cc: Jeff Chua <jeff.chua.linux@gmail.com>,
	Tomasz Chmielewski <mangoo@wpkg.org>,
	Daniel J Blueman <daniel.blueman@gmail.com>,
	Byron Stanoszek <bstanoszek@comtime.com>,
	Dave Hansen <dave@linux.vnet.ibm.com>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: 2.6.32-rc3: low mem - only 378MB on x86_32 with 64GB. Why?
Date: Sat, 10 Oct 2009 11:37:55 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0910101121190.3438@localhost.localdomain> (raw)
In-Reply-To: <32059.1255198236@turing-police.cc.vt.edu>



On Sat, 10 Oct 2009, Valdis.Kletnieks@vt.edu wrote:
>
> When the x86 went 64-bit, the register pressure relief from the 
> additional registers usually more then outweighs the additional memory 
> bandwidth (basically, if you're spending twice as much time on each 
> load/store, but only doing it 40% as often, you come out ahead...)

That's mainly stack traffic, and x86 has always been good at it. More 
registers makes for simpler (and fewer) instructions due to less reloads, 
but for kernel loads, it's not the biggest advantage.

If you have 8GB of RAM or more, the biggest advantage _by_far_ for the 
kernel is that you don't spend 25% of your system time playing with 
k[un]map() and the TLB flushing that goes along with it. You also have 
much more freedom to allocate (and thus cache) inodes, dentries and 
various other fundamental kernel data structures.

Also, the reason MIPS and Sparc had a slowdown for 64-bit code was only 
partially the bigger cache footprint (and that depends a lot on the app 
anyway: many applications aren't that pointer-intensive. The kernel is 
_very_ pointer-intensive, but even for something like that, most data 
structures tend to blow up by 50%, not 100%).

The other reason for slowdown is that generating those pointers (for 
function calls in particular) is more complex, and x86-64 is better at 
that than MIPS and Sparc. That complex instruction encoding with 
variable-size instructions means that you don't have to try to fit all 
constants in the instruction stream either in the fixed-sized instruction, 
or by doing indirect data access to memory through a GP register. 

So x86-64 not only had the register expansion advantage, it had less of a 
code generation downside to 64-bit mode to begin with. Want to have large 
constants in the code? No problem. Sure, it makes your code bigger, but 
you can still have them predecoded in the instruction stream rather than 
have to load them from memory. Much nicer for everybody.

And for the kernel, the bigger virtual address space really is a _huge_ 
deal. HIGHMEM accesses really are very slow.  You don't see that in user 
space, but I really have seen 25% performance differences between 
non-highmem builds and CONFIG_HIGHMEM4G enabled for things that try to put 
a lot of data in highmem (and the 64G one is even more expensive). And 
that was just with 2GB of RAM.

And when it makes the difference between doing IO or not doign IO (ie 
caching or not caching - when the dentry cache can't grow any more because 
it _needs_ to be in lowmem), you can literally see an order-of-magnitude 
difference.

With 8GB+ of ram, I guarantee you that the kernel spent tons of time on 
just mappign high pages, _and_ it couldn't grow inodes and dentry caches 
nearly as big as it would have wanted to. Going to x86-64 makes all those 
issues just go away entirely.

So it's not "you can save a few instructions by not spilling to stack as 
much". It's a much bigger deal than that. There's a reason I personally 
refuse to even care about >2GB 32-bit machines. There's just no excuse 
these days to do that.

			Linus

  reply	other threads:[~2009-10-10 18:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-05 15:57 2.6.32-rc3: low mem - only 378MB on x86_32 with 64GB. Why? Jeff Chua
2009-10-05 18:12 ` Linus Torvalds
     [not found]   ` <b6a2187b0910051715y4ee63503y148ba2d7e24cad8e@mail.gmail.com>
2009-10-06  0:30     ` Linus Torvalds
2009-10-06 10:06       ` Tvrtko Ursulin
2009-10-06 11:01         ` Frans Pop
2009-10-14 21:32           ` Lennart Sorensen
2009-10-06 12:59       ` David Woodhouse
2009-10-06 14:26         ` Linus Torvalds
2009-10-11  9:08           ` Benjamin Herrenschmidt
     [not found]       ` <b6a2187b0910052312o662642b2teded3d19548b9151@mail.gmail.com>
2009-10-06 14:35         ` Linus Torvalds
     [not found]           ` <b6a2187b0910080926x303d3c9em8f70632fb19b6509@mail.gmail.com>
2009-10-08 16:35             ` Dave Hansen
     [not found]           ` <b6a2187b0910090928r648169dax86178a3e8b8c2f21@mail.gmail.com>
2009-10-10 18:10             ` Valdis.Kletnieks
2009-10-10 18:37               ` Linus Torvalds [this message]
2009-10-11  9:06           ` Benjamin Herrenschmidt
2009-10-11 17:34             ` Linus Torvalds
2009-10-06 16:50   ` Yuhong Bao
2009-10-05 18:42 ` Byron Stanoszek
2009-10-05 19:15 ` Dave Hansen
  -- strict thread matches above, loose matches on Subject: below --
2009-10-05 19:42 Tomasz Chmielewski
2009-10-05 20:31 ` Valdis.Kletnieks
     [not found] <drYiu-Pj-15@gated-at.bofh.it>
2009-10-05 20:05 ` Daniel J Blueman

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=alpine.LFD.2.01.0910101121190.3438@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=bstanoszek@comtime.com \
    --cc=daniel.blueman@gmail.com \
    --cc=dave@linux.vnet.ibm.com \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=jeff.chua.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mangoo@wpkg.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