Well I've straced it a bit (in fact it's stracing as I wrote
this e-mail -- this is evolution-mail which is the mail component
of the evolution suite) and the story is:
* lots of brk()s but they simply grow the one vma, no problem
* lots of 4kb old_mmap/munmap repeated over and over, just keeps
reallocating the same block, no problem
* and then this...
7179 old_mmap(NULL, 2097152, PROT_NONE,
MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0 <unfinished ...>
7159 --- SIGRT_0 (Real-time signal 0) ---
7179 <... old_mmap resumed> ) = 0x40ef1000
7179 munmap(0x40ef1000, 61440) = 0
7179 munmap(0x41000000, 987136) = 0
Translation:
"give me 2Mb"
"now lets get rid of this non-virtual-page-aligned crap"
"now lets split up this 1Mb"
I have no idea how sensible or illogical that is, though.
7179 mprotect(0x40f00000, 32768, PROT_READ|PROT_WRITE) = 0
7179 mprotect(0x40f08000, 4096, PROT_READ|PROT_WRITE) = 0
7179 mprotect(0x40f09000, 4096, PROT_READ|PROT_WRITE) = 0
7179 mprotect(0x40f0a000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f0b000, 8192, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f0d000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f0e000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f0f000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f10000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f11000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f12000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f13000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f14000, 4096, PROT_READ|PROT_WRITE) = 0
7245 mprotect(0x40f15000, 8192, PROT_READ|PROT_WRITE) = 0
Here are some "why aren't these merged?" mappings:
40f00000-40f08000 rw-p 0000f000 00:00 0
40f08000-40f09000 rw-p 00017000 00:00 0
40f09000-40f0a000 rw-p 00018000 00:00 0
40f0a000-40f0b000 rw-p 00019000 00:00 0
40f0b000-40f0d000 rw-p 0001a000 00:00 0
40f0d000-40f0e000 rw-p 0001c000 00:00 0
40f0e000-40f0f000 rw-p 0001d000 00:00 0
40f0f000-40f10000 rw-p 0001e000 00:00 0
40f10000-40f11000 rw-p 0001f000 00:00 0
40f11000-40f12000 rw-p 00020000 00:00 0
40f12000-40f13000 rw-p 00021000 00:00 0
40f13000-40f14000 rw-p 00022000 00:00 0
40f14000-40f15000 rw-p 00023000 00:00 0
40f15000-40f17000 rw-p 00024000 00:00 0
40f17000-41000000 ---p 00026000 00:00 0
So the problem is that it's saying "make me a big chunk of memory"
and then gradually "releasing" the memory into use, and releasing
the memory into use is fragmenting up the vmas.
> BUT, glibc doesn't always have consistent use, as I mentioned about,
> it will often do
>
> mmap( .... PROT_FOO ... )
> munmap ( some of the above ) [optional]
> for( ... )
> mprotect ( PROT_BAR ... )
>
> which means the simple logic above cannot coalesce things.
Yes, that's what's happening above. And it's what's causing the
splits in the vmas. So basically evolution-mail is doing exactly what
your test program was doing, and causing exactly the same thing.
Seems strange that glibc would do this unless there was some performance
reason on past kernels to do it?
> VMware (capatalisation?) also causes large numbers of vmas, but my
> attempts to get Xfree86, gimp or gcc (when compiling C code) to do so
> were unsuccessful, all showed little if any ability to merge vmas.
> Compiling a large c++ application might show some gains here, but I
> don't have anything large enough to try.
I'd expect VMware and WINE will use large numbers of mappings and
trying to prevent it is likely to be futile. But things like Mozilla
and Evolution should be fixable, well down to the 200-ish mappings
required by the number of libraries they use at least...
David.
-- David Luyer Phone: +61 3 9674 7525 Engineering Projects Manager P A C I F I C Fax: +61 3 9699 8693 Pacific Internet (Australia) I N T E R N E T Mobile: +61 4 1111 2983 http://www.pacific.net.au/ NASDAQ: PCNTF - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/