memobj: synch prefetch among processes

This commit is contained in:
Balazs Gerofi
2016-12-18 13:46:46 +09:00
parent 5b7bcb7170
commit ff37ff9ccf
3 changed files with 32 additions and 6 deletions

View File

@ -226,12 +226,26 @@ int fileobj_create(int fd, struct memobj **objp, int *maxprotp)
obj_list_insert(newobj);
obj = newobj;
to_memobj(obj)->flags |= result.flags;
to_memobj(obj)->status = MEMOBJ_READY;
if (to_memobj(obj)->flags & MF_PREFETCH) {
to_memobj(obj)->status = MEMOBJ_TO_BE_PREFETCHED;
}
newobj = NULL;
dkprintf("%s: new obj 0x%lx cref: %d, %s\n",
__FUNCTION__,
obj,
obj->cref,
to_memobj(obj)->flags & MF_ZEROFILL ? "zerofill" : "");
}
else {
++obj->sref;
++obj->cref;
memobj_unlock(&obj->memobj); /* locked by obj_list_lookup() */
dkprintf("%s: existing obj 0x%lx cref: %d, %s\n",
__FUNCTION__,
obj,
obj->cref,
to_memobj(obj)->flags & MF_ZEROFILL ? "zerofill" : "");
}
mcs_rwlock_writer_unlock_noirq(&fileobj_list_lock, &node);
@ -281,7 +295,13 @@ static void fileobj_release(struct memobj *memobj)
memobj_unlock(&obj->memobj);
if (free_obj) {
mcs_lock_lock_noirq(&fileobj_list_lock, &node);
dkprintf("%s: release obj 0x%lx cref: %d, free_obj: 0x%lx, %s\n",
__FUNCTION__,
obj,
obj->cref,
free_obj,
to_memobj(obj)->flags & MF_ZEROFILL ? "zerofill" : "");
mcs_rwlock_writer_lock_noirq(&fileobj_list_lock, &node);
/* zap page_list */
for (;;) {
struct page *page;

View File

@ -37,11 +37,14 @@ enum {
MF_END
};
#define MEMOBJ_READY 0
#define MEMOBJ_TO_BE_PREFETCHED 1
struct memobj {
struct memobj_ops * ops;
uint32_t flags;
int8_t padding[4];
ihk_spinlock_t lock;
struct memobj_ops *ops;
uint32_t flags;
uint32_t status;
ihk_spinlock_t lock;
};
typedef void memobj_release_func_t(struct memobj *obj);

View File

@ -1363,9 +1363,12 @@ do_mmap(const intptr_t addr0, const size_t len0, const int prot,
goto out;
}
if (memobj->flags & MF_PREFETCH) {
memobj_lock(memobj);
if (memobj->status == MEMOBJ_TO_BE_PREFETCHED) {
memobj->status = MEMOBJ_READY;
populated_mapping = 1;
}
memobj_unlock(memobj);
error = 0;
p = NULL;