|
|
Log in / Subscribe / Register

kmalloc and SNC

kmalloc and SNC

Posted Jan 27, 2011 22:35 UTC (Thu) by PaulMcKenney (✭ supporter ✭, #9624)
In reply to: kmalloc by ncm
Parent article: Concurrent code and expensive instructions

Even for allocators that segregate memory on a per-request-size basis, different-sized calls can be SNC — especially if the allocator can recycle memory that was of one size to satisfy future requests of another size. However, SNC behavior can occur even in the absence of such recycling. To see this, consider an initially empty allocator in which the first pair of requests arrive concurrently and have different request sizes. It is then quite possible that the two requests might be satisfied by the same block of memory, given that the initial request will normally allocate a large block (e.g., a page) and break it up into blocks of the requested size.

All that aside, it is true that per-size caching is an example of privatization that further reduces the probability that a given allocation/free request will need to execute an expensive instruction.

Your point about calling an unreliable kmalloc() in a loop is a good one (real-time heartburn notwithstanding), although given my scenario it would loop forever — or until an interrupt handler running on that same CPU happened to free a block of the desired size.


to post comments


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