public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Zeroed pages returned for heap
@ 2005-06-07  4:23 Nagendra Singh Tomar
  2005-06-07  8:53 ` Ulrich Drepper
  2005-06-07 15:57 ` Peter Staubach
  0 siblings, 2 replies; 7+ messages in thread
From: Nagendra Singh Tomar @ 2005-06-07  4:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arm-kernel

Hi all,
	The short version first.
Is it OK for an application (a C library implementing malloc/calloc is 
also an application) to assume that the pages returned by the OS for heap 
allocation (either directly thru brk() or thru mmap(MAP_ANONYMOUS)) will 
be zero filled. 

Now a lengthier version.

Linux zero fills all anonymous pages on allocation. This is _required_ for 
the C program BSS sections but _not_ _really_ required for heap pages. For 
heap pages the kernel zero fills them to avoid leaking any important 
information to users. On my target platform (Xscale) the memory access is 
such a big evil that I am constantly thinking of ways to avoid touching 
the damned memory as much as possible without any adverse effect on the 
kernel and applications behaviour. 
	One such way which I want to exploit is to not zero fill the heap 
pages (since mine is an embedded hardware, I do not care much abt leaking 
information out to users), since profiling has shown that the 
xscale_mc_clear_user_page function is taking lots of CPU time. When I 
implement that I see that few applications namely gcc and awk break. It 
seems that either the application or the C library is assuming about the 
pages returned by brk()/MAP_ANON, probably to improve calloc() efficiency 
( I'm not 100% sure on that as I've not yet looked at the code).
For testing I implemented this on x86 first and could boot the complete 
kernel and was able to start X, only that gcc used to crash.

I'll highly appreciate any informative views on this.

Thanx,
Tomar



-- You have moved the mouse. Windows must be restarted for the 
   changes to take effect.


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

end of thread, other threads:[~2005-06-10  3:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-07  4:23 Zeroed pages returned for heap Nagendra Singh Tomar
2005-06-07  8:53 ` Ulrich Drepper
2005-06-07  9:59   ` Nagendra Singh Tomar
2005-06-07 15:57 ` Peter Staubach
2005-06-08  4:08   ` Nagendra Singh Tomar
2005-06-09 10:14     ` Richard B. Johnson
2005-06-10  4:06       ` Nagendra Singh Tomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox