linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cgroup: simplify code for cgroup_subtree_control_write()
@ 2019-07-08 13:01 Peng Wang
  2019-07-08 14:41 ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Wang @ 2019-07-08 13:01 UTC (permalink / raw)
  To: tj, lizefan, hannes; +Cc: cgroups, linux-kernel, Peng Wang

Process "enable" and "disable" earlier to simplify code.

Signed-off-by: Peng Wang <rocking@whu.edu.cn>
---
 kernel/cgroup/cgroup.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index bf9dbffd46b1..e49b8bde5c99 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -3269,23 +3269,21 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of,
 	if (!cgrp)
 		return -ENODEV;
 
+	enable &= ~(cgrp->subtree_control);
+	disable &= cgrp->subtree_control;
+
+	if (!enable && !disable) {
+		ret = 0;
+		goto out_unlock;
+	}
+
 	for_each_subsys(ss, ssid) {
 		if (enable & (1 << ssid)) {
-			if (cgrp->subtree_control & (1 << ssid)) {
-				enable &= ~(1 << ssid);
-				continue;
-			}
-
 			if (!(cgroup_control(cgrp) & (1 << ssid))) {
 				ret = -ENOENT;
 				goto out_unlock;
 			}
 		} else if (disable & (1 << ssid)) {
-			if (!(cgrp->subtree_control & (1 << ssid))) {
-				disable &= ~(1 << ssid);
-				continue;
-			}
-
 			/* a child has it enabled? */
 			cgroup_for_each_live_child(child, cgrp) {
 				if (child->subtree_control & (1 << ssid)) {
@@ -3296,11 +3294,6 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of,
 		}
 	}
 
-	if (!enable && !disable) {
-		ret = 0;
-		goto out_unlock;
-	}
-
 	ret = cgroup_vet_subtree_control_enable(cgrp, enable);
 	if (ret)
 		goto out_unlock;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cgroup: simplify code for cgroup_subtree_control_write()
  2019-07-08 13:01 [PATCH] cgroup: simplify code for cgroup_subtree_control_write() Peng Wang
@ 2019-07-08 14:41 ` Tejun Heo
  2019-07-09  1:55   ` Peng Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2019-07-08 14:41 UTC (permalink / raw)
  To: Peng Wang; +Cc: lizefan, hannes, cgroups, linux-kernel

On Mon, Jul 08, 2019 at 09:01:32PM +0800, Peng Wang wrote:
> Process "enable" and "disable" earlier to simplify code.

I don't think this is correct and even if it were the value of this
change is close to none, so nack on this one.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] cgroup: simplify code for cgroup_subtree_control_write()
  2019-07-08 14:41 ` Tejun Heo
@ 2019-07-09  1:55   ` Peng Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Peng Wang @ 2019-07-09  1:55 UTC (permalink / raw)
  To: 'Tejun Heo'; +Cc: lizefan, hannes, cgroups, linux-kernel

On Monday, July 8, 2019 10:41 PM, Tejun Heo wrote:
> On Mon, Jul 08, 2019 at 09:01:32PM +0800, Peng Wang wrote:
> > Process "enable" and "disable" earlier to simplify code.
> 
> I don't think this is correct and even if it were the value of this
> change is close to none, so nack on this one.

OK. 
Although I have tested this patch for common case, It's just somewhat trivial.

Thanks for your time :-).

> 
> Thanks.
> 
> --
> tejun


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-09  1:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 13:01 [PATCH] cgroup: simplify code for cgroup_subtree_control_write() Peng Wang
2019-07-08 14:41 ` Tejun Heo
2019-07-09  1:55   ` Peng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).