From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by kanga.kvack.org (Postfix) with ESMTP id 6AE0C6B00F0 for ; Mon, 11 Nov 2013 18:16:17 -0500 (EST) Received: by mail-pb0-f50.google.com with SMTP id xb12so1766891pbc.23 for ; Mon, 11 Nov 2013 15:16:17 -0800 (PST) Received: from psmtp.com ([74.125.245.185]) by mx.google.com with SMTP id yl8si17578716pab.176.2013.11.11.15.16.14 for ; Mon, 11 Nov 2013 15:16:16 -0800 (PST) Received: by mail-we0-f169.google.com with SMTP id q58so5329885wes.28 for ; Mon, 11 Nov 2013 15:16:12 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20131109151639.GB14249@redhat.com> References: <20131108184515.GA11555@redhat.com> <1383940173-16480-1-git-send-email-snanda@chromium.org> <20131109151639.GB14249@redhat.com> From: Sameer Nanda Date: Mon, 11 Nov 2013 15:15:52 -0800 Message-ID: Subject: Re: [PATCH v3] mm, oom: Fix race when selecting process to kill Content-Type: multipart/alternative; boundary=f46d043be1b0006c2404eaeeebcb Sender: owner-linux-mm@kvack.org List-ID: To: Oleg Nesterov Cc: Andrew Morton , mhocko@suse.cz, David Rientjes , Johannes Weiner , Rusty Russell , Luigi Semenzato , murzin.v@gmail.com, dserrg@gmail.com, "msb@chromium.org" , linux-mm@kvack.org, linux-kernel@vger.kernel.org --f46d043be1b0006c2404eaeeebcb Content-Type: text/plain; charset=UTF-8 On Sat, Nov 9, 2013 at 7:16 AM, Oleg Nesterov wrote: > On 11/08, Sameer Nanda wrote: > > > > @@ -413,12 +413,20 @@ void oom_kill_process(struct task_struct *p, gfp_t > gfp_mask, int order, > > DEFAULT_RATELIMIT_BURST); > > @@ -456,10 +463,18 @@ void oom_kill_process(struct task_struct *p, gfp_t > gfp_mask, int order, > > } > > } > > } while_each_thread(p, t); > > - read_unlock(&tasklist_lock); > > > > rcu_read_lock(); > > + > > p = find_lock_task_mm(victim); > > + > > + /* > > + * Since while_each_thread is currently not RCU safe, this unlock > of > > + * tasklist_lock may need to be moved further down if any > additional > > + * while_each_thread loops get added to this function. > > + */ > > + read_unlock(&tasklist_lock); > > Well, ack... but with this change find_lock_task_mm() relies on tasklist, > so it makes sense to move rcu_read_lock() down before for_each_process(). > Otherwise this looks confusing, but I won't insist. > Agreed that this looks a bit confusing. I will respin the patch. > > Oleg. > > -- Sameer --f46d043be1b0006c2404eaeeebcb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On Sat, Nov 9, 2013 at 7:16 AM, Oleg Nesterov <= ;oleg= @redhat.com> wrote:
On 11/08, Sameer Nanda wro= te:
>
> @@ -413,12 +413,20 @@ void oom_kill_process(st= ruct task_struct *p, gfp_t gfp_mask, int order,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 DEFAULT_RATELIMIT_BURST);
> @@ -456,10 +463,18 @@ void oom_kill_process(st= ruct task_struct *p, gfp_t gfp_mask, int order,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 }
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> =C2=A0 =C2=A0 =C2=A0 } while_each_thread(p, t);
> - =C2=A0 =C2=A0 read_unlock(&tasklist_lock);
>
> =C2=A0 =C2=A0 =C2=A0 rcu_read_lock();
> +
> =C2=A0 =C2=A0 =C2=A0 p =3D find_lock_task_mm(victim);
> +
> + =C2=A0 =C2=A0 /*
> + =C2=A0 =C2=A0 =C2=A0* Since while_each_thread is currently not RCU s= afe, this unlock of
> + =C2=A0 =C2=A0 =C2=A0* tasklist_lock may need to be moved further dow= n if any additional
> + =C2=A0 =C2=A0 =C2=A0* while_each_thread loops get added to this func= tion.
> + =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 read_unlock(&tasklist_lock);

Well, ack... but with this change find_lock_task_mm() relies on taskl= ist,
so it makes sense to move rcu_read_lock() down before for_each_process(). Otherwise this looks confusing, but I won't insist.

Agreed that this looks a bit confusing. =C2=A0I will respi= n the patch.
=C2=A0

Oleg.




-- Sameer
--f46d043be1b0006c2404eaeeebcb-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org