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-21 14:36:04 +1000
commit5f4c0b3b86de905e7eac4acdb976254df145f1c1 (patch)
tree6e18381a8a278bdbe78b8ffe447352f7090f1463 /include
parenta653df93b2d22691ac1583584c8292e6e421464f (diff)
downloadskiboot-5f4c0b3b86de905e7eac4acdb976254df145f1c1.zip
skiboot-5f4c0b3b86de905e7eac4acdb976254df145f1c1.tar.gz
skiboot-5f4c0b3b86de905e7eac4acdb976254df145f1c1.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 23ee18c..7240b17 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;