LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-23-2009, 06:46 AM   #1
movax222
LQ Newbie
 
Registered: Sep 2007
Posts: 3

Rep: Reputation: 0
Threads allocating 64M of anon space on 64-bit Linux


Hi!

I have started moving our multithreaded applications to 64-bit Linux (Fedora 11, kernel 2.6.30).

I am a little curious why every thread appears to allocate a 64 megabyte anon region. In total these regions occupy multiple GBs of address space, which if course isn't a problem in itself, but I'd like to know why it does this

Below is a partial dump of pmap -x output for the given process.
This represents the stack spaces for 6 threads together with the 64M regions for these threads.

Thanks for any input!

00007fc16405b000 65172 - - - ----- [ anon ]
00007fc168000000 944 - - - rw--- [ anon ]
00007fc1680ec000 64592 - - - ----- [ anon ]
00007fc16c000000 420 - - - rw--- [ anon ]
00007fc16c069000 65116 - - - ----- [ anon ]
00007fc170000000 496 - - - rw--- [ anon ]
00007fc17007c000 65040 - - - ----- [ anon ]
00007fc174000000 208 - - - rw--- [ anon ]
00007fc174034000 65328 - - - ----- [ anon ]
00007fc178000000 436 - - - rw--- [ anon ]
00007fc17806d000 65100 - - - ----- [ anon ]
00007fc17c000000 476 - - - rw--- [ anon ]
 
Old 06-23-2009, 08:23 AM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by movax222 View Post
This represents the stack spaces for 6 threads together with the 64M regions for these threads.
Notice how each RW chunk plus the following empty chunk adds to 65536.

That's the detail I don't understand, but I haven't experimented with it myself.

Each thread needs a stack, plus some unknown amount of empty space below the stack for that stack to grow into.

The system can't predict nor correct that stack growth, so it needs a large fixed allocation (I assume some parameter controls the amount).

So the chunk before each stack is the space allocated for growth of that stack.

So why is it that the fixed value 65536 the sum of each stack plus the space after it?

Are you sure those rw things are the stacks? Notice how they all start on 64MB boundaries. I'm not surprised they were allocated on such boundaries, and that causes the 65536 sum with the next, rather than previous, empty chunk. But stacks grow downward. That would mean none of the threads grew their stacks after launch of the thread. Is that reasonable for the test you ran?

Last edited by johnsfine; 06-23-2009 at 08:30 AM.
 
Old 06-23-2009, 09:17 AM   #3
movax222
LQ Newbie
 
Registered: Sep 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Very interesting observations, johnsfine!

I have a stack size of 128K and a "guard size" of 4K, and I allocate no other per-thread heap data, so that's why I think the rw chunks are the stacks. It would be interesting to get confirmation if Linux only allocates stacks in 64M chunks on x86_64, or if something other is going on.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Allocating fixed amount of disk space to the clients shishirkotkar Linux - Newbie 1 01-03-2008 09:44 AM
Allocating hard drive space Armon Linux - General 4 05-05-2005 08:26 PM
Need Help Allocating Space on my HD to install linux! chrishikel Linux - Newbie 6 09-10-2004 02:55 PM
allocating space for new partition ranger12002 Linux - General 12 07-20-2003 03:07 PM
allocating space and a couple other things Cheese Linux - Software 2 12-09-2001 03:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration