On Sat, May 20, 2006 at 10:15:12AM +0800, Dan Jacobson wrote:
> #J>you mean mmap of course
> retitle 367584 mmap man pages maybe warn of breaking /dev/stdin
> thanks
> J> ... |strace dpkg --merge-avail /dev/stdin 2>&1 |less
> I think it isn't that simple, with /dev/stdin and 2>&1 together.
> Anyways, this is no place for a simpleton like me.
> 
> All I know is that on 367297 he said something might be due to mmap,
> and I noticed no warning about it on mmap man pages. I don't really
> know what mmap is all about actually. Maybe the mmap and the dpkg
> people can fight/figure this out, please.
Did try the strace as I requested?

You can't mmap stdin.  It is documented, anyway:

| EACCES A  file descriptor refers to a non-regular file.

mmap is a mostly-portable unix interface to the memory management unit
(MMU).  One typically maps a file into memory, requesting its contents
is made available at some region of memory.  This defer the paging
decisions to the kernel, which actually knows about other processes
and can make better decisions about caching and stuff.  This is better
than allocating st_size bytes and reading it in, for a handful of
reasons, including that you don't need to have st_size bytes of
virtual ram/address space, and that you don't need to read stuff that
you will never use.  You also don't need to write the read() loop.
Shared libraries are mapped into the address space; this is one of the
huge reasons why shared libs exist; only one copy of the lib is in
memory at a given time, independant of how many processes mmap it.
Consider the benefits for eg. libc6, which every process uses.

Justin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to