Hi Willy,
On 2013/7/19 13:32, Willy Tarreau wrote:
Hi Godbach,
On Fri, Jul 19, 2013 at 12:21:23PM +0800, Godbach wrote:
You should strace it. I'm sure you'll see an mmap() call that matches
the size of your allocation, meaning that the libc has decided to use
this instead of sbrk() to allocate the area. Then by definition all
the area will return zeroes, so the libc does not need to perform a
memset on it. The issue however is that we believe the memory is granted
but we can fail to use it on low memory condition.
If this is what happens, I'd prefer that we explicitly use memset on these
critical elements such as fdtab etc... to guarantee the memory is allocated.
Best regards,
Willy
Here is part information about strace during haproxy startup:
open("h.cfg", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1985, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7fadfa0e0000
read(3, "global\n\tnode vs_1\n\tpidfile /tmp/"..., 4096) = 1985
read(3, "", 4096) = 0
close(3) = 0
munmap(0x7fadfa0e0000, 4096) = 0
brk(0) = 0x164d000
brk(0x166f000) = 0x166f000
mmap(NULL, 41947136, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7fadf78c0000
mmap(NULL, 62918656, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7fadf3cbf000
mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7fadf32be000
mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7fadf28bd000
epoll_create(2621472) = 3
mmap(NULL, 31461376, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7fadf0abc000
The allocation of memory related to 40Mbytes and 60Mbytes should be in
these two lines:
mmap(NULL, 41947136, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7fadf78c0000
mmap(NULL, 62918656, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7fadf3cbf000
Yes, as you said, mmap is used to allocate the areas. Is that what you
meant libc has not called memset yet.
--
Best Regards,
Godbach