diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2015-05-12 18:12:20 +0800 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-05-13 14:01:35 +1000 |
commit | ceea843752331258a01a683bf203e9fce6dcd546 (patch) | |
tree | 886ee046dc4403dfcb9c1f548e333190194415c8 /core/mem_region.c | |
parent | f96dd8b3d82543ea733a7ab0e854b8331875d524 (diff) | |
download | skiboot-ceea843752331258a01a683bf203e9fce6dcd546.zip skiboot-ceea843752331258a01a683bf203e9fce6dcd546.tar.gz skiboot-ceea843752331258a01a683bf203e9fce6dcd546.tar.bz2 |
core: Add asserts for region free-list locking
This change adds asserts to the mem_region calls that should have the
per-region lock held.
To keep the tests working, they need the lock_held_by_me() function. The
run-mem_region.c test has a bogus implementation of this, as it doesn't
do any locking at the moment. This will be addressed in a later change.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/mem_region.c')
-rw-r--r-- | core/mem_region.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/mem_region.c b/core/mem_region.c index 8adb036..c3da059 100644 --- a/core/mem_region.c +++ b/core/mem_region.c @@ -376,8 +376,11 @@ found: void *mem_alloc(struct mem_region *region, size_t size, size_t align, const char *location) { - void *r = __mem_alloc(region, size, align, location); + void *r; + assert(lock_held_by_me(®ion->free_list_lock)); + + r = __mem_alloc(region, size, align, location); if (r) return r; @@ -394,6 +397,8 @@ void mem_free(struct mem_region *region, void *mem, const char *location) /* This should be a constant. */ assert(is_rodata(location)); + assert(lock_held_by_me(®ion->free_list_lock)); + /* Freeing NULL is always a noop. */ if (!mem) return; @@ -426,6 +431,8 @@ bool mem_resize(struct mem_region *region, void *mem, size_t len, /* This should be a constant. */ assert(is_rodata(location)); + assert(lock_held_by_me(®ion->free_list_lock)); + /* Get header. */ hdr = mem - sizeof(*hdr); if (hdr->free) |