--- zzzz-none-000/linux-4.1.38/mm/vmscan.c 2017-01-18 18:48:06.000000000 +0000 +++ bcm63-7582-715/linux-4.1.38/mm/vmscan.c 2020-11-25 10:06:48.000000000 +0000 @@ -3366,6 +3366,11 @@ }; const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); +#if defined(CONFIG_BCM_KF_VMSCAN_OPT) + /* Lower the priority to prevent lock up when running low on memory */ + set_user_nice(current, 10); +#endif + lockdep_set_current_reclaim_state(GFP_KERNEL); if (!cpumask_empty(cpumask)) @@ -3460,6 +3465,17 @@ if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL)) return; + +#if defined(CONFIG_BCM_KF_VMSCAN_OPT) + /* Cap the order at 128k blocks to relax fragmentation standard, so kswapd won't be + * running constantly without much progress in our small swapless system. Big blocks + * should be allocated with vmalloc or kmalloc at boot time for our system + */ + if (order > 5) { + order = 5; + } +#endif + pgdat = zone->zone_pgdat; if (pgdat->kswapd_max_order < order) { pgdat->kswapd_max_order = order; @@ -3607,7 +3623,15 @@ * of a node considered for each zone_reclaim. 4 scans 1/16th of * a zone. */ + +#if defined(CONFIG_BCM_KF_VMSCAN_OPT) +/* Start from a higher priority (lower value) for more optimized memory + * scanning, see DEF_PRIORITY + */ +#define ZONE_RECLAIM_PRIORITY 2 +#else #define ZONE_RECLAIM_PRIORITY 4 +#endif /* * Percentage of pages in a zone that must be unmapped for zone_reclaim to