[BusyBox] choice for reserving buffers

Larry Doolittle ldoolitt at recycle.lbl.gov
Fri Jan 26 17:06:21 UTC 2001


On Fri, Jan 26, 2001 at 01:47:11PM +0300, Vladimir N. Oleynik wrote:
> 
> Please run test in attach. 
> The test have 50M BSS buffer, and usage only 2M, and viewing this.

Interesting.  Everybody is at least partly right!  And I'll bet this
program dies a horrible death on uClinux.

The definition of BSS is that the memory appears and is zero.
As Erik pointed out on Jan 4:

EA> Only the bss and stack space memory is allocated per process, and
EA> even then, since Linux does lazy allocation, pages of memory are
EA> not actually allocated until a process writes to stuff living in
EA> .bss.  Then, Linux creates space just for what was written, not the
EA> whole bss).

So I was able to see in /proc/self/maps that there is a 50 M virtual
memory allocation, and that does require some space for page tables,
but the pages themselves don't appear until needed.

So Vladimir has me convinced that, on Linux at least, BSS is the
"cheapest" way to go.  We need to be aware of the subject (that
should be easy, after all this discussion :*) ) when BusyBox starts
to work on other systems with less sophisticated memory handling --
such as uClinux.

If the system runs short on memory, malloc will return NULL (and
the xmalloc wrapper will exit).  A page fault that should create
a new, physical BSS page, but can't because of a memory shortage,
will turn into a SIGSEGV, or similar.

      - Larry





More information about the busybox mailing list