--- El jue 13-oct-11, Mulyadi Santosa <mulyadi.santosa@gmail.com> escribió:
I am sorry maybe I explained myself incorrectly, threads don't actually allocate anything; just mmap it's own stack space (8MB each).
I see, so 8 MB each.... and since you created 10 threads, I suppose that would commit 8*10=80 MB of RAM. CMIIW here.... (stack are individual, so they aren't shared between threads)
Reading sources I think kernel let the process create several threads because as there is no real memory usage, the amount of free pages on each thread allocation is the same. I mean, when I start first thread I have enough free pages to allow the mmap(). When I start the second, third, etc. I always have the same amount of free pages, since threads don't alloc any pages they just 'prepare' the adresses. I'll try to put some printk inside vm_enough_memory() and try to re-run my tests. Do you think there is any other debugging aproach? By the way, I have already solved my problem (weeks ago) by reducing default thread stack size :) But I would love to understand what happened. It's a strange scenario for a linux kernel, since I have very low memory left and zero swap. Thanks a lot for the help!