From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755556AbbE2GhD (ORCPT ); Fri, 29 May 2015 02:37:03 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:33112 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755501AbbE2Gg4 (ORCPT ); Fri, 29 May 2015 02:36:56 -0400 Date: Fri, 29 May 2015 08:36:50 +0200 From: Ingo Molnar To: Vince Weaver Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, eranian@google.com, Paul Mackerras , Arnaldo Carvalho de Melo Subject: Re: [patch] inherited events not signalling parent on overflow Message-ID: <20150529063650.GA22568@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Vince Weaver wrote: > We're trying to get self-monitoring multi-threaded sampling working in PAPI. > Fun times. > > Is this even possible? > > Ideally in your parent thread you could perf_event_open() with inherit set. > Then your program (say an OpenMP program) would do its thing and all of the > samples would get written back to the parent thread's mmap() buffer. > > But this won't work as mmap'ing an inherited event is explicitly disasllowed in > events.c due to "performance reasons". > > Which is believable, it's just there's not really a good alternative that > doesn't involve having to somehow manually instrument every single possible > thread. > > on a related note, I turned up the following issue when working on this issue. > I don't know if this is the proper fix but it makes my simple test case behave > as expected. > > If we inherit events, we inherit the signal state but not the fasync state, so > overflows in inherited children will never trigger the signal handler. > > Signed-off-by: Vince Weaver > > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 1a3bf48..7df4cf5 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -8626,6 +8630,8 @@ inherit_event(struct perf_event *parent_event, > child_event->overflow_handler_context > = parent_event->overflow_handler_context; > > + child_event->fasync = parent_event->fasync; > + > /* > * Precalculate sample_data sizes > */ Btw., if we do this (sensible looking) ABI fix, could we make it a new attr bit, so that PAPI can essentially query the kernel whether this gets propagated properly? That way old kernels 'intentionally' don't inherit the fasync handler and tooling can deterministically make use of this 'feature' on new kernels. Thanks, Ingo