Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700951

Re: Possible race condition in oom-killer

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: Possible race condition in oom-killer
Date 2017-08-01 14:20 +0200
Message-ID <u9Ejv-3Ut-11@gated-at.bofh.it> (permalink)
References (1 earlier) <u8dln-4dP-3@gated-at.bofh.it> <u8dEJ-4kJ-5@gated-at.bofh.it> <u8dY6-4rR-23@gated-at.bofh.it> <u8e7O-4Ks-47@gated-at.bofh.it> <u8rHI-5wl-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat 29-07-17 13:31:44, Tetsuo Handa wrote:
[...]
> @@ -806,6 +799,20 @@ static bool task_will_free_mem(struct task_struct *task)
>  	}
>  	rcu_read_unlock();
>  
> +	/*
> +	 * It is possible that current thread fails to try allocation from
> +	 * memory reserves if the OOM reaper set MMF_OOM_SKIP on this mm before
> +	 * current thread calls out_of_memory() in order to get TIF_MEMDIE.
> +	 * In that case, allow current thread to try TIF_MEMDIE allocation
> +	 * before start selecting next OOM victims.
> +	 */
> +	if (ret && test_bit(MMF_OOM_SKIP, &mm->flags)) {
> +		if (task == current && !task->oom_kill_free_check_raced)
> +			task->oom_kill_free_check_raced = true;
> +		else
> +			ret = false;
> +	}
> +
>  	return ret;
>  }

I was going to argue that this will not work because we could mark a
former OOM victim again after it passed exit_oom_victim but this seems
impossible because task_will_free_mem checks task->mm and that will be
NULL by that time. This is still an ugly hack and it doesn't provide any
additional guarantee. Once we merge [1] then the oom victim wouldn't
need to get TIF_MEMDIE to access memory reserves.

[1] http://lkml.kernel.org/r/20170727090357.3205-2-mhocko@kernel.org
-- 
Michal Hocko
SUSE Labs

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Possible race condition in oom-killer Michal Hocko <mhocko@kernel.org> - 2017-08-01 14:20 +0200
  Re: Possible race condition in oom-killer Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-08-01 16:20 +0200
    Re: Possible race condition in oom-killer Michal Hocko <mhocko@kernel.org> - 2017-08-01 16:50 +0200

csiph-web