From 44c71785d808cf0acdbba56d988dbf66159b1cf6 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Thu, 15 Dec 2016 18:36:03 +0100 Subject: [PATCH] libbarrelfish: memobj_anon: change refilling flag to be per memobj Signed-off-by: Simon Gerber --- include/barrelfish/memobj.h | 1 + lib/barrelfish/vspace/memobj_anon.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/barrelfish/memobj.h b/include/barrelfish/memobj.h index c373ece..d6867de 100644 --- a/include/barrelfish/memobj.h +++ b/include/barrelfish/memobj.h @@ -112,6 +112,7 @@ struct memobj_anon { struct slab_allocator vregion_slab; ///< Slab to back the vregion list struct memobj_frame_list *frame_list; ///< List of frames tracked by the obj struct slab_allocator frame_slab; ///< Slab to back the frame list + bool frame_slab_refilling; ///< True, iff we're currently refilling `frame_slab` }; /** diff --git a/lib/barrelfish/vspace/memobj_anon.c b/lib/barrelfish/vspace/memobj_anon.c index 1a005d0..5a47b24 100644 --- a/lib/barrelfish/vspace/memobj_anon.c +++ b/lib/barrelfish/vspace/memobj_anon.c @@ -255,9 +255,8 @@ static errval_t fill_foff(struct memobj *memobj, genvaddr_t offset, struct capre // vspace_pinned_alloc(). The is_refilling flag allows us to hand out the // last slab when coming back here from vspace_pinned_alloc(). // -SG, 2016-12-15. - static bool is_refilling = false; - if (slab_freecount(&anon->frame_slab) <= 1 && !is_refilling) { - is_refilling = true; + if (slab_freecount(&anon->frame_slab) <= 1 && !anon->frame_slab_refilling) { + anon->frame_slab_refilling = true; void *buf; err = vspace_pinned_alloc(&buf, FRAME_LIST); if (err_is_fail(err)) { @@ -265,12 +264,15 @@ static errval_t fill_foff(struct memobj *memobj, genvaddr_t offset, struct capre } slab_grow(&anon->frame_slab, buf, VSPACE_PINNED_UNIT * sizeof(struct memobj_frame_list)); - new = slab_alloc(&anon->frame_slab); - if (!new) { - return LIB_ERR_SLAB_ALLOC_FAIL; + if (new == NULL) { + new = slab_alloc(&anon->frame_slab); } - is_refilling = false; + anon->frame_slab_refilling = false; + } + if (!new) { + return LIB_ERR_SLAB_ALLOC_FAIL; } + assert(new != NULL); new->offset = offset; new->frame = frame; new->size = size; @@ -488,6 +490,8 @@ errval_t memobj_create_anon(struct memobj_anon *anon, size_t size, slab_init(&anon->vregion_slab, sizeof(struct vregion_list), NULL); slab_init(&anon->frame_slab, sizeof(struct memobj_frame_list), NULL); + anon->frame_slab_refilling = false; + anon->vregion_list = NULL; anon->frame_list = NULL; return SYS_ERR_OK; -- 1.7.2.5