[sheepdog] [PATCH] sheep: avoid the OOM killer

Liu Yuan namei.unix at gmail.com
Fri Jul 5 07:31:35 CEST 2013


On Fri, Jul 05, 2013 at 02:27:47PM +0900, Hitoshi Mitake wrote:
> Because sheep provides virtual disks to many VMs, sheep is an
> important process and it shouldn't be killed by the OOM killer of
> Linux. This patch implements a mechanism for avoiding the OOM killer.
> 
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
>  sheep/sheep.c |   28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/sheep/sheep.c b/sheep/sheep.c
> index 84bd269..ac9cc2a 100644
> --- a/sheep/sheep.c
> +++ b/sheep/sheep.c
> @@ -371,6 +371,30 @@ static int create_work_queues(void)
>  	return 0;
>  }
>  
> +static int avoid_oom_killer(void)

kill_oom_killer is better?

> +{
> +	int fd, ret = 0;
> +	char path[PATH_MAX];
> +
> +	/* Avoid oom-killer */

This comment is meaningless.

> +	snprintf(path, PATH_MAX, "/proc/%d/oom_score_adj", getpid());
> +	fd = open(path, O_WRONLY);
> +	if (fd < 0) {
> +		sd_iprintf("opening %s failed, %m", path);
> +		ret = -1;
> +		goto end;
> +	}
> +
> +	if (xwrite(fd, "-1000\n", 6) != 6) {

Please explain what does -1000 means why you choose it.

Thanks
Yuan



More information about the sheepdog mailing list