From 0c803ec17b56a9235eb150f7cad930de56e21c90 Mon Sep 17 00:00:00 2001 From: Charan Teja Reddy Date: Fri, 29 Jan 2021 15:47:10 +0530 Subject: [PATCH] soc: qcom: memoffline: use a freezable unbounded workqueue for migration Use freezable unbounded workqueue for reverse migration of the pages in the system. This helps in avoiding the watchdog timeouts while executing the suspend2idle usecases which expectation is to finish in 14secs. Also, add the support to know if there are any pending requests for reverse migration to take better decissions from userspace. Change-Id: Iada770799936c4d6110310e48f96a6f1dc4725cf Signed-off-by: Charan Teja Reddy --- drivers/soc/qcom/mem-offline.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/mem-offline.c b/drivers/soc/qcom/mem-offline.c index 9ce89e6fa54a..a719ba899641 100644 --- a/drivers/soc/qcom/mem-offline.c +++ b/drivers/soc/qcom/mem-offline.c @@ -48,6 +48,7 @@ static u32 offline_granule; static bool is_rpm_controller; static bool has_pend_offline_req; static atomic_long_t totalram_pages_with_offline = ATOMIC_INIT(0); +static struct workqueue_struct *migrate_wq; #define MODULE_CLASS_NAME "mem-offline" #define MIGRATE_TIMEOUT_SEC (20) @@ -970,6 +971,13 @@ static ssize_t show_mem_stats(struct kobject *kobj, static struct kobj_attribute stats_attr = __ATTR(stats, 0444, show_mem_stats, NULL); +static ssize_t show_anon_migrate(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return scnprintf(buf, PAGE_SIZE, "%lu\n", + atomic_read(&target_migrate_pages)); +} + static ssize_t store_anon_migrate(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t size) @@ -983,7 +991,7 @@ static ssize_t store_anon_migrate(struct kobject *kobj, atomic_add(val, &target_migrate_pages); if (!work_pending(&fill_movable_zone_work)) - queue_work(system_unbound_wq, &fill_movable_zone_work); + queue_work(migrate_wq, &fill_movable_zone_work); return size; } @@ -992,7 +1000,7 @@ static struct kobj_attribute offline_granule_attr = __ATTR(offline_granule, 0444, show_mem_offline_granule, NULL); static struct kobj_attribute anon_migration_size_attr = - __ATTR(anon_migrate, 0220, NULL, store_anon_migrate); + __ATTR(anon_migrate, 0644, show_anon_migrate, store_anon_migrate); static struct attribute *mem_root_attrs[] = { &stats_attr.attr, @@ -1123,6 +1131,14 @@ static int mem_offline_driver_probe(struct platform_device *pdev) if (bypass_send_msg) pr_info("mem-offline: bypass mode\n"); + migrate_wq = alloc_workqueue("reverse_migrate_wq", + WQ_UNBOUND | WQ_FREEZABLE, 0); + if (!migrate_wq) { + pr_err("Failed to create the worker for reverse migration\n"); + ret = -ENOMEM; + goto err_sysfs_remove_group; + } + return 0; err_sysfs_remove_group: