/* Update task's mems_allowed and rebind its mempolicy and vmas' mempolicy of it to cpuset's new mems_allowed, and migrate pages to new nodes if memory_migrate flag is set. Called with cgroup_mutex held.  */
static void cpuset_change_nodemask(struct task_struct *p, struct cgroup_scanner *scan)
/* Update task's mems_allowed and rebind its mempolicy and vmas' mempolicy of it to cpuset's new mems_allowed, and migrate pages to new nodes if memory_migrate flag is set. Called with cgroup_mutex held.  */
static void cpuset_change_nodemask(struct task_struct *p, struct cgroup_scanner *scan)
{
	struct mm_struct *mm;
	struct cpuset *cs;
	int migrate;
	const nodemask_t *oldmem = scan->data;
	nodemask_t newmems;
	cs = cgroup_cs(scan->cg);
	guarantee_online_mems(cs, &newmems);
	task_lock(p);
	cpuset_change_task_nodemask(p, &newmems);
	task_unlock(p);
	mm = get_task_mm(p);
	if (!mm)
		return;
	migrate = is_memory_migrate(cs);
	mpol_rebind_mm(mm, &cs->mems_allowed);
	if (migrate)
		cpuset_migrate_mm(mm, oldmem, &cs->mems_allowed);
	mmput(mm);
}