Re: [rfc] no ZERO_PAGE?

Valdis.Kletnieks
2007-04-05T01:25:12Z

[-- Attachment #1: Type: text/plain, Size: 903 bytes --]

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?

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]