Re: [PATCH] cgroup: minor optimization around the usage of cur_tasks_head

Tejun Heo
2022-01-26T16:47:11Z

On Wed, Jan 26, 2022 at 02:17:05PM +0000, Yafang Shao wrote:
> Recently there was an issue occurred on our production envrionment with a
> very old kernel version 4.19. That issue can be fixed by upstream
> commit 9c974c772464 ("cgroup: Iterate tasks that did not finish do_exit()")
>
> When I was trying to fix that issue on our production environment, I found
> we can create a hotfix with a simplified version of the commit -
>
> As the usage of cur_tasks_head is within the function
> css_task_iter_advance(), we can make it as a local variable. That could
> make it more clear and easier to understand. Another benefit is we don't
> need to carry it in css_task_iter.
>
> Signed-off-by: Yafang Shao <laoar.shao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Michal Koutný <mkoutny-IBi9RG/b67k@public.gmane.org>

I can't tell whether this is better or not. Sure, it loses one pointer from
the struct but that doesn't really gain anything practical. On the other
hand, before, we could understand where the iteration was by just dumping
the struct. After, we can't. At best, maybe this change is a wash.

Thanks.

--
tejun