From 3c29b7a199f1d33a0537c0bb99c830e9b21c2280 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Tue, 15 Oct 2019 17:06:43 -0700 Subject: [PATCH] ion: Conditionally compile page pool refill code Compile the page pool refill code only when CONFIG_ION_POOL_AUTO_REFILL is enabled. Change-Id: Ia4024f3d6eec08769d837fbc3f81f778cdd29bff Signed-off-by: Isaac J. Manjarres --- drivers/staging/android/ion/heaps/Kconfig | 2 +- .../staging/android/ion/heaps/ion_page_pool.c | 62 ++++++++++--------- .../staging/android/ion/heaps/ion_page_pool.h | 26 ++++++++ 3 files changed, 59 insertions(+), 31 deletions(-) diff --git a/drivers/staging/android/ion/heaps/Kconfig b/drivers/staging/android/ion/heaps/Kconfig index 075a5f832a7e..88b7606bdfbe 100644 --- a/drivers/staging/android/ion/heaps/Kconfig +++ b/drivers/staging/android/ion/heaps/Kconfig @@ -69,7 +69,7 @@ config ION_DEFER_FREE_NO_SCHED_IDLE config ION_POOL_AUTO_REFILL bool "Refill the ION heap pools automatically" - depends on ION + depends on ION && QGKI help Choose this option to refill the ION system heap pools (non-secure) automatically when the pool pages count becomes lower than a set low mark. diff --git a/drivers/staging/android/ion/heaps/ion_page_pool.c b/drivers/staging/android/ion/heaps/ion_page_pool.c index b612fd75cad7..6035f8237427 100644 --- a/drivers/staging/android/ion/heaps/ion_page_pool.c +++ b/drivers/staging/android/ion/heaps/ion_page_pool.c @@ -13,6 +13,37 @@ #include "msm_ion_priv.h" #include "ion_page_pool.h" +static inline struct page *ion_page_pool_alloc_pages(struct ion_page_pool *pool) +{ + if (fatal_signal_pending(current)) + return NULL; + return alloc_pages(pool->gfp_mask, pool->order); +} + +static void ion_page_pool_free_pages(struct ion_page_pool *pool, + struct page *page) +{ + __free_pages(page, pool->order); +} + +static void ion_page_pool_add(struct ion_page_pool *pool, struct page *page) +{ + mutex_lock(&pool->mutex); + if (PageHighMem(page)) { + list_add_tail(&page->lru, &pool->high_items); + pool->high_count++; + } else { + list_add_tail(&page->lru, &pool->low_items); + pool->low_count++; + } + + atomic_inc(&pool->count); + mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, + (1 << (PAGE_SHIFT + pool->order))); + mutex_unlock(&pool->mutex); +} + +#ifdef CONFIG_ION_POOL_AUTO_REFILL /* do a simple check to see if we are in any low memory situation */ static bool pool_refill_ok(struct ion_page_pool *pool) { @@ -48,36 +79,6 @@ static bool pool_refill_ok(struct ion_page_pool *pool) return true; } -static inline struct page *ion_page_pool_alloc_pages(struct ion_page_pool *pool) -{ - if (fatal_signal_pending(current)) - return NULL; - return alloc_pages(pool->gfp_mask, pool->order); -} - -static void ion_page_pool_free_pages(struct ion_page_pool *pool, - struct page *page) -{ - __free_pages(page, pool->order); -} - -static void ion_page_pool_add(struct ion_page_pool *pool, struct page *page) -{ - mutex_lock(&pool->mutex); - if (PageHighMem(page)) { - list_add_tail(&page->lru, &pool->high_items); - pool->high_count++; - } else { - list_add_tail(&page->lru, &pool->low_items); - pool->low_count++; - } - - atomic_inc(&pool->count); - mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, - (1 << (PAGE_SHIFT + pool->order))); - mutex_unlock(&pool->mutex); -} - void ion_page_pool_refill(struct ion_page_pool *pool) { struct page *page; @@ -99,6 +100,7 @@ void ion_page_pool_refill(struct ion_page_pool *pool) ion_page_pool_add(pool, page); } } +#endif /* CONFIG_ION_PAGE_POOL_REFILL */ static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high) { diff --git a/drivers/staging/android/ion/heaps/ion_page_pool.h b/drivers/staging/android/ion/heaps/ion_page_pool.h index 646a5224532a..dfe3f8b59426 100644 --- a/drivers/staging/android/ion/heaps/ion_page_pool.h +++ b/drivers/staging/android/ion/heaps/ion_page_pool.h @@ -92,6 +92,7 @@ size_t ion_system_heap_secure_page_pool_total(struct ion_heap *heap, int vmid); int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, int nr_to_scan); +#ifdef CONFIG_ION_POOL_AUTO_REFILL void ion_page_pool_refill(struct ion_page_pool *pool); static __always_inline int get_pool_fillmark(struct ion_page_pool *pool) @@ -113,4 +114,29 @@ static __always_inline bool pool_fillmark_reached(struct ion_page_pool *pool) { return atomic_read(&pool->count) >= get_pool_fillmark(pool); } +#else +static inline void ion_page_pool_refill(struct ion_page_pool *pool) +{ +} + +static __always_inline int get_pool_fillmark(struct ion_page_pool *pool) +{ + return 0; +} + +static __always_inline int get_pool_lowmark(struct ion_page_pool *pool) +{ + return 0; +} + +static __always_inline bool pool_count_below_lowmark(struct ion_page_pool *pool) +{ + return false; +} + +static __always_inline bool pool_fillmark_reached(struct ion_page_pool *pool) +{ + return false; +} +#endif /* CONFIG_ION_POOL_AUTO_REFILL */ #endif /* _ION_PAGE_POOL_H */