allocating >2G in userland

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi all,

I have a computer with 4GB with FedoraCore3 installed, and wrote this program that allocates a >2G array:


int main(int,char**) {
        unsigned int size = (unsigned int)2 * 1024 *1024 *1024 + 1000;
        char *p;

        p = malloc(size);
        if (p != NULL)
                printf("OK\n");
        else
                printf("Bad\n");
}

Using the kernel supplied with FC the buffer is allocated. When I use a kernel I compile malloc returns NULL.
I am aware of the high-mem support and I tried it set to 4G and 64G.
Furthermore, when I compile a kernel with the config file given by FC (linux-2.6.5-1.358/configs/kernel-2.6.5-i* ) it doesn't work (although the kernel should be configured the same).

Obviously this has something to do with the way I build the kernel, since when I use the kernel supplied with FC3 it works well.

I also tried to copy a good kernel I compiled on another machine (together with its modules) and this one doesn't work as well, although on the original machine it worked.



Another strange thing:
Using ldd on the "bad" machine I get:
[root@host1 root]# ldd test_hi_mem
        linux-gate.so.1 =>  (0x00280000)
        libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x4e056000)
        libm.so.6 => /lib/tls/libm.so.6 (0x4d316000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x4deb8000)
        libc.so.6 => /lib/tls/libc.so.6 (0x4d1f3000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x4d1da000)

while on the "good" machine I get:
[root@host2 root]# ldd test_high_mem
        linux-gate.so.1 =>  (0xffffe000)
        libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x072d7000)
        libm.so.6 => /lib/tls/libm.so.6 (0x0079c000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x005f3000)
        libc.so.6 => /lib/tls/libc.so.6 (0x00679000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00660000)


This suggests that the "bad" machine puts the libraries in the middle of the address space. But then I do not understand how any kernel can allocate 2G.


Any suggestions?

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux