Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 292624
b: refs/heads/master
c: 7be62de
h: refs/heads/master
v: v3
  • Loading branch information
Rik van Riel authored and Linus Torvalds committed Mar 22, 2012
1 parent 04ea745 commit d37509d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fe2c2a106663130a5ab45cb0e3414b52df2fff0c
refs/heads/master: 7be62de99adcab4449d416977b4274985c5fe023
6 changes: 6 additions & 0 deletions trunk/include/linux/compaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern int fragmentation_index(struct zone *zone, unsigned int order);
extern unsigned long try_to_compact_pages(struct zonelist *zonelist,
int order, gfp_t gfp_mask, nodemask_t *mask,
bool sync);
extern int compact_pgdat(pg_data_t *pgdat, int order);
extern unsigned long compaction_suitable(struct zone *zone, int order);

/* Do not skip compaction more than 64 times */
Expand Down Expand Up @@ -62,6 +63,11 @@ static inline unsigned long try_to_compact_pages(struct zonelist *zonelist,
return COMPACT_CONTINUE;
}

static inline int compact_pgdat(pg_data_t *pgdat, int order)
{
return COMPACT_CONTINUE;
}

static inline unsigned long compaction_suitable(struct zone *zone, int order)
{
return COMPACT_SKIPPED;
Expand Down
53 changes: 35 additions & 18 deletions trunk/mm/compaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 10 additions & 0 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2919,6 +2919,8 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,
* and it is potentially going to sleep here.
*/
if (order) {
int zones_need_compaction = 1;

for (i = 0; i <= end_zone; i++) {
struct zone *zone = pgdat->node_zones + i;

Expand All @@ -2939,9 +2941,17 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,
goto loop_again;
}

/* Check if the memory needs to be defragmented. */
if (zone_watermark_ok(zone, order,
low_wmark_pages(zone), *classzone_idx, 0))
zones_need_compaction = 0;

/* If balanced, clear the congested flag */
zone_clear_flag(zone, ZONE_CONGESTED);
}

if (zones_need_compaction)
compact_pgdat(pgdat, order);
}

/*
Expand Down

0 comments on commit d37509d

Please sign in to comment.