fileobj/shmobj: release pages correctly according to dynamic page frame management

This commit is contained in:
Balazs Gerofi
2016-09-13 00:05:51 -04:00
parent 8eb3bf3559
commit f4db8b96de
2 changed files with 25 additions and 1 deletions

View File

@ -258,6 +258,7 @@ static void fileobj_release(struct memobj *memobj)
/* zap page_list */ /* zap page_list */
for (;;) { for (;;) {
struct page *page; struct page *page;
void *page_va;
int count; int count;
page = page_list_first(obj); page = page_list_first(obj);
@ -265,6 +266,17 @@ static void fileobj_release(struct memobj *memobj)
break; break;
} }
page_list_remove(obj, page); page_list_remove(obj, page);
page_va = phys_to_virt(page_to_phys(page));
if (ihk_atomic_read(&page->count) != 1) {
kprintf("%s: WARNING: page count for phys 0x%lx is invalid\n",
__FUNCTION__, page->phys);
}
if (page_unmap(page)) {
ihk_mc_free_pages(page_va, 1);
}
#if 0
count = ihk_atomic_sub_return(1, &page->count); count = ihk_atomic_sub_return(1, &page->count);
if (!((page->mode == PM_WILL_PAGEIO) if (!((page->mode == PM_WILL_PAGEIO)
@ -281,7 +293,7 @@ static void fileobj_release(struct memobj *memobj)
} }
page->mode = PM_NONE; page->mode = PM_NONE;
ihk_mc_free_pages(phys_to_virt(page_to_phys(page)), 1); #endif
} }
obj_list_remove(free_obj); obj_list_remove(free_obj);
ihk_mc_spinlock_unlock_noirq(&fileobj_list_lock); ihk_mc_spinlock_unlock_noirq(&fileobj_list_lock);

View File

@ -240,6 +240,7 @@ void shmobj_destroy(struct shmobj *obj)
npages = (size_t)1 << (obj->pgshift - PAGE_SHIFT); npages = (size_t)1 << (obj->pgshift - PAGE_SHIFT);
for (;;) { for (;;) {
struct page *page; struct page *page;
void *page_va;
int count; int count;
page = page_list_first(obj); page = page_list_first(obj);
@ -247,7 +248,17 @@ void shmobj_destroy(struct shmobj *obj)
break; break;
} }
page_list_remove(obj, page); page_list_remove(obj, page);
page_va = phys_to_virt(page_to_phys(page));
if (ihk_atomic_read(&page->count) != 1) {
kprintf("%s: WARNING: page count for phys 0x%lx is invalid\n",
__FUNCTION__, page->phys);
}
if (page_unmap(page)) {
ihk_mc_free_pages(page_va, npages);
}
#if 0
dkprintf("shmobj_destroy(%p):" dkprintf("shmobj_destroy(%p):"
"release page. %p %#lx %d %d", "release page. %p %#lx %d %d",
obj, page, page_to_phys(page), obj, page, page_to_phys(page),
@ -266,6 +277,7 @@ void shmobj_destroy(struct shmobj *obj)
page->mode = PM_NONE; page->mode = PM_NONE;
ihk_mc_free_pages(phys_to_virt(page_to_phys(page)), npages); ihk_mc_free_pages(phys_to_virt(page_to_phys(page)), npages);
#endif
} }
if (obj->index < 0) { if (obj->index < 0) {
kfree(obj); kfree(obj);