From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752398AbcHHJ5Z (ORCPT ); Mon, 8 Aug 2016 05:57:25 -0400 Received: from merlin.infradead.org ([205.233.59.134]:55858 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752115AbcHHJ5X (ORCPT ); Mon, 8 Aug 2016 05:57:23 -0400 Date: Mon, 8 Aug 2016 11:57:14 +0200 From: Peter Zijlstra To: Brendan Gregg Cc: Alexei Starovoitov , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , linux-kernel@vger.kernel.org, Alexei Starovoitov , Wang Nan Subject: Re: [PATCH v2 1/3] perf/core: Add a tracepoint for perf sampling Message-ID: <20160808095714.GY6879@twins.programming.kicks-ass.net> References: <1470192469-11910-1-git-send-email-bgregg@netflix.com> <1470192469-11910-2-git-send-email-bgregg@netflix.com> <20160803094805.GD6879@twins.programming.kicks-ass.net> <20160804142853.GO6862@twins.programming.kicks-ass.net> <20160805014341.GB52225@ast-mbp.thefacebook.com> <20160805052404.GA57782@ast-mbp.thefacebook.com> <20160805105209.GR6879@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Fri, Aug 05, 2016 at 10:22:08AM -0700, Brendan Gregg wrote: > (Normally I'd use I$ miss overflow, but none of our Linux systems have > PMCs: cloud.) I think I had better not comment on that ;-) > >> > The perf:perf_hrtimer probe point is also reading state mid-way > >> > through a function, so it's not quite as simple as wrapping the > >> > function pointer. I do like that idea, though, but for things like > >> > struct file_operations. > > > > So what additional state to you need? > > I was pulling in regs after get_irq_regs(), struct perf_event *event > after it's populated. Not that hard to duplicate. Just noting it > didn't map directly to the function entry. Right, both of which are available to the overflow handler. > I wanted perf_event just for event->ctx->task->pid, so that a BPF > program can differentiate between it's samples and other concurrent > sessions. > > (I was thinking of changing my patch to expose pid_t instead of > perf_event, since I was noticing it didn't add many instructions.) Slightly confused, event->ctx->task == current, no? We flip that pointer when we flip the contexts. At which point, it should be the same as SAMPLE_TID. !? > [...] > >> instead of adding a tracepoint to perf_swevent_hrtimer we can replace > >> overflow_handler for that particular event with some form of bpf wrapper. > >> (probably new bpf program type). Then not only periodic events > >> will be triggering bpf prog, but pmu events as well. > > > > Exactly. > > Although the timer use case is a bit different, and is via > hwc->hrtimer.function = perf_swevent_hrtimer. Still not entirely sure why you could not hook into event->overflow_handler.