#include <linux/page-isolation.h>
#include "internal.h"
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
#ifdef CONFIG_COMPACTION
static inline void count_compact_event(enum vm_event_item item)
{
if (is_migrate_isolate(migratetype))
return false;
+ if (is_migrate_mtkpasr(migratetype))
+ return false;
+
/* If the page is a large free page, then allow migration */
if (PageBuddy(page) && page_order(page) >= pageblock_order)
return true;
#endif /* CONFIG_SYSFS && CONFIG_NUMA */
#endif /* CONFIG_COMPACTION */
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+extern void drop_pagecache(void);
+//extern void kick_lmk_from_compaction(gfp_t);
+static void kick_compaction_early_suspend(struct early_suspend *h)
+{
+ struct zone *z = &NODE_DATA(0)->node_zones[ZONE_NORMAL];
+ int status;
+ int retry = 3;
+ int safe_order = THREAD_SIZE_ORDER + 1;
+ bool contended;
+ gfp_t gfp_mask = GFP_KERNEL;
+
+ /* Check whether gfp is restricted. */
+ if (gfp_mask != (gfp_mask & gfp_allowed_mask)) {
+ printk("XXXXXX GFP is restricted! XXXXXX\n");
+ return;
+ }
+
+ /* We try retry times at most. */
+ while (retry > 0) {
+ /* If it is safe under low watermark, then break. */
+ if (zone_watermark_ok(z, safe_order, low_wmark_pages(z), 0, 0))
+ break;
+ status = compact_zone_order(z, safe_order, gfp_mask, true, &contended);
+ --retry;
+ }
+}
+
+static void kick_compaction_late_resume(struct early_suspend *h)
+{
+ /* Do nothing */
+}
+
+static struct early_suspend kick_compaction_early_suspend_desc = {
+ .level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1,
+ .suspend = kick_compaction_early_suspend,
+ .resume = kick_compaction_late_resume,
+};
+
+static int __init compaction_init(void)
+{
+ printk("@@@@@@ [%s] Register early suspend callback @@@@@@\n",__FUNCTION__);
+ register_early_suspend(&kick_compaction_early_suspend_desc);
+ return 0;
+}
+static void __exit compaction_exit(void)
+{
+ printk("@@@@@@ [%s] Unregister early suspend callback @@@@@@\n",__FUNCTION__);
+ unregister_early_suspend(&kick_compaction_early_suspend_desc);
+}
+
+module_init(compaction_init);
+module_exit(compaction_exit);
+#endif