History log of /haiku/src/system/kernel/slab/ObjectDepot.cpp
Revision Date Author Comments
# e1c6140e 01-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmlr + bonefish:
* Add optional stack trace capturing for slab memory manager tracing.
* Add allocation tracking for the slab allocator (enabled via
SLAB_ALLOCATION_TRACKING). The allocation tracking requires tracing
with stack traces to be enabled for object caches and/or the memory
manager.
- Add class AllocationTrackingInfo that associates an allocation with
its respective tracing entry. The structure is added to the end of
an allocation done by the memory manager. For the object caches
there's a separate array for each slab.
- Add code range markers to the slab code, so that the first caller
into the slab code can be retrieved from the stack traces.
- Add KDL command "allocations_per_caller" that lists all allocations
summarized by caller.
* Move debug definitions from slab_private.h to slab_debug.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43072 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 72156a40 31-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Introduce "paranoid" malloc/free into the slab allocator (initializing
allocated memory to 0xcc and setting freed memory to 0xdeadbeef).
* Allow for optional stack traces for slab object cache tracing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43046 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2a196c63 03-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

exchange_with_empty() did not set the freeMagazine return value to NULL when
the maximum magazine count wasn't reached yet. With object_depot_store() not
resetting its local variable, a magazine could thus be emptied and freed
twice. Fixes #5489 and #5497.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35752 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 464d9f12 24-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed object_depot_store() return value to void. It is now always takes
over ownership of the object. Fixes double free introduced in r35605.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35608 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 462dd94a 24-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Don't leak the object when allocating a magazine failed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35605 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6426413d 24-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Also print the maximum full count, and the magazine capacity when being
dumped.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35603 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ff59ce68 24-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* The low resource handler now empties the cache depot's magazines; before,
they were never freed unless the cache was destroyed (I just wondered why
my system would bury >1G in the magazines).
* Made the magazine capacity variable per cache, ie. for larger objects, it's
not a good idea to have 64*CPU buffers lying around in the worst case.
* Furthermore, the create_object_cache_etc()/object_depot_init() now have
arguments for the magazine capacity as well as the maximum number of full
unused magazines.
* By default, you might want to initialize both to zero, as then some hopefully
usable defaults are computed. Otherwise (the only current example is the
vm_page_mapping cache) you can just put in the values you'd want there.
The page mapping cache uses larger values, as its objects are usually
allocated and deleted in larger chunks.
* Beware, though, I couldn't test these changes yet as Qemu didn't like to run
today. I'll test these changes on another machine now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35601 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 54f3267e 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed maintaining the object depot's free magazine count (it's not really used
though).
* Added/improved some KDL commands to make the slab easier to work with from
KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35466 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d1316fd 22-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced CACHE_DONT_SLEEP by two new flags CACHE_DONT_WAIT_FOR_MEMORY and
CACHE_DONT_LOCK_KERNEL_SPACE. If the former is given, the slab memory manager
does not wait when reserving memory or pages. The latter prevents area
operations. The new flags add a bit of flexibility. E.g. when allocating page
mapping objects for userland areas CACHE_DONT_WAIT_FOR_MEMORY is sufficient,
i.e. the allocation will succeed as long as pages are available.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35246 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86c794e5 21-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

slab allocator:
* Implemented a more elaborated raw memory allocation backend (MemoryManager).
We allocate 8 MB areas whose pages we allocate and map when needed. An area is
divided into equally-sized chunks which form the basic units of allocation. We
have areas with three possible chunk sizes (small, medium, large), which is
basically what the ObjectCache implementations were using anyway.
* Added "uint32 flags" parameter to several of the slab allocator's object
cache and object depot functions. E.g. object_depot_store() potentially wants
to allocate memory for a magazine. But also in pure freeing functions it
might eventually become useful to have those flags, since they could end up
deleting an area, which might not be allowable in all situations. We should
introduce specific flags to indicate that.
* Reworked the block allocator. Since the MemoryManager allocates block-aligned
areas, maintains a hash table for lookup, and maps chunks to object caches,
we can quickly find out which object cache a to be freed allocation belongs
to and thus don't need the boundary tags anymore.
* Reworked the slab boot strap process. We allocate from the initial area only
when really necessary, i.e. when the object cache for the respective
allocation size has not been created yet. A single page is thus sufficient.

