Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757429AbcJXMEH (ORCPT ); Mon, 24 Oct 2016 08:04:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54816 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754136AbcJXMEF (ORCPT ); Mon, 24 Oct 2016 08:04:05 -0400 Date: Mon, 24 Oct 2016 14:02:32 +0200 From: Oleg Nesterov To: Peter Zijlstra 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: <20161024120231.GA16554@redhat.com> References: <318B87A793BE164187D8851D6CE09D64371C8811@shsmsx102.ccr.corp.intel.com> <20161024095341.GF3102@twins.programming.kicks-ass.net> <20161024111526.GA13509@redhat.com> <20161024112402.GI3102@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161024112402.GI3102@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 24 Oct 2016 12:04:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1160 Lines: 45 On 10/24, Peter Zijlstra wrote: > > On Mon, Oct 24, 2016 at 01:15:27PM +0200, Oleg Nesterov wrote: > > > > --- x/kernel/events/core.c > > +++ x/kernel/events/core.c > > @@ -1257,7 +1257,7 @@ static u32 perf_event_pid(struct perf_ev > > if (event->parent) > > event = event->parent; > > > > - return task_tgid_nr_ns(p, event->ns); > > + return pid_alive(p) ? task_tgid_nr_ns(p, event->ns) : 0; > > } > > Hurm.. should we not push this into task_tgid_nr_ns() ? I mean, now the > user needs to be aware of this dinky detail. Perhaps. Or into task_tgid(). Or even the patch below, __task_pid_nr_ns() is always safe. This certainly needs some cleanups. Oleg. --- x/include/linux/pid.h +++ x/include/linux/pid.h @@ -8,7 +8,8 @@ enum pid_type PIDTYPE_PID, PIDTYPE_PGID, PIDTYPE_SID, - PIDTYPE_MAX + PIDTYPE_MAX, + PIDTYPE_TGID /* do not use */ }; /* --- x/kernel/pid.c +++ x/kernel/pid.c @@ -538,7 +538,7 @@ EXPORT_SYMBOL(__task_pid_nr_ns); pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) { - return pid_nr_ns(task_tgid(tsk), ns); + return __task_pid_nr_ns(tsk, PIDTYPE_TGID, ns); } EXPORT_SYMBOL(task_tgid_nr_ns);