Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758673AbcJYJ2e (ORCPT ); Tue, 25 Oct 2016 05:28:34 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:50396 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755405AbcJYJ2c (ORCPT ); Tue, 25 Oct 2016 05:28:32 -0400 Date: Tue, 25 Oct 2016 11:28:31 +0200 From: Peter Zijlstra To: Oleg Nesterov Cc: "Ni, BaoleX" , "mingo@redhat.com" , "acme@kernel.org" , "linux-kernel@vger.kernel.org" , "alexander.shishkin@linux.intel.com" , "Liu, Chuansheng" Subject: Re: hit a KASan bug related to Perf during stress test Message-ID: <20161025092831.GW3102@twins.programming.kicks-ass.net> References: <20161024111526.GA13509@redhat.com> <20161024112402.GI3102@twins.programming.kicks-ass.net> <20161024120231.GA16554@redhat.com> <20161024121030.GA17007@redhat.com> <20161024122210.GM3102@twins.programming.kicks-ass.net> <20161024122942.GC17007@redhat.com> <20161024123814.GP3102@twins.programming.kicks-ass.net> <20161024132555.GA18410@redhat.com> <20161024143646.GR3102@twins.programming.kicks-ass.net> <20161024153908.GA26135@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161024153908.GA26135@redhat.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1003 Lines: 27 On Mon, Oct 24, 2016 at 05:39:08PM +0200, Oleg Nesterov wrote: > On 10/24, Peter Zijlstra wrote: > > > > --- a/kernel/events/core.c > > +++ b/kernel/events/core.c > > @@ -1257,7 +1257,14 @@ static u32 perf_event_pid(struct perf_event *event, struct task_struct *p) > > if (event->parent) > > event = event->parent; > > > > - return task_tgid_nr_ns(p, event->ns); > > + /* > > + * It is possible the task already got unhashed, in which case we > > + * cannot determine the current->group_leader/real_parent. > > + * > > + * Also, report -1 to indicate unhashed, so as not to confused with > > + * 0 for the idle task. > > + */ > > + return pid_alive(p) ? task_tgid_nr_ns(p, event->ns) : ~0; > > } > > Yes, but this _looks_ racy unless p == current. I mean, pid_alive() makes > task_tgid_nr_ns() safe, but task_tgid_nr_ns() still can return zero _if_ > it can race with the exiting task. So what serialization would close that race? __task_pid_nr_ns() only seems to use RCU nothing more.