Myth: PAE increases the virtual address space beyond 4GB


This is another non sequitur. PAE increases the amount of physical memory that can be addressed by the processor, but that is unrelated to virtual address space. (Remember that PAE stands for Physical Address Extensions.)

PAE increases the physical address space (the address space that the CPU can use to access the memory chips on your computer) from 32 bits to 36 on a Pentium 2, for a theoretical maximum physical memory capacity of 64GB. However, the size of a pointer variable hasn't changed. It's still 32 bits (for a 32-bit processor), which means that the virtual address space is still 4GB.

With PAE enabled, the page table and page directory entries double in size (to accomodate the additional bits in the page frame), which significantly increases the amount of memory required for page tables and page directories (since each page table describes only half as much memory as it used to).

Notice that this has as a consequence that PAE and /3GB conflict with each other to some degree. If you turn on both PAE and /3GB, then the kernel will limit itself to 16GB of physical memory. That's because there isn't enough address space in the kernel to fit all the necessary memory bookkeeping into the 1GB of memory you told the kernel to squeeze itself into.

(On an AMD processor, the physical address space expands to 40 bits, for a theoretical maximum of 1TB. However, the memory manager uses only 37 of those bits, for an actual maximum of 128GB. Why? For the same reason that the kernel limits itself to 16GB in /3GB mode: Not enough address space. It's time to move to 64-bit processors...)

Comments (13)
  1. neli says:

    LOL, there is 1TB memory available, but there is no addressing space left to map it into :).

  2. vince says:

    Wouldn’t increasing the page size also alleviate this? (Let’s pretend for a second that wouldn’t break a bunch of applications that don’t correctly query the page size from the OS)

    I would think bigger page size = less address mapping entries, and thus more physical memory could be mapped (obviously, in different processes).

  3. Miles Archer says:

    It’s time to move to 64-bit processors…

    You said it, man. I suspect the floodgates will open once MS releases 64 bit windows for the Athlon-64.

  4. I have a dual opteron 240 that I use to test drivers with, and I’ve been running the amd64 preview of winxp for a while now. It works really well, and it is super fast. I agree with you on the Athalon 64 – it’s gonna be a killer.

  5. timchen says:

    There is one thing quite interesting about /PAE. On some machines with 4GB RAM installed, Task Manager shows only 3.5GB physical memory. However, if you switch to the PAE kernel, all 4GB is shown.

    Some says that it’s because the BIOS reserves 512MB "physical" address space just below the 4GB line and put the real 512MB RAM above the line. Thus only the PAE kernel sees that 512MB RAM.

    I’m not sure if the explanation is true or not, but the symptom is confirmed.

  6. Claus says:

    I have also heard that BIOS story, about how it hides memory from task manager, but I’d sure love to hear that story confirmed or refuted by someone "in the know"….

    Claus

  7. That’s exactly what happens. The BIOS (or sometimes devices) remap the memory above the 4GB range, which means without /PAE, Windows can’t address it. Once you turn on /PAE, we can see it all again.

  8. Ben Hutchings says:

    A standard AGP or PCI bus only has 32-bit address lines so MMIO areas for video, network and disk interfaces among other things normally need to be within the first 4 GB of physical memory. (Some hardware allows remapping between PCI and system bus addresses, but I don’t think this is normally done on the PC aside from the use of GARTs for video.) So in order for a standard PC to do anything useful it can’t have a whole 4 GB of RAM in the first 4 GB of physical address space, which is why the BIOS prevents that.

  9. Jeremy Morton says:

    Hmmm, I wonder if that’s why our 32GB /PAE machine lists the memory as 31.0 GB.

  10. Memory-mapped hardware (like almost every PCI device in your system) eats up a chunk of the 4GB physical address space. For example, one of the boards I’m writing drivers for now has a 4MB and an 8MB address window. This cuts into the amount of RAM Windows can see (with 32-bit addressing anyway).

    There are some 64-bit PCI devices, which can live above 4GB, but to use them (as a 64-bit device) you need a 64-bit PCI motherboard.

    Some devices are I/O mapped (usually legacy ISA devices), which don’t eat into the 4GB address space. It’s pretty rare to see an exclusively I/O mapped device these days, though.

    Enabling PAE increases the physical address space, so Windows can fit all 4GB of RAM AND your PCI devices.

  11. DrPizza says:

    Of course, 64-bit machines have the same problem with 32-bit PCI devices.

    The AMD abominations have an on-CPU hardware IOMMU to make this work (the 32-bit devices think that what they’re getting is memory below 4 GiB but it could be anywhere). Intel’s x86-64 implementations don’t; it’d go on the Northbridge for Intel, but their chipsets don’t have one.

    AMD’s IOMMU is a hacked up AGP GART. It’s not as capable as a purpose-built IOMMU would probably be, and so inefficient in comparison (to e.g. SPARC64). But it’s still better than no IOMMU at all (which is what you get on Intel).

    The proper solution, of course, is to use 64-bit PCI devices (PCI-X, PCIe, both of which notionally require 64-bit support, though both of which have devices that are broken and only really work with 32-bit addresses…).

  12.   As Evan already mentioned on his blog, Raymond Chen has a great series on /3GB switch on his blog. What is really cool is that Raymond takes on some myths about the /3GB switch and  the fact that he…

Comments are closed.