aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2015-05-12 18:12:20 +0800
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-05-13 14:01:35 +1000
commitf96dd8b3d82543ea733a7ab0e854b8331875d524 (patch)
tree41b87ac71ac02d24b0a37dc556974522e97c3831 /include
parent8f527a0290068f1b2224fcfd7d88d91eab6ddd6f (diff)
downloadskiboot-f96dd8b3d82543ea733a7ab0e854b8331875d524.zip
skiboot-f96dd8b3d82543ea733a7ab0e854b8331875d524.tar.gz
skiboot-f96dd8b3d82543ea733a7ab0e854b8331875d524.tar.bz2
core: Move free-list locking to a separate per-region lock
Currently, we have a single lock for the entire mem_region system; this protects both the global region list, and the allocations from each region. This means we can't allocate memory while traversing the global region list, as any malloc/realloc/free will try to acquire the mem_region lock again. This change separates the locking into different functions. We keep the mem_region_lock to protect the regions list, and introduce a per-region lock to protect allocations from the regions' free_lists. Then we remove the open-coded invocations of mem_alloc, where we'd avoided malloc() due to the above locking issue. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/mem_region.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/mem_region.h b/include/mem_region.h
index d6dd296..e5cf0f6 100644
--- a/include/mem_region.h
+++ b/include/mem_region.h
@@ -19,6 +19,8 @@
#include <ccan/list/list.h>
#include <stdint.h>
+#include <lock.h>
+
enum mem_region_type {
/* ranges allocatable by mem_alloc: this will be most of memory */
REGION_SKIBOOT_HEAP,
@@ -41,6 +43,7 @@ struct mem_region {
struct dt_node *mem_node;
enum mem_region_type type;
struct list_head free_list;
+ struct lock free_list_lock;
};
extern struct lock mem_region_lock;