Skip to content

Commit

Permalink
mm: compaction: do suspend compaction in workqueue
Browse files Browse the repository at this point in the history
Move compact_nodes_suspend out of the direct early suspend workqueue
to avoid long delays in the suspend path on a heavily loaded system;
examples being heavily use of filesystem contending with the pages
that are trying to be compacted.

Signed-off-by: Yuan Jiangli <[email protected]>
Reviewed-on: http://gerrit.pcs.mot.com/535748
SLT-Approved: Slta Waiver <[email protected]>
Tested-by: Jira Key <[email protected]>
Reviewed-by: Christopher Fries <[email protected]>
Reviewed-by: Igor Kovalenko <[email protected]>
Reviewed-by: Klocwork kwcheck <[email protected]>
Submit-Approved: Jira Key <[email protected]>
Reviewed-by: Check Patch <[email protected]>

(cherry-pick from commit  6e202c2572708430f682987b2240eae50dadb1e3)

Change-Id: Ifcf8e0ff8f60d3c7f099d95653a43ba9651eeb28
Reviewed-on: http://gerrit.pcs.mot.com/540977
SLT-Approved: Slta Waiver <[email protected]>
Tested-by: Jira Key <[email protected]>
Reviewed-by: Yi-Wei Zhao <[email protected]>
Submit-Approved: Jira Key <[email protected]>
  • Loading branch information
Yuan Jiangli authored and Yinjun Chen committed Apr 30, 2014
1 parent a6f2ec2 commit f4af75a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mm/compaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,9 @@ unsigned long try_to_compact_pages(struct zonelist *zonelist,
}

#ifdef CONFIG_HAS_EARLYSUSPEND
static struct work_struct compactnodes_w;
static int compact_nodes(void);
static void compact_nodes_suspend(struct early_suspend *s)
static void compactnodes_work(struct work_struct *w)
{
/* No point in being gun shy here since compact_zone()
* will check suitability of compaction run per zone.
Expand All @@ -1080,6 +1081,13 @@ static void compact_nodes_suspend(struct early_suspend *s)
* screen is off so there's no perceived user impact.
*/
compact_nodes();

}


static void compact_nodes_suspend(struct early_suspend *s)
{
schedule_work(&compactnodes_w);
}

static struct early_suspend early_suspend_compaction_desc = {
Expand Down Expand Up @@ -1212,6 +1220,7 @@ void compaction_unregister_node(struct node *node)
#ifdef CONFIG_HAS_EARLYSUSPEND
static int __init mem_compaction_init(void)
{
INIT_WORK(&compactnodes_w, compactnodes_work);
register_early_suspend(&early_suspend_compaction_desc);
return 0;
}
Expand Down

0 comments on commit f4af75a

Please sign in to comment.