LWN.net Logo

Sanitizing kernel memory

Sanitizing kernel memory

Posted Jun 2, 2009 15:29 UTC (Tue) by etienne_lorrain@yahoo.fr (guest, #38022)
In reply to: Sanitizing kernel memory by anton
Parent article: Sanitizing kernel memory

On the other side, if a function allocates more than it will use (allocating the maximum size is quite usual, and *alloc() may round up the size), then the zeroing at allocation will pollute all those very performance enhancing 32+ bytes cache 1 lines...
Moreover, DMA zeroing at free() time should set those cache lines in a state where they will be first reused (instead of more important lines).
Sorry, not statistics available.


(Log in to post comments)

Sanitizing kernel memory

Posted Jun 2, 2009 16:24 UTC (Tue) by anton (guest, #25547) [Link]

Yes, if the zeroed cache lines are not accessed or not accessed before being replaced in the cache, then the performance of on-demand zeroing for that cache line will be just as bad as eager zeroing in the cache, and a little worse than for eager methods that don't go through the cache. But I doubt that that's the case for the majority of cache lines. In particular, I don't think that there are replaced at all cache levels before being accessed. But yes, measurements would be a good idea.

Concerning eager zeroing of cache lines, that is certain to replace a page full of cache lines just as on-demand zeroing does, except that it is far less likely that the cache lines will be accessed before being replaced by other cache lines, so it is a bad idea. Tagging the line as least-recently-used helps only a little, if it is possible at all.

Sanitizing kernel memory

Posted Jun 4, 2009 18:30 UTC (Thu) by oak (guest, #2786) [Link]

> On the other side, if a function allocates more than it will use

I think all the user-space allocated pages point to the same zeroed/shared
physical page until they're written to?

Sanitizing kernel memory

Posted Jun 9, 2009 12:28 UTC (Tue) by etienne_lorrain@yahoo.fr (guest, #38022) [Link]

> user-space allocated pages
We were talking about kernel-space allocated memory...
Having a stock of cleared pages for user-space would probably also be an improvement (when user-space writes its first byte on a page), as long as clearing those pages does not wipe the memory cache (i.e. DMA to memory instead of processor writing).

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds