From: Waiman Long <longman@redhat.com>
To: Xiu Jianfeng <xiujianfeng@huaweicloud.com>,
tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org,
mkoutny@suse.com
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
xiujianfeng@huawei.com
Subject: Re: [PATCH v2 -next] cgroup/pids: Remove unreachable paths of pids_{can,cancel}_fork
Date: Sun, 4 Aug 2024 21:23:16 -0400 [thread overview]
Message-ID: <e8186bf5-51ed-453f-8ba2-350735a2b058@redhat.com> (raw)
In-Reply-To: <20240805004304.57314-1-xiujianfeng@huaweicloud.com>
On 8/4/24 20:43, Xiu Jianfeng wrote:
> From: Xiu Jianfeng <xiujianfeng@huawei.com>
>
> According to the implementation of cgroup_css_set_fork(), it will fail
> if cset cannot be found and the can_fork/cancel_fork methods will not
> be called in this case, which means that the argument 'cset' for these
> methods must not be NULL, so remove the unrechable paths in them.
>
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> ---
> v2: reword the commit message
> ---
> kernel/cgroup/pids.c | 14 ++------------
> 1 file changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/kernel/cgroup/pids.c b/kernel/cgroup/pids.c
> index 34aa63d7c9c6..8f61114c36dd 100644
> --- a/kernel/cgroup/pids.c
> +++ b/kernel/cgroup/pids.c
> @@ -272,15 +272,10 @@ static void pids_event(struct pids_cgroup *pids_forking,
> */
> static int pids_can_fork(struct task_struct *task, struct css_set *cset)
> {
> - struct cgroup_subsys_state *css;
> struct pids_cgroup *pids, *pids_over_limit;
> int err;
>
> - if (cset)
> - css = cset->subsys[pids_cgrp_id];
> - else
> - css = task_css_check(current, pids_cgrp_id, true);
> - pids = css_pids(css);
> + pids = css_pids(cset->subsys[pids_cgrp_id]);
> err = pids_try_charge(pids, 1, &pids_over_limit);
> if (err)
> pids_event(pids, pids_over_limit);
> @@ -290,14 +285,9 @@ static int pids_can_fork(struct task_struct *task, struct css_set *cset)
>
> static void pids_cancel_fork(struct task_struct *task, struct css_set *cset)
> {
> - struct cgroup_subsys_state *css;
> struct pids_cgroup *pids;
>
> - if (cset)
> - css = cset->subsys[pids_cgrp_id];
> - else
> - css = task_css_check(current, pids_cgrp_id, true);
> - pids = css_pids(css);
> + pids = css_pids(cset->subsys[pids_cgrp_id]);
> pids_uncharge(pids, 1);
> }
>
Reviewed-by: Waiman Long <longman@redhat.com>
next prev parent reply other threads:[~2024-08-05 1:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-05 0:43 Xiu Jianfeng
2024-08-05 1:23 ` Waiman Long [this message]
2024-08-05 22:16 ` Tejun Heo
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=e8186bf5-51ed-453f-8ba2-350735a2b058@redhat.com \
--to=longman@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=mkoutny@suse.com \
--cc=tj@kernel.org \
--cc=xiujianfeng@huawei.com \
--cc=xiujianfeng@huaweicloud.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®