[CRIU] [PATCH v4 2/5] criu: restore loginuid & oom_score_adj values

Pavel Emelyanov xemul at parallels.com
Wed Dec 16 07:10:31 PST 2015


All applied, thanks. More incremental patches required however, see inline.

On 12/14/2015 12:19 PM, Dmitry Safonov wrote:
> https://jira.sw.ru/browse/PSBM-41993
> 
> Signed-off-by: Dmitry Safonov <dsafonov at odin.com>
> ---
>  cr-restore.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 3c636b9..9501713 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -840,6 +840,64 @@ err:
>  	return -1;
>  }
>  
> +static int prepare_pid_oom_score_adj(pid_t pid, int value)
> +{
> +	int fd, ret = 0;
> +	char buf[11];

Need fastpath here -- if current oom score matches the default one,
no need to mess with proc.

> +
> +	fd = open_proc_rw(pid, "oom_score_adj");
> +	if (fd < 0)
> +		return -1;
> +
> +	snprintf(buf, 11, "%d", value);
> +
> +	if (write(fd, buf, 11) < 0) {
> +		pr_perror("Write %s to /proc/%d/oom_score_adj failed",
> +			buf, pid);
> +		ret = -1;
> +	}
> +
> +	close(fd);
> +	return ret;
> +}
> +
> +static int prepare_pid_loginuid(pid_t pid, unsigned int value)
> +{
> +	int fd, ret = 0;
> +	char buf[11]; /* 4294967295 is maximum for u32 */

And here -- loginuid is inherited, so if parent has the same, no need
to do restore it.

-- Pavel


More information about the CRIU mailing list