libc - Do some reorganization of nmalloc() and add asserts.
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 9 Oct 2010 21:47:47 +0000 (14:47 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 9 Oct 2010 21:59:23 +0000 (14:59 -0700)
commite58e48b4e24346fdda3691cc17bcd42522001399
tree24beffe7d03fcbb49013a885642416be36f30b19
parentf72ba821922c7c3766c0299e8e2a56f8326db171
libc - Do some reorganization of nmalloc() and add asserts.

* Reorganize mtmagazine_alloc() and mtmagazine_free() to make the code
  more clear.  Add assertions on 'continue' loops so we abort on
  magazine memory corruption instead of looping forever.

* Pre-stage the new magazine that mtmagazine_free() might need to avoid
  having to relock the depot.  This also allows us to stage the new
  magazine directory into the per-thread loaded field instead of running
  it through the depot.

* Fix a deep or infinite recursion which can occur when mtmagazine_free()
  calls _slaballoc(), which it does sometimes when it needs a new
  magazine.  Avoid reentrancy by temporarily disabling the per-thread
  cache around the call.
lib/libc/stdlib/nmalloc.c