[CRIU] Re: [PATCH] pstree: Rename @max_pid to @helper_task_pid
Andrey Wagin
avagin at gmail.com
Tue Oct 2 11:07:08 EDT 2012
2012/10/2 Cyrill Gorcunov <gorcunov at openvz.org>:
> This name is too abstract, rename it trying to
> explain why we need it.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> pstree.c | 16 +++++++++++-----
> 1 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/pstree.c b/pstree.c
> index 6033e7e..a464107 100644
> --- a/pstree.c
> +++ b/pstree.c
> @@ -116,7 +116,13 @@ err:
> return ret;
> }
>
> -static int max_pid = 0;
> +/*
> + * This is the pid we use for helper tasks, it should
> + * not ever intersect with any pid in process tree we're
> + * restoring.
> + */
> +static int helper_task_pid = 0;
No. It is not one pid and here is one more thing.
Look at this code:
max_pid = max((int)e->pid, max_pid);
max_pid is a maximum value of pid. Why do you want to rename max_pid?
We can rename this value to last_pid, that it looks like in a kernel.
> +
> int prepare_pstree(void)
> {
> int ret = 0, i, ps_fd;
> @@ -141,13 +147,13 @@ int prepare_pstree(void)
> break;
>
> pi->pid.virt = e->pid;
> - max_pid = max((int)e->pid, max_pid);
> + helper_task_pid = max((int)e->pid, helper_task_pid);
>
> pi->pgid = e->pgid;
> - max_pid = max((int)e->pgid, max_pid);
> + helper_task_pid = max((int)e->pgid, helper_task_pid);
>
> pi->sid = e->sid;
> - max_pid = max((int)e->sid, max_pid);
> + helper_task_pid = max((int)e->sid, helper_task_pid);
>
> if (e->ppid == 0) {
> if (root_item) {
> @@ -300,7 +306,7 @@ int prepare_pstree_ids(void)
> continue;
>
> child->pgid = item->pgid;
> - child->pid.virt = ++max_pid;
> + child->pid.virt = ++helper_task_pid;
> child->parent = item;
> list_move(&child->list, &item->children);
>
> --
> 1.7.7.6
>
More information about the CRIU
mailing list