This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

kernel memory available

Guru 20755 points

Hello,

I would like you advise regarding the memory available in Linux:

I have an issue where kernel see different memory size than the real memory.
DDR = 512M (in u-boot)

bootargs also contain 512M:
root@dm814x:~# cat /proc/cmdline
console=ttyO0,115200n8 ip=10.0.0.2 nfsroot=10.0.0.1:/mnt/DVR_NEW/DVRRDK_04.01.00.02/target/rfs_814x,nolock root=/dev/nfs rw rootdelay=15 mem=512M

But I see in dmesg that memory is 461M:
root@dm814x:~# dmesg | grep '[Mm]em'
Memory policy: ECC disabled, Data cache writeback
free_area_init_node: node 0, pgdat c05396d8, node_mem_map c0578000
Normal zone: 1024 pages used for memmap
Kernel command line: console=ttyO0,115200n8 ip=10.0.0.2 nfsroot=10.0.0.1:/mnt/DVR_NEW/DVRRDK_04.01.00.02/target/rfs_814x,nolock root=/dev/nfs rw rootdelay=15 mem=512M
Memory: 460MB 1MB = 461MB total
Memory: 461924k/461924k available, 62364k reserved, 0K highmem
Virtual kernel memory layout:
lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)

Is there any idea why the kernel does not see 512M ?

Thanks you,

Ran

  • Hi Ran,

    This is because the memory is divided to meny segments. Please see the kernel message (this is from my kernel) :
    [ 0.000000] Memory: 512MB = 512MB total
    [ 0.000000] Memory: 515016k/515016k available, 9272k reserved, 0K highmem
    [ 0.000000] Virtual kernel memory layout:
    [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
    [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
    [ 0.000000] vmalloc : 0xe0800000 - 0xff000000 ( 488 MB)
    [ 0.000000] lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)
    [ 0.000000] modules : 0xbf000000 - 0xc0000000 ( 16 MB)
    [ 0.000000] .text : 0xc0008000 - 0xc03f8000 (4032 kB)
    [ 0.000000] .init : 0xc03f8000 - 0xc042a000 ( 200 kB)
    [ 0.000000] .data : 0xc042a000 - 0xc0476870 ( 307 kB)
    [ 0.000000] .bss : 0xc0476894 - 0xc049f4a8 ( 164 kB)

    BR
    Ivan
  • Hi Ran,

    Check void __init mem_init(void) function in arch/arm/mm/init.c... You can add some debug prints in the relevalnt fragment of code:

       printk(KERN_INFO "Memory:");
       num_physpages = 0;
       for_each_memblock(memory, reg) {
                     unsigned long pages = memblock_region_memory_end_pfn(reg) -
                     memblock_region_memory_base_pfn(reg);
                     num_physpages += pages;
                     printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
        }
       printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));

    There are some pages of the memory that are marked as reserved.

    Best Regards,
    Yordan

  • What are the contents of /proc/iomem?

  • The issue is fixed in the below e2e thread:

    e2e.ti.com/.../397771

    BR
    Pavel
  • Hi thank you for tge useful information.
    In kernel config file there is ti81xx flag vram set to 50M.
    when setting it to 0 I see the full memory.
    thank you
    ran