int alloc_type;
int do_retry;
+#if defined(CONFIG_MIPS_BRCM)
+ int nretry;
+ int tpages = 0;
+#endif
+
might_sleep_if(wait);
zones = zonelist->zones; /* the list of zones suitable for gfp_mask */
goto got_pg;
}
}
+#if defined(CONFIG_MIPS_BRCM)
+ tpages += z->nr_active + z->nr_inactive;
+#endif
}
/* here we're in the low on memory slow path */
+#if defined(CONFIG_MIPS_BRCM)
+ nretry = tpages/SWAP_CLUSTER_MAX;
+ //printk("============to rebalance, tpages %d nretry %d ", tpages, nretry);
+#endif
+
rebalance:
if ((p->flags & (PF_MEMALLOC | PF_MEMDIE)) && !in_interrupt()) {
/* go through the zonelist yet again, ignoring mins */
}
}
}
-
+#if defined(CONFIG_MIPS_BRCM)
+ /*
+ * For embedded system, we have small memory and we assume well-behaved software
+ * Let it scan all pages if necessary
+ * This is similar to including __GFP_NOFAIL/__GFP_REPEAT by default, except we use nretry as a safety mechanism
+ */
+ do_retry = 0;
+ if (!(gfp_mask & __GFP_NORETRY)) {
+ if ((gfp_mask & __GFP_NOFAIL) || (gfp_mask & __GFP_REPEAT)) {
+ do_retry = 1;
+ }
+ else if (nretry > 0) {
+ do_retry = 1;
+ nretry--;
+ }
+ }
+ //printk(".");
+#else
/*
* Don't let big-order allocations loop unless the caller explicitly
* requests that. Wait for some write requests to complete then retry.
if (gfp_mask & __GFP_NOFAIL)
do_retry = 1;
}
+#endif
+
if (do_retry) {
blk_congestion_wait(WRITE, HZ/50);
goto rebalance;
for_each_zone(zone) {
spin_lock_irqsave(&zone->lru_lock, flags);
+#if !defined(CONFIG_MIPS_BRCM)
if (is_highmem(zone)) {
/*
* Often, highmem doesn't need to reserve any pages.
zone->pages_min = (pages_min * zone->present_pages) /
lowmem_pages;
}
-
zone->pages_low = zone->pages_min * 2;
zone->pages_high = zone->pages_min * 3;
+#else
+ /* Tuned watermarks for better out of memory performance on our swapless system */
+ /* As we don't have a disc to swap out dirty pages, there is not much we can do if memory is really low */
+ /* We want to lower watermarks to prevent excessive scanning, which could slow down or lock up the system */
+ zone->pages_min = 0; /* this is actually not used elsewhere except for calculating the other two */
+ zone->pages_low = 48;
+ zone->pages_high = 50;
+#endif
+
spin_unlock_irqrestore(&zone->lru_lock, flags);
}
}