You are not logged in.

#1 2009-04-18 15:10:15

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Memory question on Arch x86_64. 2x2048 MB = 3950 MB?

I have a naive memory question for some knowledgeable folks.  My machine has 2x2 Gb sticks which should total to 4096.  When I do a free -m under Arch, it's only showing 3950.  Is the remaining 146 reserved or..?

$ free -m
             total       used       free     shared    buffers     cached
Mem:          3950        422       3528          0         28        157
-/+ buffers/cache:        236       3714
Swap:         2000          0       2000

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2009-04-18 16:58:26

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: Memory question on Arch x86_64. 2x2048 MB = 3950 MB?

Thats a really good question smile and the result you get is normal as far as I know.
Part of it (a small part I believe) is used by the kernel, the rest of it, and this is where things are not so clear, is reserved as an agp apperture.
As far as I could tell (I have stumbled uppon that too) the problem seems to be that some bioses don't setup everything as they should.

The thing is that some devices can only handle 32bit addresses so their address is somewhere until the 4GB mark, because the bios doesn't setup the memory remapping correctly (sometimes the user has no way set anything related to memory remapping, this seems to be the case with some desktop boards and most notebooks/laptops). This memory remapping "problem" was anticipated and there are ways to properly handle that.

For some reason unknown to me (and most people that have stumbled upon this) many bioses don't setup (or allow the setup) of proper remapping. To add to the problem the kernel seems to reserve 128MB of agp aperture by default even if you don't have an agp card, this reserved address space falls in the first 4GB of addressing space therefore stealing you some memory.

I have tried to regain those MB, I have tried to recompile the kernel with a different config and I've tried several kernel boot parameters and the only thing I could regain was 64MB if I recall correctly. I can't find now what I have added to regain those 64MB, I didn't keep that option in the kernel line, 64MB were not worth the possibility of having problems later on.

I know its a pain to have that voice in the back of your head telling you that there is some memory that is being wasted, specially if you have tried a 32bit kernel with support for 64GB of address space and got 4050 MB of usable memory, but just leave it as it is, it's not worth the time and the trouble.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#3 2009-04-18 18:18:37

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Memory question on Arch x86_64. 2x2048 MB = 3950 MB?

kernel wrote:

Your BIOS doesn't leave a aperture memory hole
Please enable the IOMMU option in the BIOS setup
This costs you 64 MB of RAM
Mapping aperture over 65536 KB of RAM @ 20000000

My system always reads 3950MB of RAM. Despite the fuzzy math, I believe that this may be the cause. Unfortunately I haven't figured out how to upgrade my BIOS without scavenging a floppy drive from somewhere.

Offline

#4 2009-04-20 03:49:35

jspaces
Member
From: Canada
Registered: 2009-04-16
Posts: 21

Re: Memory question on Arch x86_64. 2x2048 MB = 3950 MB?

If you put "iommu=noaperture" on the kernel line, that will stop that error message although one does not gain much more memory.
My results are:

root /boot #  free -m
             total       used       free     shared    buffers     cached
Mem:          3954        812       3142          0         52        274
-/+ buffers/cache:        485       3469
Swap:         7632          0       7632

Kernel no longer posts the error about aperture and that you should configure the BIOS for iommu's aperture.

#  dmesg | grep iommu
Command line: root=/dev/mapper/galaxy-arch cryptdevice=/dev/sdc3:galaxy ro vga=795 cryptkey=/dev/sdd:2048:2048 iommu=noaperture
Kernel command line: root=/dev/mapper/galaxy-arch cryptdevice=/dev/sdc3:galaxy ro vga=795 cryptkey=/dev/sdd:2048:2048 iommu=noaperture

The only lines now showing is the command and kernel line with iommu. wink

Last edited by jspaces (2009-04-20 03:51:53)


Knowledge is a beam of light in which humans can only see the reflection.

Offline

#5 2009-04-20 09:20:50

Bogart
Member
From: Madrid, Spain
Registered: 2005-06-22
Posts: 272

Re: Memory question on Arch x86_64. 2x2048 MB = 3950 MB?

I always thought that this was a decimal vs. binary thing. You know:

1GB (gigabyte) = 1000 MB (megabytes)
1GiB (gibibyte) = 1024 MiB (mebibytes)

The operating system always uses the binary system, but hardware manufacturers use decimal. So that's also why if you buy a hard drive with 320GB, your operating system will tell you it's just 295GiB or so.

But I never investigated about it, so I might be completely wrong. And the fact that there is no just one standard is a pin in the ass, anyway. Everyone should use the same system to avoid these kind of confusions.

EDIT: But thinking about it, it can't be that, since then you would have much less than 3950. I in fact have 3821, but that's because my integrated graphics take 128 for itself (or so I believe).

Last edited by Bogart (2009-04-20 09:23:53)

Offline

#6 2009-04-20 13:41:16

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: Memory question on Arch x86_64. 2x2048 MB = 3950 MB?

On the RAM side of things math is still done in 1024 units (as it should be done in my oppinion), if you disable the pretty screen that shows up during POST you will see the detected amount of RAM (among other things) and you will see the amount in KB or MB and you will see that the math is done in 1024 units.

On the options you can pass to the kernel, most just make the kernel silent about the iommu thing, some options don't affect the total amount of RAM available and others will steal 1MB of RAM. Like I said before, not worth the trouble of regaining around 100MB of RAM when something could break later on because of that.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#7 2009-04-20 15:26:56

jleach
Member
Registered: 2008-07-24
Posts: 27

Re: Memory question on Arch x86_64. 2x2048 MB = 3950 MB?

The kernel is reserving a chunk. Try doing:

$ dmesg | grep Memory:

and you'll see exactly how much (should be around 146MB for you).

Note this is only about 3.5% reserved, which is typical for x86_64, considering that page tables alone will account for around 1.5%, the e820 BIOS itself will consume about 0.25%, then other motherboard features like onboard video/sound/network card to be memory mapped, then space for the uncompressed kernel code itself.

Tweaking your kernel build and settings may reduce this amount slightly, but the kernel will always reserve a portion exclusively for itself.

Offline

#8 2009-04-20 18:56:54

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Memory question on Arch x86_64. 2x2048 MB = 3950 MB?

Cool, thanks for the tip.  Mystery solved smile

$ dmesg | grep Me
Memory: 4043340k/4980736k available (2769k kernel code, 788040k absent, 148456k reserved, 1207k data, 392k init)
VBoxDrv: dbg - g_abExecMemory=ffffffffa0133d80

Last edited by graysky (2009-04-20 18:57:26)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB