Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Nov 2000 21:40:14 +0800
From:      Peter Wemm <peter@netplex.com.au>
To:        Matt Dillon <dillon@earth.backplane.com>
Cc:        Mike Smith <msmith@FreeBSD.ORG>, Alfred Perlstein <bright@wintelcom.net>, Warner Losh <imp@village.org>, arch@FreeBSD.ORG
Subject:   Re: The shared /bin and /sbin bikeshed 
Message-ID:  <200011101340.eAADeEW34342@mobile.wemm.org>
In-Reply-To: <200011092322.eA9NMHN12920@earth.backplane.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
Matt Dillon wrote:
> :Um.  And root on a BSD box is equally screwed when there's no memory left 
> :to map in the text segment of 'ps' which just happens to contain another 
> :copy of libc.
> :
> :The difference being that if libc is shared, it's already mapped in for 
> :the hundreds of other programs using it, so you're *better* off, not 
> :worse.
> 
>     This is not exactly true.  The difference between the static binary and
>     shared binary is that *ALL* the text pages in the static binary are
>     clean.  A shared binary dirties many, many more pages to generate the
>     library relocations - as much as 60K for a simple program that links
>     into libc.

Text in a shared binary (and library) is clean too.  All references go
via the PLT and GOT.. and *they* are what get relocated and backed by swap.
The more relocations, the larger this will be.

>     So in a low memory situation the static binary will win, because clean
>     pages use the already-existing binary file image as backing store and
>     do not have to go to swap.  They can simply be discarded.

*A* static binary, yes.  If you are only using the one binary for all
processes.  I doubt many real-world out-of-memory situations are all due
to a a single static vs. dynamic 'ps' binary shared 300+ times....
More likely it'd be a runaway httpd or something, which are almost always
shared anyway.  Trying to run a static ps is going to need ~330K of ram.
Trying to run a dyanmic ps is going to need ~25K of ram for the text+data
and ~60K or so for the PLT/GOT glue, plus it will hook onto the already-present
libc.so pages for text and COW any libc.so data pages...

Cheers,
-Peter
--
Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au
"All of this is for nothing if we don't go to the stars" - JMS/B5



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011101340.eAADeEW34342>