Messages in this thread | | | Subject | Re: [rfc] no ZERO_PAGE? | From | Valdis.Kletnieks@vt ... | Date | Wed, 04 Apr 2007 21:25:12 -0400 |
| |
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] | |