kernel/cgroup/pids.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
From: Xiu Jianfeng <xiujianfeng@huawei.com>
According to the implement of cgroup_css_set_fork() and the usage in
the cpuset controller which also has .can_fork and .cancel_fork hooks,
the argument 'cset' for these two hooks must not be NULL, so remove
the unrechable paths in thse two hooks.
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
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);
}
--
2.34.1
On 8/3/24 02:16, Xiu Jianfeng wrote:
> From: Xiu Jianfeng <xiujianfeng@huawei.com>
>
> According to the implement of cgroup_css_set_fork() and the usage in
"implementation"?
> the cpuset controller which also has .can_fork and .cancel_fork hooks,
> the argument 'cset' for these two hooks must not be NULL, so remove
> the unrechable paths in thse two hooks.
It is primarily due to cgroup_css_set_fork() will fail if cset cannot be
found and the can_fork/cancel_fork method will not be called in this case.
Cheers,
Longman
>
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> ---
> 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);
> }
>
On 2024/8/3 21:59, Waiman Long wrote:
>
> On 8/3/24 02:16, Xiu Jianfeng wrote:
>> From: Xiu Jianfeng <xiujianfeng@huawei.com>
>>
>> According to the implement of cgroup_css_set_fork() and the usage in
> "implementation"?
Thanks, will do
>> the cpuset controller which also has .can_fork and .cancel_fork hooks,
>> the argument 'cset' for these two hooks must not be NULL, so remove
>> the unrechable paths in thse two hooks.
>
> It is primarily due to cgroup_css_set_fork() will fail if cset cannot be
> found and the can_fork/cancel_fork method will not be called in this case.
Thanks for your review, I will reword the commit message in the next
version.
>
> Cheers,
> Longman
>
>>
>> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
>> ---
>> 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);
>> }
>>
© 2016 - 2025 Red Hat, Inc.