Commit 48f07456 authored by Miaohe Lin's avatar Miaohe Lin Committed by Tejun Heo
Browse files

cgroup/cpuset: avoid unneeded cpuset_mutex re-lock



cpuset_mutex unlock and lock pair is only needed when transferring tasks
out of empty cpuset. Avoid unneeded cpuset_mutex re-lock when !is_empty
to save cpu cycles.

Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Reviewed-by: default avatarWaiman Long <longman@redhat.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent a453be97
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -3521,18 +3521,17 @@ hotplug_update_tasks_legacy(struct cpuset *cs,
	is_empty = cpumask_empty(cs->cpus_allowed) ||
		   nodes_empty(cs->mems_allowed);

	mutex_unlock(&cpuset_mutex);

	/*
	 * Move tasks to the nearest ancestor with execution resources,
	 * This is full cgroup operation which will also call back into
	 * cpuset. Should be done outside any lock.
	 */
	if (is_empty)
	if (is_empty) {
		mutex_unlock(&cpuset_mutex);
		remove_tasks_in_empty_cpuset(cs);

		mutex_lock(&cpuset_mutex);
	}
}

static void
hotplug_update_tasks(struct cpuset *cs,