mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
vmscan: kswapd carefully call compaction
With CONFIG_COMPACTION enabled, kswapd does not try to free contiguous free pages, even when it is woken for a higher order request. This could be bad for eg. jumbo frame network allocations, which are done from interrupt context and cannot compact memory themselves. Higher than before allocation failure rates in the network receive path have been observed in kernels with compaction enabled. Teach kswapd to defragment the memory zones in a node, but only if required and compaction is not deferred in a zone. [[email protected]: reduce scope of zones_need_compaction] Signed-off-by: Rik van Riel <[email protected]> Acked-by: Mel Gorman <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Minchan Kim <[email protected]> Cc: KOSAKI Motohiro <[email protected]> Cc: Hillf Danton <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
fe2c2a1066
commit
7be62de99a
3 changed files with 51 additions and 18 deletions
|
|
@ -675,44 +675,61 @@ unsigned long try_to_compact_pages(struct zonelist *zonelist,
|
|||
|
||||
|
||||
/* Compact all zones within a node */
|
||||
static int compact_node(int nid)
|
||||
static int __compact_pgdat(pg_data_t *pgdat, struct compact_control *cc)
|
||||
{
|
||||
int zoneid;
|
||||
pg_data_t *pgdat;
|
||||
struct zone *zone;
|
||||
|
||||
if (nid < 0 || nid >= nr_node_ids || !node_online(nid))
|
||||
return -EINVAL;
|
||||
pgdat = NODE_DATA(nid);
|
||||
|
||||
/* Flush pending updates to the LRU lists */
|
||||
lru_add_drain_all();
|
||||
|
||||
for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
|
||||
struct compact_control cc = {
|
||||
.nr_freepages = 0,
|
||||
.nr_migratepages = 0,
|
||||
.order = -1,
|
||||
.sync = true,
|
||||
};
|
||||
|
||||
zone = &pgdat->node_zones[zoneid];
|
||||
if (!populated_zone(zone))
|
||||
continue;
|
||||
|
||||
cc.zone = zone;
|
||||
INIT_LIST_HEAD(&cc.freepages);
|
||||
INIT_LIST_HEAD(&cc.migratepages);
|
||||
cc->nr_freepages = 0;
|
||||
cc->nr_migratepages = 0;
|
||||
cc->zone = zone;
|
||||
INIT_LIST_HEAD(&cc->freepages);
|
||||
INIT_LIST_HEAD(&cc->migratepages);
|
||||
|
||||
compact_zone(zone, &cc);
|
||||
if (cc->order < 0 || !compaction_deferred(zone))
|
||||
compact_zone(zone, cc);
|
||||
|
||||
VM_BUG_ON(!list_empty(&cc.freepages));
|
||||
VM_BUG_ON(!list_empty(&cc.migratepages));
|
||||
VM_BUG_ON(!list_empty(&cc->freepages));
|
||||
VM_BUG_ON(!list_empty(&cc->migratepages));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int compact_pgdat(pg_data_t *pgdat, int order)
|
||||
{
|
||||
struct compact_control cc = {
|
||||
.order = order,
|
||||
.sync = false,
|
||||
};
|
||||
|
||||
return __compact_pgdat(pgdat, &cc);
|
||||
}
|
||||
|
||||
static int compact_node(int nid)
|
||||
{
|
||||
pg_data_t *pgdat;
|
||||
struct compact_control cc = {
|
||||
.order = -1,
|
||||
.sync = true,
|
||||
};
|
||||
|
||||
if (nid < 0 || nid >= nr_node_ids || !node_online(nid))
|
||||
return -EINVAL;
|
||||
pgdat = NODE_DATA(nid);
|
||||
|
||||
return __compact_pgdat(pgdat, &cc);
|
||||
}
|
||||
|
||||
/* Compact all nodes in the system */
|
||||
static int compact_nodes(void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue