From patchwork Fri Sep 4 16:45:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 53135 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 6026F2159E for ; Fri, 4 Sep 2015 16:50:12 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf8648675lbc.1 for ; Fri, 04 Sep 2015 09:50:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=ocXEgMW19b2WKU0jqTKEyq6Od3Y6vM1UIfpe1bnCovk=; b=MJhR+c5LR5bSQtxx6QyA5MY+sdLTGC6owlwVuYmX33R+DrXWdDj1JF/ivmG/8RrY4u plBqI5yrbJxVxgzROP9jZrAbOmPHTol5XF6P78zLZeaKhXEJ8ypo3e/crOqhi51MgxBk fTxqxcXUsBOiIJ/TdpbcOr5NE30vMCVG5oAooaQAHvHktN7T3L41K/MPOlq16Cv2Mvq2 6o/FPwFpcXlzymK/whUJjWcAcuGOU2Oea+cUPH4WbVKofFeIB3X3XlyyATM1M+L255T+ GktxHAEXadjUaEMTWGrYFifBTQFD4lzpVZffeBrQuhA2bMhbnDQsc+KiWRgaDXXDQP/u 6PMQ== X-Gm-Message-State: ALoCoQmRplGhMnUChOA9GIEMSDJeZIHE7KTu7z9Poow+uXrOCE7MOOLe3oMJ0ww0L9nO/lDxwfO/ X-Received: by 10.180.89.104 with SMTP id bn8mr1378420wib.4.1441385411293; Fri, 04 Sep 2015 09:50:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.1 with SMTP id g1ls343099lag.46.gmail; Fri, 04 Sep 2015 09:50:11 -0700 (PDT) X-Received: by 10.112.169.8 with SMTP id aa8mr4127016lbc.90.1441385411088; Fri, 04 Sep 2015 09:50:11 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id n10si2741570laj.155.2015.09.04.09.50.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2015 09:50:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbpo4 with SMTP id o4so14572778lbp.2 for ; Fri, 04 Sep 2015 09:50:11 -0700 (PDT) X-Received: by 10.112.146.135 with SMTP id tc7mr4598130lbb.35.1441385410933; Fri, 04 Sep 2015 09:50:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp31274lbb; Fri, 4 Sep 2015 09:50:10 -0700 (PDT) X-Received: by 10.66.234.202 with SMTP id ug10mr10355523pac.50.1441385409820; Fri, 04 Sep 2015 09:50:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lx10si5186050pdb.65.2015.09.04.09.50.08; Fri, 04 Sep 2015 09:50:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760350AbbIDQqy (ORCPT + 28 others); Fri, 4 Sep 2015 12:46:54 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:45597 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932996AbbIDQpp (ORCPT ); Fri, 4 Sep 2015 12:45:45 -0400 Received: from [177.35.17.8] (helo=zoo.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZXu7M-0005uT-Ac; Fri, 04 Sep 2015 16:45:36 +0000 Received: by zoo.infradead.org (Postfix, from userid 1000) id 6CC64220210; Fri, 4 Sep 2015 13:45:21 -0300 (BRT) From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Wang Nan , Jiri Olsa , Peter Zijlstra , pi3orama@163.com, Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 27/31] perf probe: Link trace_probe_event into perf_probe_event Date: Fri, 4 Sep 2015 13:45:11 -0300 Message-Id: <1441385115-6744-28-git-send-email-acme@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1441385115-6744-1-git-send-email-acme@kernel.org> References: <1441385115-6744-1-git-send-email-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: acme@kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Wang Nan This patch drops struct __event_package structure. Instead, it adds a 'struct trace_probe_event' pointer to 'struct perf_probe_event'. The trace_probe_event information gives further patches a chance to access actual probe points and actual arguments. Using them, 'perf probe' can get the whole list of added probes and print them at once. Other users like the upcoming bpf_loader will be able to attach one bpf program to different probing points of an inline function (which has multiple probing points) and glob functions. Moreover, by reading the arguments information, bpf code for reading those arguments can be generated. Signed-off-by: Wang Nan Acked-by: Masami Hiramatsu Cc: Jiri Olsa Cc: Peter Zijlstra Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1441368963-11565-2-git-send-email-namhyung@kernel.org [namhyung: extract necessary part from the existing patch] Signed-off-by: Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-event.c | 57 +++++++++++++------------------------------ tools/perf/util/probe-event.h | 5 ++++ 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 2c762f41e7a5..0d3a051b9202 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -2759,59 +2759,39 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev, return find_probe_trace_events_from_map(pev, tevs); } -struct __event_package { - struct perf_probe_event *pev; - struct probe_trace_event *tevs; - int ntevs; -}; - -static int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs, - struct __event_package **ppkgs) +int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs) { int i, ret; - struct __event_package *pkgs; - - ret = 0; - pkgs = zalloc(sizeof(struct __event_package) * npevs); - - if (pkgs == NULL) - return -ENOMEM; ret = init_symbol_maps(pevs->uprobes); - if (ret < 0) { - free(pkgs); + if (ret < 0) return ret; - } /* Loop 1: convert all events */ for (i = 0; i < npevs; i++) { - pkgs[i].pev = &pevs[i]; /* Init kprobe blacklist if needed */ - if (!pkgs[i].pev->uprobes) + if (!pevs[i].uprobes) kprobe_blacklist__init(); /* Convert with or without debuginfo */ - ret = convert_to_probe_trace_events(pkgs[i].pev, - &pkgs[i].tevs); + ret = convert_to_probe_trace_events(&pevs[i], &pevs[i].tevs); if (ret < 0) return ret; - pkgs[i].ntevs = ret; + pevs[i].ntevs = ret; } /* This just release blacklist only if allocated */ kprobe_blacklist__release(); - *ppkgs = pkgs; - return 0; } -static int apply_perf_probe_events(struct __event_package *pkgs, int npevs) +int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs) { int i, ret = 0; /* Loop 2: add all events */ for (i = 0; i < npevs; i++) { - ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs, - pkgs[i].ntevs, + ret = __add_probe_trace_events(&pevs[i], pevs[i].tevs, + pevs[i].ntevs, probe_conf.force_add); if (ret < 0) break; @@ -2819,33 +2799,30 @@ static int apply_perf_probe_events(struct __event_package *pkgs, int npevs) return ret; } -static void cleanup_perf_probe_events(struct __event_package *pkgs, int npevs) +void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs) { int i, j; - if (pkgs == NULL) - return; - /* Loop 3: cleanup and free trace events */ for (i = 0; i < npevs; i++) { - for (j = 0; j < pkgs[i].ntevs; j++) - clear_probe_trace_event(&pkgs[i].tevs[j]); - zfree(&pkgs[i].tevs); + for (j = 0; j < pevs[i].ntevs; j++) + clear_probe_trace_event(&pevs[i].tevs[j]); + zfree(&pevs[i].tevs); + pevs[i].ntevs = 0; } - free(pkgs); + exit_symbol_maps(); } int add_perf_probe_events(struct perf_probe_event *pevs, int npevs) { int ret; - struct __event_package *pkgs = NULL; - ret = convert_perf_probe_events(pevs, npevs, &pkgs); + ret = convert_perf_probe_events(pevs, npevs); if (ret == 0) - ret = apply_perf_probe_events(pkgs, npevs); + ret = apply_perf_probe_events(pevs, npevs); - cleanup_perf_probe_events(pkgs, npevs); + cleanup_perf_probe_events(pevs, npevs); return ret; } diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index 6e7ec68a4aa8..70c327bd61de 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h @@ -87,6 +87,8 @@ struct perf_probe_event { bool uprobes; /* Uprobe event flag */ char *target; /* Target binary */ struct perf_probe_arg *args; /* Arguments */ + struct probe_trace_event *tevs; + int ntevs; }; /* Line range */ @@ -138,6 +140,9 @@ extern void line_range__clear(struct line_range *lr); extern int line_range__init(struct line_range *lr); extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs); +extern int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs); +extern int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs); +extern void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs); extern int del_perf_probe_events(struct strfilter *filter); extern int show_perf_probe_events(struct strfilter *filter); extern int show_line_range(struct line_range *lr, const char *module,