lkml.org 
[lkml]   [2007]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [rfc] no ZERO_PAGE?
From
Date
On Wed, 04 Apr 2007 17:27:31 PDT, Linus Torvalds said:

> Sure you do. If glibc used mmap() or brk(), it *knows* the new data is
> zero. So if you use calloc(), for example, it's entirely possible that
> a good libc wouldn't waste time zeroing it.

Right. However, the *user* code usually has no idea about the previous
history - so if it uses malloc(), it should be doing something like:

ptr = malloc(my_size*sizeof(whatever));
memset(ptr, my_size*sizeof(), 0);

So malloc does something clever to guarantee that it's zero, and then userspace
undoes the cleverness because it has no easy way to *know* that cleverness
happened.

Admittedly, calloc() *can* get away with being clever. I know we have some
glibc experts lurking here - any of them want to comment on how smart calloc()
actually is, or how smart it can become without needing major changes to the
rest of the malloc() and friends?

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2007-04-05 03:29    [W:0.079 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site