other:
* vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the
semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS.
* Use an object cache for page mappings. This significantly reduces the
contention on the heap bin locks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35232 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bb439b87 20-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Consequently propagate the CACHE_DONT_SLEEP flag.
* block_alloc(): Create B_FULL_LOCK area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35202 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 453a2bdd 20-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced the locking strategy (formerly a recursive lock for the depot and
one for each per CPU store):
* The depot is now protected by a R/W lock combined with a spinlock. It is
required to either hold read lock + spinlock or just the write lock.
* When accessing the per CPU stores we only need to acquire the read lock
and disable interrupts. When switching magazines with the depot we
additionally get the spinlock.
* When allocating a new magazine we do completely unlock.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35200 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 030a4ea6 19-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Reordered functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35199 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bcf73b3a 19-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Pulled smp_get_num_cpus() out of loops.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35181 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 825566f8 19-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Split the slab allocator code into separate source files and C++-ified
things a bit.
* Some style cleanup.
* The object depot does now have a cookie that will be passed to the return
hook.
* Fixed object_cache_return_object_wrapper() using the new cookie.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35174 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8806e5e 19-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed headers/private/kernel/slab/Depot.h to ObjectDepot.h.
* Moved the object depot code to its own source file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35161 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1c6140eaa641aa95fc6d82f0d5c53cf4fe41a16 01-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmlr + bonefish:
* Add optional stack trace capturing for slab memory manager tracing.
* Add allocation tracking for the slab allocator (enabled via
SLAB_ALLOCATION_TRACKING). The allocation tracking requires tracing
with stack traces to be enabled for object caches and/or the memory
manager.
- Add class AllocationTrackingInfo that associates an allocation with
its respective tracing entry. The structure is added to the end of
an allocation done by the memory manager. For the object caches
there's a separate array for each slab.
- Add code range markers to the slab code, so that the first caller
into the slab code can be retrieved from the stack traces.
- Add KDL command "allocations_per_caller" that lists all allocations
summarized by caller.
* Move debug definitions from slab_private.h to slab_debug.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43072 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 72156a402f54ea4be9dc3e3e9704c612f7d9ad16 31-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Introduce "paranoid" malloc/free into the slab allocator (initializing
allocated memory to 0xcc and setting freed memory to 0xdeadbeef).
* Allow for optional stack traces for slab object cache tracing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43046 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2a196c634904e919ae9ee3dda90de522b7f3f5a3 03-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

