public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Petr Vandrovec" <VANDROVE@vc.cvut.cz>
To: Wayne Whitney <whitney@math.berkeley.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Repost: could ia32 mmap() allocations grow downward?
Date: Wed, 12 Dec 2001 21:47:49 MET-1	[thread overview]
Message-ID: <BCF5AF03A80@vcnet.vc.cvut.cz> (raw)

On 12 Dec 01 at 12:02, Wayne Whitney wrote:

> o Pick a maximum stack size S and change the kernel so the "mmap()
>   without MAP_FIXED" region starts at 0xC0000000 - S and grows downwards. 

How you'll pick S? 8MB? 128MB? Now you can have 1GB brk + 2GB (stack+mmap),
after change you have 2.9GB (brk+mmap), but only 128MB stack. And if you'll
change your malloc implementation, you can have up to 2GB stack now, or
up to 3GB of mmap. After your change your stack is limited to 128MB, and
you cannot do anything around that except moving stack somewhere else
during libc startup - and in this case couple of argv[] assumptions
setproctitle and other do are no longer valid.

Another problem is mremap. Due to way how apps works, you'll have
to move VMAs around much more because of you cannot grow your last
VMA up without move. And if you shrink your last block, you'll get
a gap.
 
> This seems ideal, as it allows the balance between the mmap() region and
> the brk() region to vary for each process, automatically.  What changes
> would be required to the kernel to implement this properly and
> efficiently?  Is there some downside I am missing?

Nobody can call brk() directly from app, as libc may use brk() for
implementing malloc(), and libraries can call malloc. So you have to
create your own allocator on the top of brk() results, and this
allocator must not release memory back to system, as this could
release also chunks you do not own. Writting your allocator on the
top of malloc()ed areas is much better idea.
                                                Best regards,
                                                    Petr Vandrovec
                                                    vandrove@vc.cvut.cz
                                                    
P.S.: I do not think that your app calls directly brk(). I think that
your app calls malloc with some small number, and libc decides to use
brk() instead of mmap(). And in such case it is bug in your libc that 
it does not use mmap() after brk() fails.

             reply	other threads:[~2001-12-12 20:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-12 21:47 Petr Vandrovec [this message]
2001-12-13  6:28 ` Repost: could ia32 mmap() allocations grow downward? Wayne Whitney
  -- strict thread matches above, loose matches on Subject: below --
2001-12-13 20:13 Petr Vandrovec
2001-12-13 18:36 Petr Vandrovec
2001-12-13 18:03 ` Wayne Whitney
2001-12-13 11:27 Petr Vandrovec
2001-12-13 16:22 ` Wayne Whitney
2001-12-13 16:54   ` Wayne Whitney
2001-12-13 17:10   ` Hugh Dickins
2001-12-13 17:38     ` Wayne Whitney
2001-12-13 18:02       ` Hugh Dickins
2001-12-12 20:02 Wayne Whitney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BCF5AF03A80@vcnet.vc.cvut.cz \
    --to=vandrove@vc.cvut.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=whitney@math.berkeley.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox