void ion_page_pool_destroy(struct ion_page_pool *pool);
struct page *ion_page_pool_alloc(struct ion_page_pool *pool, bool nozero);
void ion_page_pool_free(struct ion_page_pool *pool, struct page *page);
+int ion_page_pool_total(struct ion_page_pool *pool, bool high);
/** ion_page_pool_shrink - shrinks the size of the memory cached in the pool
* @pool: the pool
ion_page_pool_free_pages(pool, page);
}
-static int ion_page_pool_total(struct ion_page_pool *pool, bool high)
+int ion_page_pool_total(struct ion_page_pool *pool, bool high)
{
int count = pool->low_count;
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
+#include <linux/module.h>
#include "ion.h"
#define NUM_ORDERS ARRAY_SIZE(orders)
return -ENOMEM;
}
+static int max_page_pool_size = INT_MAX;
+module_param(max_page_pool_size, int, 0600);
+
static void ion_system_heap_free(struct ion_buffer *buffer)
{
struct ion_system_heap *sys_heap = container_of(buffer->heap,
heap);
struct sg_table *table = buffer->sg_table;
struct scatterlist *sg;
+ unsigned int count = 0;
int i;
+ for (i = 0; i < NUM_ORDERS; i++) {
+ count += ion_page_pool_total(sys_heap->cached_pools[i], true);
+ count += ion_page_pool_total(sys_heap->uncached_pools[i], true);
+ }
+
+ if (count > max_page_pool_size)
+ buffer->private_flags |= ION_PRIV_FLAG_SHRINKER_FREE;
+
/* zero the buffer before goto page pool */
if (!(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE))
ion_heap_buffer_zero(buffer);