From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Gianni Tedesco <gianni@ecsc.co.uk>
Cc: Mike Black <mblack@csihq.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: mmap'ing a large file
Date: Wed, 14 Aug 2002 20:42:47 +0100 [thread overview]
Message-ID: <20020814204247.C26404@kushida.apsleyroad.org> (raw)
In-Reply-To: <1029342745.8255.6.camel@lemsip>; from gianni@ecsc.co.uk on Wed, Aug 14, 2002 at 05:32:23PM +0100
Gianni Tedesco wrote:
> On Wed, 2002-08-14 at 16:42, Mike Black wrote:
> > Is there a logical reason why a process can't mmap more than a 2G file?
> >
> > I seem to get stuck at 2142208000 with
> > mmap: Cannot allocate memory
>
> Perhaps this should be an FAQ item.
>
> Intel is a 32bit architecture, that is to say the address space is 2^32
> bytes (4GB), of this address space the kernel takes the top 2GB and
> userspace the bottom 2GB.
No, firstly those numbers are incorrect and secondly, that's not the
reason why Mike's program stops at 2142208000.
The standard kernel's address space provides exactly 3GB for userspace.
The range of user addresses is 0x00000000 to 0xbfffffff. So the
absolute maximum that can be mmaped at a time is a little under 3GB.
The reason why Mike's program won't mmap() more than about 2GB of the
file is for two reasons:
1. mmap() will search for a free address starting at 0x40000000, up to
0xbffff000. It won't search lower addresses, unless you give it a
hint, and the hinted address is actually unmapped. I think this is
to reserve about 1GB for brk().
2. The executable and shared libraries take some room, too.
Btw Mike, the original program uses `p' uninitialised. If you weren't
so lucky (say if the stack is initialised differently) you could get
much less than 2GB.
-- Jamie
next prev parent reply other threads:[~2002-08-14 19:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-14 15:42 mmap'ing a large file Mike Black
2002-08-14 16:32 ` Gianni Tedesco
2002-08-14 19:42 ` Jamie Lokier [this message]
2002-08-15 19:34 ` H. Peter Anvin
2002-08-15 10:02 ` DervishD
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=20020814204247.C26404@kushida.apsleyroad.org \
--to=lk@tantalophile.demon.co.uk \
--cc=gianni@ecsc.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=mblack@csihq.com \
/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