[Devel] [PATCH rh7 v2 3/6] oom: rework locking design

Vladimir Davydov vdavydov at parallels.com
Sat Sep 12 05:56:59 PDT 2015


On Fri, Sep 11, 2015 at 06:18:03PM +0300, Vladimir Davydov wrote:
...
> @@ -423,6 +449,19 @@ void mark_oom_victim(struct task_struct *tsk)
>  	 * that TIF_MEMDIE tasks should be ignored.
>  	 */
>  	__thaw_task(tsk);
> +
> +	/*
> +	 * Record the pointer to the victim in the oom context of the
> +	 * owner memcg. It will be used in exit_oom_victim in order to
> +	 * wake up all processes waiting for the oom victim to exit.
> +	 */
> +	memcg = try_get_mem_cgroup_from_mm(tsk->mm);
> +	ctx = mem_cgroup_oom_context(memcg);
> +	spin_lock(&oom_context_lock);
> +	if (!ctx->victim)
> +		ctx->victim = tsk;
> +	spin_unlock(&oom_context_lock);

We do not propagate victim up to the context that initiated oom here,
neither do we in oom_unlock. That means, if a process was killed in
cgroup A/B as a result of memory limit of A, oom_unlock will immediately
wake all processes waiting on A although it makes no sense - they should
wait for victim in B to exit. I will rework and resend soon.

> +	mem_cgroup_put(memcg);
>  }



More information about the Devel mailing list