From patchwork Fri Sep 4 12:16:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 53087 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 62B1E22E23 for ; Fri, 4 Sep 2015 12:19:30 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf5620886wic.2 for ; Fri, 04 Sep 2015 05:19:29 -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=H1Y+0UpVUhZV5mVwhsdEDRfQktKzJ04POmhjSDBbUFw=; b=IQ+bh5aO+P2gNbNQ8+tv2Bgvo9dHPvBIJV2+pR6UH41R+zeODDe8wlmtkYffc045u3 Oy6Jo0Xf2fjknj0X2SmzYcEb9Ya5cfCOjnrxOkITUd2txCTHDoTMMvyq1LgwOExHY8w5 2gJchVuzMQ3bI7OwwLWWHI2k0LHNNWGImSdT5nBsvZJfIUdxtPOUR2smEbsCvVDGjWI0 Z5drmljtybj/vhPCIy//nmu2Mend0n9uR1pljrHn57JYMrRo828YJzjPaUhoAOWd1opi +smazwltjHssLI0k042I65n9jfjHTYgaKRS8w1PPd4PsXD48xDTy2/vF8STb+0erXpQ6 qCuw== X-Gm-Message-State: ALoCoQnF5h0qy9pMEVbS/2KkTvXe7VURX8US7aGBS6NW9TvoIcVXbpkD+zygNnZJR0rlLqoznxzb X-Received: by 10.112.199.5 with SMTP id jg5mr968196lbc.14.1441369169627; Fri, 04 Sep 2015 05:19:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.137 with SMTP id jc9ls311998lac.26.gmail; Fri, 04 Sep 2015 05:19:29 -0700 (PDT) X-Received: by 10.152.181.5 with SMTP id ds5mr3405563lac.60.1441369169442; Fri, 04 Sep 2015 05:19:29 -0700 (PDT) Received: from mail-la0-x236.google.com (mail-la0-x236.google.com. [2a00:1450:4010:c03::236]) by mx.google.com with ESMTPS id iz8si2147914lac.131.2015.09.04.05.19.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2015 05:19:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) client-ip=2a00:1450:4010:c03::236; Received: by lagj9 with SMTP id j9so12348548lag.2 for ; Fri, 04 Sep 2015 05:19:29 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr3427766lbc.112.1441369169297; Fri, 04 Sep 2015 05:19:29 -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 yn10csp1929038lbb; Fri, 4 Sep 2015 05:19:27 -0700 (PDT) X-Received: by 10.68.68.143 with SMTP id w15mr7909318pbt.56.1441369167755; Fri, 04 Sep 2015 05:19:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id di3si4042048pbc.142.2015.09.04.05.19.26; Fri, 04 Sep 2015 05:19:27 -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 S1758904AbbIDMTX (ORCPT + 28 others); Fri, 4 Sep 2015 08:19:23 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33451 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753428AbbIDMTU (ORCPT ); Fri, 4 Sep 2015 08:19:20 -0400 Received: by pacex6 with SMTP id ex6so23254041pac.0 for ; Fri, 04 Sep 2015 05:19:20 -0700 (PDT) X-Received: by 10.66.122.207 with SMTP id lu15mr7748032pab.146.1441369160409; Fri, 04 Sep 2015 05:19:20 -0700 (PDT) Received: from localhost.localdomain ([121.167.8.74]) by smtp.gmail.com with ESMTPSA id un2sm2385267pac.28.2015.09.04.05.19.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Sep 2015 05:19:19 -0700 (PDT) From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , Masami Hiramatsu , Wang Nan , pi3orama@163.com Subject: [PATCH v2 2/5] perf probe: Attach trace_probe_event with perf_probe_event Date: Fri, 4 Sep 2015 21:16:00 +0900 Message-Id: <1441368963-11565-2-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1441368963-11565-1-git-send-email-namhyung@kernel.org> References: <1441368963-11565-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: namhyung@kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@gmail.com 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 trace_probe_event into 'struct perf_probe_event'. trace_probe_event information gives further patches a chance to access actual probe points and actual arguments. Using them, perf probe can get whole list of added probes and print them at once. Other users like upcoming bpf_loader will be able to attach one bpf program to different probing points of an inline functions (which has multiple probing points) and glob functions. Moreover, by reading arguments information, bpf code for reading those arguments can be generated. Acked-by: Masami Hiramatsu Signed-off-by: Wang Nan [namhyung: extract necessary part from the existing patch] Signed-off-by: Namhyung Kim --- 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,