@@ -290,6 +290,7 @@ static int ksm_nr_node_ids = 1;
#define KSM_RUN_MERGE 1
#define KSM_RUN_UNMERGE 2
#define KSM_RUN_OFFLINE 4
+#define KSM_RUN_AUTO 8
static unsigned long ksm_run = KSM_RUN_STOP;
static void wait_while_offlining(void);
@@ -2416,7 +2417,9 @@ static void ksm_do_scan(unsigned int scan_npages)
static int ksmd_should_run(void)
{
- return (ksm_run & KSM_RUN_MERGE) && !list_empty(&ksm_mm_head.mm_list);
+ if (!list_empty(&ksm_mm_head.mm_list))
+ return ksm_run & KSM_RUN_AUTO || ksm_run & KSM_RUN_MERGE;
+ return 0;
}
static int ksm_scan_thread(void *nothing)
@@ -2916,7 +2919,7 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
err = kstrtouint(buf, 10, &flags);
if (err)
return -EINVAL;
- if (flags > KSM_RUN_UNMERGE)
+ if (flags > KSM_RUN_UNMERGE && flags != KSM_RUN_AUTO)
return -EINVAL;
/*
@@ -2942,7 +2945,7 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
}
mutex_unlock(&ksm_thread_mutex);
- if (flags & KSM_RUN_MERGE)
+ if (flags & KSM_RUN_MERGE || flags & KSM_RUN_AUTO)
wake_up_interruptible(&ksm_thread_wait);
return count;