Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941074AbcJXOSE (ORCPT ); Mon, 24 Oct 2016 10:18:04 -0400 Received: from merlin.infradead.org ([205.233.59.134]:56120 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938845AbcJXOSC (ORCPT ); Mon, 24 Oct 2016 10:18:02 -0400 Date: Mon, 24 Oct 2016 16:17:53 +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: <20161024141753.GQ3102@twins.programming.kicks-ass.net> References: <20161024095341.GF3102@twins.programming.kicks-ass.net> <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> <20161024134012.GA20798@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161024134012.GA20798@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: 1226 Lines: 35 On Mon, Oct 24, 2016 at 03:40:13PM +0200, Oleg Nesterov wrote: > On 10/24, Oleg Nesterov wrote: > > > > -static u32 perf_event_pid(struct perf_event *event, struct task_struct *p) > > +static u32 perf_event_xxx(struct perf_event *event, struct task_struct *p, > > + enum pid_type type) > > { > > + pid_t nr; > > /* > > * only top level events have the pid namespace they were created in > > */ > > if (event->parent) > > event = event->parent; > > > > - return task_tgid_nr_ns(p, event->ns); > > + nr = __task_pid_nr_ns(p, type, event->ns); > > + if (!nr && !is_idle_task(p)) > > + nr = -1; > > + return nr; > > And just in case... In any case __task_pid_nr_ns() and other similar helpers > can also return zero if "p" runs in another namespace. Say, in the parent ns. Right, I'm tempted to not change that. Its been the behaviour for a while and changing that will upset people. The unhash case is different in that its actively broken so we must do something. > Say, perf_event_switch_output(). What do we want to report in this case, zero > or -1 ? As with all switch_output() cases, the user had better know wth he's doing ;-) Doing a switch_output() on a running counter is dubious to begin with.