exchange_with_empty() did not set the freeMagazine return value to NULL when
the maximum magazine count wasn't reached yet. With object_depot_store() not
resetting its local variable, a magazine could thus be emptied and freed
twice. Fixes #5489 and #5497.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35752 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 464d9f1252a638eee63ca5cdf72e5cd321df47e1 24-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed object_depot_store() return value to void. It is now always takes
over ownership of the object. Fixes double free introduced in r35605.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35608 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 462dd94a1f0cb7e94a840e26bfd5f45e5a77714f 24-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Don't leak the object when allocating a magazine failed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35605 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6426413dcbdd1d9d612d44972c7ec78e019e854f 24-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Also print the maximum full count, and the magazine capacity when being
dumped.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35603 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ff59ce680df5d2032ea5a11c666688269225f033 24-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* The low resource handler now empties the cache depot's magazines; before,
they were never freed unless the cache was destroyed (I just wondered why
my system would bury >1G in the magazines).
* Made the magazine capacity variable per cache, ie. for larger objects, it's
not a good idea to have 64*CPU buffers lying around in the worst case.
* Furthermore, the create_object_cache_etc()/object_depot_init() now have
arguments for the magazine capacity as well as the maximum number of full
unused magazines.
* By default, you might want to initialize both to zero, as then some hopefully
usable defaults are computed. Otherwise (the only current example is the
vm_page_mapping cache) you can just put in the values you'd want there.
The page mapping cache uses larger values, as its objects are usually
allocated and deleted in larger chunks.
* Beware, though, I couldn't test these changes yet as Qemu didn't like to run
today. I'll test these changes on another machine now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35601 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 54f3267e78aaf6fb1e2b941596f1c2863e7f1790 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed maintaining the object depot's free magazine count (it's not really used
though).
* Added/improved some KDL commands to make the slab easier to work with from
KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35466 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d1316fd23616f6dac131a0eba5dab08acc6e76d 22-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced CACHE_DONT_SLEEP by two new flags CACHE_DONT_WAIT_FOR_MEMORY and
CACHE_DONT_LOCK_KERNEL_SPACE. If the former is given, the slab memory manager
does not wait when reserving memory or pages. The latter prevents area
operations. The new flags add a bit of flexibility. E.g. when allocating page
mapping objects for userland areas CACHE_DONT_WAIT_FOR_MEMORY is sufficient,
i.e. the allocation will succeed as long as pages are available.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35246 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86c794e5c10f1b2d99d672d424a8637639c703dd 21-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

slab allocator:
* Implemented a more elaborated raw memory allocation backend (MemoryManager).
We allocate 8 MB areas whose pages we allocate and map when needed. An area is
divided into equally-sized chunks which form the basic units of allocation. We
have areas with three possible chunk sizes (small, medium, large), which is
basically what the ObjectCache implementations were using anyway.
* Added "uint32 flags" parameter to several of the slab allocator's object
cache and object depot functions. E.g. object_depot_store() potentially wants
to allocate memory for a magazine. But also in pure freeing functions it
might eventually become useful to have those flags, since they could end up
deleting an area, which might not be allowable in all situations. We should
introduce specific flags to indicate that.
* Reworked the block allocator. Since the MemoryManager allocates block-aligned
areas, maintains a hash table for lookup, and maps chunks to object caches,
we can quickly find out which object cache a to be freed allocation belongs
to and thus don't need the boundary tags anymore.
* Reworked the slab boot strap process. We allocate from the initial area only
when really necessary, i.e. when the object cache for the respective
allocation size has not been created yet. A single page is thus sufficient.

other:
* vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the
semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS.
* Use an object cache for page mappings. This significantly reduces the
contention on the heap bin locks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35232 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bb439b871e0be2e107ecc868be8c5660836f4253 20-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Consequently propagate the CACHE_DONT_SLEEP flag.
* block_alloc(): Create B_FULL_LOCK area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35202 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 453a2bdd18f2425ba61eed2205f86218238d200e 20-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced the locking strategy (formerly a recursive lock for the depot and
one for each per CPU store):
* The depot is now protected by a R/W lock combined with a spinlock. It is
required to either hold read lock + spinlock or just the write lock.
* When accessing the per CPU stores we only need to acquire the read lock
and disable interrupts. When switching magazines with the depot we
additionally get the spinlock.
* When allocating a new magazine we do completely unlock.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35200 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 030a4ea6c911443cb6e4baf58ec5348ff2c8fe41 19-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Reordered functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35199 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bcf73b3a5941b70065d13544b07a3e7b6fe0297a 19-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Pulled smp_get_num_cpus() out of loops.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35181 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 825566f82f652d82ffaf3f0deca0a2bcda1e02c2 19-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Split the slab allocator code into separate source files and C++-ified
things a bit.
* Some style cleanup.
* The object depot does now have a cookie that will be passed to the return
hook.
* Fixed object_cache_return_object_wrapper() using the new cookie.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35174 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8806e5e0dad28238343bd4dcc8d035657d358ff 19-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed headers/private/kernel/slab/Depot.h to ObjectDepot.h.
* Moved the object depot code to its own source file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35161 a95241bf-73f2-0310-859d-f6bbb57e9c96