Re: [PATCH] cgroup: freezer: don't change task and cgroups status unnecessarily

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/21, Honglei Wang wrote:
>
> @@ -230,6 +230,15 @@ void cgroup_freezer_migrate_task(struct task_struct *task,
> +	/*
> +	 * It's not necessary to do changes if both of the src and dst cgroups
> +	 * are not freeze and task is not frozen.
> +	 */
> +	if (!test_bit(CGRP_FREEZE, &src->flags) &&
> +	    !test_bit(CGRP_FREEZE, &dst->flags) &&
> +	    !task->frozen)
> +		return;
> +

If we want to optimize cgroup_freezer_migrate_task()... I am sure I missed
something, but can't we do better ?

If a frozen task enters or leaves cgrp, this should never change the state
of FROZEN bit?

Oleg.

--- x/kernel/cgroup/freezer.c
+++ x/kernel/cgroup/freezer.c
@@ -238,14 +238,14 @@ void cgroup_freezer_migrate_task(struct
 	if (task->frozen) {
 		cgroup_inc_frozen_cnt(dst);
 		cgroup_dec_frozen_cnt(src);
+	} else {
+		if (test_bit(CGRP_FREEZE, &src->flags))
+			cgroup_update_frozen(src);
+		if (test_bit(CGRP_FREEZE, &dst->flags)) {
+			cgroup_update_frozen(dst);
+			cgroup_freeze_task(task, true);
+		}
 	}
-	cgroup_update_frozen(dst);
-	cgroup_update_frozen(src);
-
-	/*
-	 * Force the task to the desired state.
-	 */
-	cgroup_freeze_task(task, test_bit(CGRP_FREEZE, &dst->flags));
 }
 
 void cgroup_freeze(struct cgroup *cgrp, bool freeze)





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux