Currently the mutex is held while kmalloc is called, under a low memory
condition this might trigger the shrinker which also takes this mutex.
Refactor so the mutex is not held during allocation.
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
[jstultz: modified patch to apply to staging directory]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
item = kmalloc(sizeof(struct ion_page_pool_item), GFP_KERNEL);
if (!item)
return -ENOMEM;
+
+ mutex_lock(&pool->mutex);
item->page = page;
if (PageHighMem(page)) {
list_add_tail(&item->list, &pool->high_items);
list_add_tail(&item->list, &pool->low_items);
pool->low_count++;
}
+ mutex_unlock(&pool->mutex);
return 0;
}
{
int ret;
- mutex_lock(&pool->mutex);
ret = ion_page_pool_add(pool, page);
- mutex_unlock(&pool->mutex);
if (ret)
ion_page_pool_free_pages(pool, page);
}