public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Last data page not being filled
@ 2003-06-27  7:08 D. J. Bernstein
  2003-06-27  9:37 ` Alexandre Oliva
  2003-06-27 16:45 ` Zack Weinberg
  0 siblings, 2 replies; 5+ messages in thread
From: D. J. Bernstein @ 2003-06-27  7:08 UTC (permalink / raw)
  To: gcc-bugs

When a program has (to take a real example) 220 bytes of initialized
data and 444 bytes of zero-filled data, gcc puts the 220 bytes into the
data segment and the 444 bytes into the bss segment, frittering away a
page of memory per process. It should instead put all 664 bytes into the
data segment.

The general rule is simple: as long as there's something in bss that
fits into the last page of data, move it to the last page of data and
repeat, unless -fminimize-data is specified.

(The reason I care about a page per process is that I'm building systems
on the scale of ten thousand processes. Each process has its own uid,
and memory protection is crucial, so please don't suggest threads.)

---D. J. Bernstein, Associate Professor, Department of Mathematics,
Statistics, and Computer Science, University of Illinois at Chicago


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Last data page not being filled
  2003-06-27  7:08 Last data page not being filled D. J. Bernstein
@ 2003-06-27  9:37 ` Alexandre Oliva
  2003-06-27 11:23   ` D. J. Bernstein
  2003-06-27 16:45 ` Zack Weinberg
  1 sibling, 1 reply; 5+ messages in thread
From: Alexandre Oliva @ 2003-06-27  9:37 UTC (permalink / raw)
  To: D. J. Bernstein; +Cc: gcc-bugs

On Jun 27, 2003, "D. J. Bernstein" <djb@cr.yp.to> wrote:

> gcc puts the 220 bytes into the data segment and the 444 bytes into
> the bss segment

GCC puts them in sections, not segments.  It's the linker that maps
sections to segments.  Assuming you're using the GNU linker, the
mailing list in which to discuss such issues is
binutils@sources.redhat.com.  Make sure you have a look at the
documentation of linker scripts in the GNU ld manual first, maybe this
will already solve the problem.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Last data page not being filled
  2003-06-27  9:37 ` Alexandre Oliva
@ 2003-06-27 11:23   ` D. J. Bernstein
  0 siblings, 0 replies; 5+ messages in thread
From: D. J. Bernstein @ 2003-06-27 11:23 UTC (permalink / raw)
  To: gcc-bugs

Alexandre Oliva writes:
> Assuming you're using the GNU linker, the mailing list in which to
> discuss such issues is binutils@sources.redhat.com.

Thanks. Sorry for the misdirected message.

---D. J. Bernstein, Associate Professor, Department of Mathematics,
Statistics, and Computer Science, University of Illinois at Chicago


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Last data page not being filled
  2003-06-27  7:08 Last data page not being filled D. J. Bernstein
  2003-06-27  9:37 ` Alexandre Oliva
@ 2003-06-27 16:45 ` Zack Weinberg
  2003-07-03  5:26   ` Richard Henderson
  1 sibling, 1 reply; 5+ messages in thread
From: Zack Weinberg @ 2003-06-27 16:45 UTC (permalink / raw)
  To: D. J. Bernstein; +Cc: gcc-bugs

"D. J. Bernstein" <djb@cr.yp.to> writes:

> When a program has (to take a real example) 220 bytes of initialized
> data and 444 bytes of zero-filled data, gcc puts the 220 bytes into the
> data segment and the 444 bytes into the bss segment, frittering away a
> page of memory per process. It should instead put all 664 bytes into the
> data segment.

What you really want, I think, is for the linker to recognize that
there is no need to align the breakpoint between data and bss to a
page boundary.  The kernel will zero-fill the last page of the data
segment when it's mapped in, so bss symbols can be stuck into that
space.  Since there is no cost whatsoever to this approach (unlike
your original suggestion which would enlarge executables on disk)
there is no reason not to do it unconditionally.

This probably requires changes both to the linker (part of binutils)
and the dynamic loader (part of glibc, for Linux; normally maintained
with the C library of other systems as well).  

zw


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Last data page not being filled
  2003-06-27 16:45 ` Zack Weinberg
@ 2003-07-03  5:26   ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2003-07-03  5:26 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: D. J. Bernstein, gcc-bugs

On Fri, Jun 27, 2003 at 09:45:30AM -0700, Zack Weinberg wrote:
> What you really want, I think, is for the linker to recognize that
> there is no need to align the breakpoint between data and bss to a
> page boundary.

And it doesn't, so I'm not sure where he got this idea.


r~


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-07-03  5:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-27  7:08 Last data page not being filled D. J. Bernstein
2003-06-27  9:37 ` Alexandre Oliva
2003-06-27 11:23   ` D. J. Bernstein
2003-06-27 16:45 ` Zack Weinberg
2003-07-03  5:26   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).