From: "haifeng.xu" <haifeng.xu@shopee.com> To: tj@kernel.org Cc: lizefan.x@bytedance.com, hannes@cmpxchg.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, "haifeng.xu" <haifeng.xu@shopee.com> Subject: [PATCH] cgroup: Simplify code in css_set_move_task Date: Thu, 20 Oct 2022 07:47:01 +0000 [thread overview] Message-ID: <20221020074701.84326-1-haifeng.xu@shopee.com> (raw) Check the populated state of css_set in css_set_update_populated and update the populated state of to_cset after from_cset is updated. Signed-off-by: haifeng.xu <haifeng.xu@shopee.com> --- kernel/cgroup/cgroup.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index d922773fa90b..6c474be57f91 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -861,7 +861,8 @@ static void css_set_update_populated(struct css_set *cset, bool populated) { struct cgrp_cset_link *link; - lockdep_assert_held(&css_set_lock); + if (!cset || css_set_populated(cset)) + return; list_for_each_entry(link, &cset->cgrp_links, cgrp_link) cgroup_update_populated(link->cgrp, populated); @@ -903,16 +904,12 @@ static void css_set_move_task(struct task_struct *task, { lockdep_assert_held(&css_set_lock); - if (to_cset && !css_set_populated(to_cset)) - css_set_update_populated(to_cset, true); - if (from_cset) { WARN_ON_ONCE(list_empty(&task->cg_list)); css_set_skip_task_iters(from_cset, task); list_del_init(&task->cg_list); - if (!css_set_populated(from_cset)) - css_set_update_populated(from_cset, false); + css_set_update_populated(from_cset, false); } else { WARN_ON_ONCE(!list_empty(&task->cg_list)); } @@ -926,6 +923,7 @@ static void css_set_move_task(struct task_struct *task, WARN_ON_ONCE(task->flags & PF_EXITING); cgroup_move_task(task, to_cset); + css_set_update_populated(to_cset, true); list_add_tail(&task->cg_list, use_mg_tasks ? &to_cset->mg_tasks : &to_cset->tasks); } -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: "haifeng.xu" <haifeng.xu-LL2PKPoSiP3QT0dZR+AlfA@public.gmane.org> To: tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org Cc: lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org, hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "haifeng.xu" <haifeng.xu-LL2PKPoSiP3QT0dZR+AlfA@public.gmane.org> Subject: [PATCH] cgroup: Simplify code in css_set_move_task Date: Thu, 20 Oct 2022 07:47:01 +0000 [thread overview] Message-ID: <20221020074701.84326-1-haifeng.xu@shopee.com> (raw) Check the populated state of css_set in css_set_update_populated and update the populated state of to_cset after from_cset is updated. Signed-off-by: haifeng.xu <haifeng.xu-LL2PKPoSiP3QT0dZR+AlfA@public.gmane.org> --- kernel/cgroup/cgroup.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index d922773fa90b..6c474be57f91 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -861,7 +861,8 @@ static void css_set_update_populated(struct css_set *cset, bool populated) { struct cgrp_cset_link *link; - lockdep_assert_held(&css_set_lock); + if (!cset || css_set_populated(cset)) + return; list_for_each_entry(link, &cset->cgrp_links, cgrp_link) cgroup_update_populated(link->cgrp, populated); @@ -903,16 +904,12 @@ static void css_set_move_task(struct task_struct *task, { lockdep_assert_held(&css_set_lock); - if (to_cset && !css_set_populated(to_cset)) - css_set_update_populated(to_cset, true); - if (from_cset) { WARN_ON_ONCE(list_empty(&task->cg_list)); css_set_skip_task_iters(from_cset, task); list_del_init(&task->cg_list); - if (!css_set_populated(from_cset)) - css_set_update_populated(from_cset, false); + css_set_update_populated(from_cset, false); } else { WARN_ON_ONCE(!list_empty(&task->cg_list)); } @@ -926,6 +923,7 @@ static void css_set_move_task(struct task_struct *task, WARN_ON_ONCE(task->flags & PF_EXITING); cgroup_move_task(task, to_cset); + css_set_update_populated(to_cset, true); list_add_tail(&task->cg_list, use_mg_tasks ? &to_cset->mg_tasks : &to_cset->tasks); } -- 2.25.1
next reply other threads:[~2022-10-20 7:47 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-20 7:47 haifeng.xu [this message] 2022-10-20 7:47 ` [PATCH] cgroup: Simplify code in css_set_move_task haifeng.xu 2022-10-27 8:05 ` Michal Koutný 2022-10-27 8:05 ` Michal Koutný 2022-10-28 11:29 ` Haifeng Xu 2022-10-28 11:29 ` Haifeng Xu 2022-10-31 13:11 ` Michal Koutný 2022-10-31 13:11 ` Michal Koutný 2022-11-03 2:13 ` Haifeng Xu 2022-11-03 2:13 ` Haifeng Xu 2022-11-03 2:31 ` Tejun Heo 2022-11-03 2:31 ` Tejun Heo 2022-11-03 14:55 ` Haifeng Xu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221020074701.84326-1-haifeng.xu@shopee.com \ --to=haifeng.xu@shopee.com \ --cc=cgroups@vger.kernel.org \ --cc=hannes@cmpxchg.org \ --cc=linux-kernel@vger.kernel.org \ --cc=lizefan.x@bytedance.com \ --cc=tj@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.