#define RESTRIC_ANON 0
#define ANON_RATIO 60
+bool cma_first_wm_low __read_mostly;
bool can_use_cma(gfp_t gfp_flags)
{
unsigned long anon_cma;
#endif /* RESTRIC_ANON */
+ if (unlikely(!cma_first_wm_low))
+ return false;
+
if (cma_forbidden_mask(gfp_flags))
return false;
void show_page(struct page *page)
{
unsigned long trace = 0;
+ unsigned long map_flag = -1UL;
if (!page)
return;
#ifdef CONFIG_AMLOGIC_PAGE_TRACE
trace = get_page_trace(page);
#endif
- pr_info("page:%lx, map:%p, f:%lx, m:%d, c:%d, f:%pf\n",
- page_to_pfn(page), page->mapping,
+ if (page->mapping && !((unsigned long)page->mapping & 0x3))
+ map_flag = page->mapping->flags;
+ pr_info("page:%lx, map:%p, mf:%lx, pf:%lx, m:%d, c:%d, f:%pf\n",
+ page_to_pfn(page), page->mapping, map_flag,
page->flags & 0xffffffff,
page_mapcount(page), page_count(page),
(void *)trace);
extern unsigned long get_cma_allocated(void);
extern unsigned long get_total_cmapages(void);
extern spinlock_t cma_iso_lock;
+extern bool cma_first_wm_low;
extern int cma_debug_level;
extern int aml_cma_alloc_range(unsigned long start, unsigned long end);
int ret;
#ifdef CONFIG_AMLOGIC_CMA
int dummy;
+ unsigned long long tick;
#endif /* CONFIG_AMLOGIC_CMA */
if (!cma || !cma->count)
count, align);
#ifdef CONFIG_AMLOGIC_CMA
+ tick = sched_clock();
cma_debug(0, NULL, "(cma %p, count %zu, align %d)\n",
(void *)cma, count, align);
#endif
#ifdef CONFIG_AMLOGIC_CMA
aml_cma_alloc_post_hook(&dummy, count, page);
- cma_debug(0, NULL, "return %p\n", page);
+ cma_debug(0, NULL, "return page:%lx, tick:%lld\n",
+ page ? page_to_pfn(page) : 0, sched_clock() - tick);
#endif /* CONFIG_AMLOGIC_CMA */
pr_debug("%s(): returned %p\n", __func__, page);
return page;
radix_tree_deref_slot_protected(pslot, &mapping->tree_lock) != page) {
spin_unlock_irq(&mapping->tree_lock);
#ifdef CONFIG_AMLOGIC_CMA
- cma_debug(2, page, " anon page cnt miss match, e:%d, p:%d\n",
+ cma_debug(2, page, " file page cnt miss match, e:%d, p:%d\n",
expected_count, page_has_private(page));
#endif
return -EAGAIN;
* are not met, then a high-order request also cannot go ahead
* even if a suitable page happened to be free.
*/
+#ifdef CONFIG_AMLOGIC_CMA
+ if (free_pages <= min + z->lowmem_reserve[classzone_idx]) {
+ /* do not using cma until water mark is low */
+ if (unlikely(!cma_first_wm_low && free_pages > 0)) {
+ cma_first_wm_low = true;
+ pr_info("Now can use cma, free:%ld, wm:%ld\n",
+ free_pages,
+ min + z->lowmem_reserve[classzone_idx]);
+ }
+ return false;
+ }
+#else
if (free_pages <= min + z->lowmem_reserve[classzone_idx])
return false;
+#endif
/* If this is an order-0 request then the watermark is fine */
if (!order)
if (!PageActive(page) && page_mapcount(page) >= INACTIVE_MIGRATE)
return 1;
+ if (PageUnevictable(page))
+ return 0;
+
return 0;
}
#endif