3

I'm running Debian Linux. uname -m says i686 which means 32-bit architecture machine with pae flag enabled. getconf LONG_BIT is 32. Installed RAM capacity is 6GB.

My /proc/cpuinfo has an entry address sizes : 40 bits physical, 48 bits virtual. However, my program is generating only 32 bit address. (Address of x is 0xbfbaf5cc)

I do not understand the relation between 48 bit virtual address shown by cat /proc/cpuinfo and the virtual address generated by the C program. Complete CPU info can be found here.

Could somebody explain?

  • 2
    /proc/cpuinfo is your physical CPU's capabilities. If your kernel & OS are 32bit, you'll only get 32bit addresses. – Mat Jul 30 '15 at 11:47
  • What CPU do you have? – Mark Plotnick Jul 30 '15 at 15:10
  • @MarkPlotnick: Added cpuinfo – Tamilselvan Aug 3 '15 at 7:47
3

PAE doesn't change anything about virtual addresses. As the name hints, it's only about physical addresses. As an application programmer, PAE doesn't change anything for you. Your program still has a 32-bit address space, out of which the kernel takes approximately 1 bit (Linux grants 1GB, 2GB or 3GB to userspace depending on compilation options). If you want a larger address space, you need a 64-bit system.

The point of PAE is to allow the kernel to address more than 4GB of physical RAM. In order to make use of all this RAM, you need multiple processes, each of which can map at most 2GB (or 1GB or 3GB).

In PAE mode, MMU tables map 32-bit virtual addresses to 40-bit physical addresses, with a three-level table (unlike non-PAE mode where the MMU tables map 32-bit virtual addresses to 32-bit physical addresses with a two-level table).

The indication “48 bits virtual” refers to the CPU's capabilities. I think this means that the CPU is a 64-bit one (i.e. one that supports amd64 a.k.a. x86-64). In order to make use of 48-bit virtual addresses, you'd need to run a 64-bit operating system. Here 48-bit is a little confusing for an application programmer: the CPU translates only 48 bits of the address, but the address is encoded in 64 bits — pointers occupy 8 bytes, not 6. The upper 16 bits can contain additional tags used by the operating system.

  • My CPU is 64 bit and installed OS is 32 bit. That explains the reason of 48 bits virtual address size. Above such machines lscpu will be like Architecture: i686 CPU op-mode(s): 32-bit, 64-bit – Tamilselvan Aug 6 '15 at 7:59
1

pae stand for physical address extension and allow a cpu with a 32bit address bus to address more than 4G.

Notice that if your /proc/cpuinfo show support for pae isn't enough, you need to use a kernel compiled with pae options enabled (eg: I'm using a Debian prebuilt 3.16-2-686-pae)

The memory model/layout of a Linux process is defined by the Linux kernel and is (or anyway may be) different between architectures, a user process would never see the whole physical RAM (only the kernel), let say the kernel may allow the process to theoretically use 2G but then in real those are used only when needed with pages (usually each with size 4K or 16K) which the kernel map from the physical Ram into the process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.