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


Groups > linux.kernel > #1423113

Re: [PATCH 05/10] mm, oom: skip vforked tasks from being selected

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 05/10] mm, oom: skip vforked tasks from being selected
Date 2016-06-15 17:00 +0200
Message-ID <rKksq-3QZ-31@gated-at.bofh.it> (permalink)
References <rI6MV-5RF-3@gated-at.bofh.it> <rI6MW-5RF-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 06/09, Michal Hocko wrote:
>
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1883,6 +1883,32 @@ extern int arch_task_struct_size __read_mostly;
>  #define TNF_FAULT_LOCAL	0x08
>  #define TNF_MIGRATE_FAIL 0x10
>  
> +static inline bool in_vfork(struct task_struct *tsk)
> +{
> +	bool ret;
> +
> +	/*
> +	 * need RCU to access ->real_parent if CLONE_VM was used along with
> +	 * CLONE_PARENT.
> +	 *
> +	 * We check real_parent->mm == tsk->mm because CLONE_VFORK does not
> +	 * imply CLONE_VM
> +	 *
> +	 * CLONE_VFORK can be used with CLONE_PARENT/CLONE_THREAD and thus
> +	 * ->real_parent is not necessarily the task doing vfork(), so in
> +	 * theory we can't rely on task_lock() if we want to dereference it.
> +	 *
> +	 * And in this case we can't trust the real_parent->mm == tsk->mm
> +	 * check, it can be false negative. But we do not care, if init or
> +	 * another oom-unkillable task does this it should blame itself.
> +	 */
> +	rcu_read_lock();
> +	ret = tsk->vfork_done && tsk->real_parent->mm == tsk->mm;
> +	rcu_read_unlock();
> +
> +	return ret;
> +}

ACK, but why sched.h ? It has a single caller in oom_kill.c.

Oleg.

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


Thread

Re: [PATCH 05/10] mm, oom: skip vforked tasks from being selected Oleg Nesterov <oleg@redhat.com> - 2016-06-15 17:00 +0200
  Re: [PATCH 05/10] mm, oom: skip vforked tasks from being selected Michal Hocko <mhocko@kernel.org> - 2016-06-16 08:30 +0200

csiph-web