[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5946.1175736312@turing-police.cc.vt.edu>
Date: Wed, 04 Apr 2007 21:25:12 -0400
From: Valdis.Kletnieks@...edu
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Nick Piggin <npiggin@...e.de>, Hugh Dickins <hugh@...itas.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Memory Management List <linux-mm@...ck.org>,
tee@....com, holt@....com, Andrea Arcangeli <andrea@...e.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [rfc] no ZERO_PAGE?
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?
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists