mm: slab: Add cache allocator code

A stub has been  written for the slab alloc and free functions.  At the
moment the  alloc is used by the cache  allocator function which should
be fully functional (untested though).

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Add mm_cache_free function base

The function loops through the lists  of slabs to figure out from which
slab to free, only to call the slab freeing code on that slab.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Fix atomicity issue

The issue with the cache allocator was that it wasn't atomic,i  where it
should have been.  The new mutexes in the caches are implemented so that
race conflicts  in moving caches  from empty  to partial to full,  don't
happen anymore.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: style: Minor code style tweaks

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Added actual alloc and freeing code

The slabs  should now be able  to allocate and free  objects from their
lists  of  objects.  Several features  remain  unimplemented,  such  as
marking a slab  as full  and knowing when  not  to  allocate  from  any
particular slab.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Add support for slab state switching

Slabs  now should  be able to switch  between full,  partial and  empty
states. This is untested though. Test suites, bug reports and bug fixes
will be here soon.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Remove argument and add comments

mm_slab_move had a redundant argument, which has now been removed.

Also the function lacked any kinds of significant commenting, which has
now been into place.

Hope you enjoy!

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Add comments to mm_slab_alloc

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Add comments to mm_slab_free

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Add documentation and fix race conflict

mm_slab_alloc now is commented

During the commenting process the potential for race conflicts has been
found.  This is now  resolved by checking  the state of the  slab again
once the  slab lock has been entered.  If the slab turns out to be full,
request a new slab from the cache.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Add comments and fix race conflict

While commenting the mm_cache_free function,  I found another potential
race conflict. This has now been solved by introducing some mutexes.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: test: Add testing code
Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Fix bug in mm_cache_free

Basically, the if condition on the tmp variable was incorrect

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: Add code to assist in dumping to screen

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: test: Added bulk allocation tests

Basically allocate from the slab untill its empty,  and the free to see
if this works properly.

Found bug in freeing mechanism,  as the slab  seems to be  left in both
the free list as in the full list.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: fix slab moving bug

Basically what it drilled down to was a simple typo.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: slab: test: Added bastard test

Once the slab is fully allocated,  it should not be allowed to allocate
more  space from  its  space.  The bastard test  tries to  allocate yet
another time, just to see if the allocation returns the correct answer.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>