Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2704208pxv; Sun, 27 Jun 2021 06:20:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwktwKEpm3c7flGB0S6Y9rpp80bDDQ1PW0TT4TsGnx6pg6ghnzWkLKBTCoU/0Oyg1O1bQcr X-Received: by 2002:a92:3647:: with SMTP id d7mr14580580ilf.231.1624800003328; Sun, 27 Jun 2021 06:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624800003; cv=none; d=google.com; s=arc-20160816; b=Zo/G4kC/snLa+ok5WUv3wj47bdkkjJWa7x+Pd0g/CFA0xL55wN/9KAqs2nn9W3bgDz YnBLmYPG3kBkU1jaP3L5I9M4nyzhZyJwHlkDUsKUL5XHKCi7ynYTiNROJ1E+0cC3Jg1X zYkkjoWVoCsCCDSHxP+xU9nH293b0HOr4l7kB/f1LIAuq8RbpasdMBOQNmYQe/vWG4GD sYVmrutG1gKoAqRKg0hqnsJNKiwvN3gY5iHNZdHahOAcMvR11FOGbs1HYxZmqPWvoYu0 l4JzBmC6mcdQb/7bueedDaFkyYnTAClYL5YszqMHWESNfamtGpMdnPvVRit4m0x8UKjo 7ypw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:references:in-reply-to:message-id :date:subject:cc:to:from; bh=cwK3xKsANTm7jzD/NcoX9AYOhdxNDFbjpgoDA/lKKF8=; b=o85npTnd31a4FhoMJq5oivn88uFs/ILpJF+MNfoFGaaNZI1e66gdfZxoIjD/afNR9j IU5kXmsEEtNKdya20lcEHF8Ao55pJa5YbX3v66AjKmVwsz+4699FLpjzJqGzknd2KV3s v0LS9PYJ0+4qnkS3/6SjAR2UzoANzmqU1ocYDQn+ry7KtJiNfhCWkOE0rnGNS1/d2yrB 9I7CbF8Map6jfFZlqD8oaj8jvEsmYZjHVD93hhMy/dXaztWBN5TRdUB4hpCT44zYHJk7 iyjODbqIdkdX+vNIAcccQnBqWqAOvLBcZGn50eJNhKjxdu3YcBPkEmQo6WSbOKoZYs8o y1bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si12875503ilc.133.2021.06.27.06.19.51; Sun, 27 Jun 2021 06:20:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231239AbhF0NUr (ORCPT + 99 others); Sun, 27 Jun 2021 09:20:47 -0400 Received: from mga18.intel.com ([134.134.136.126]:60751 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbhF0NUo (ORCPT ); Sun, 27 Jun 2021 09:20:44 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10027"; a="195137058" X-IronPort-AV: E=Sophos;i="5.83,302,1616482800"; d="scan'208";a="195137058" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2021 06:18:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,302,1616482800"; d="scan'208";a="640589057" Received: from ahunter-desktop.fi.intel.com ([10.237.72.79]) by fmsmga006.fm.intel.com with ESMTP; 27 Jun 2021 06:18:17 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Andi Kleen , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Leo Yan , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 06/10] perf dlfilter: Add resolve_address() to perf_dlfilter_fns Date: Sun, 27 Jun 2021 16:18:14 +0300 Message-Id: <20210627131818.810-7-adrian.hunter@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210627131818.810-1-adrian.hunter@intel.com> References: <20210627131818.810-1-adrian.hunter@intel.com> Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a function, for use by dlfilters, to resolve addresses from branch stacks or callchains. Signed-off-by: Adrian Hunter --- tools/perf/Documentation/perf-dlfilter.txt | 6 ++++- tools/perf/util/dlfilter.c | 29 ++++++++++++++++++++++ tools/perf/util/perf_dlfilter.h | 7 +++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-dlfilter.txt b/tools/perf/Documentation/perf-dlfilter.txt index 5795ab3ca23b..642323ac8934 100644 --- a/tools/perf/Documentation/perf-dlfilter.txt +++ b/tools/perf/Documentation/perf-dlfilter.txt @@ -123,7 +123,8 @@ struct perf_dlfilter_fns { const struct perf_dlfilter_al *(*resolve_ip)(void *ctx); const struct perf_dlfilter_al *(*resolve_addr)(void *ctx); char **(*args)(void *ctx, int *dlargc); - void *(*reserved[125])(void *); + __s32 (*resolve_address)(void *ctx, __u64 address, struct perf_dlfilter_al *al); + void *(*reserved[124])(void *); }; ---- @@ -133,6 +134,9 @@ struct perf_dlfilter_fns { 'args' returns arguments from --dlarg options. +'resolve_address' provides information about 'address'. al->size must be set +before calling. Returns 0 on success, -1 otherwise. + The perf_dlfilter_al structure ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c index eaa3cea49178..4b03227541d3 100644 --- a/tools/perf/util/dlfilter.c +++ b/tools/perf/util/dlfilter.c @@ -149,10 +149,39 @@ static char **dlfilter__args(void *ctx, int *dlargc) return d->dlargv; } +static __s32 dlfilter__resolve_address(void *ctx, __u64 address, struct perf_dlfilter_al *d_al_p) +{ + struct dlfilter *d = (struct dlfilter *)ctx; + struct perf_dlfilter_al d_al; + struct addr_location al; + struct thread *thread; + __u32 sz; + + if (!d->ctx_valid || !d_al_p) + return -1; + + thread = get_thread(d); + if (!thread) + return -1; + + thread__find_symbol_fb(thread, d->sample->cpumode, address, &al); + + al_to_d_al(&al, &d_al); + + d_al.is_kernel_ip = machine__kernel_ip(d->machine, address); + + sz = d_al_p->size; + memcpy(d_al_p, &d_al, min((size_t)sz, sizeof(d_al))); + d_al_p->size = sz; + + return 0; +} + static const struct perf_dlfilter_fns perf_dlfilter_fns = { .resolve_ip = dlfilter__resolve_ip, .resolve_addr = dlfilter__resolve_addr, .args = dlfilter__args, + .resolve_address = dlfilter__resolve_address, }; static char *find_dlfilter(const char *file) diff --git a/tools/perf/util/perf_dlfilter.h b/tools/perf/util/perf_dlfilter.h index 35e03aa41a7f..dfd0f8482824 100644 --- a/tools/perf/util/perf_dlfilter.h +++ b/tools/perf/util/perf_dlfilter.h @@ -92,8 +92,13 @@ struct perf_dlfilter_fns { const struct perf_dlfilter_al *(*resolve_addr)(void *ctx); /* Return arguments from --dlarg option */ char **(*args)(void *ctx, int *dlargc); + /* + * Return information about address (al->size must be set before + * calling). Returns 0 on success, -1 otherwise. + */ + __s32 (*resolve_address)(void *ctx, __u64 address, struct perf_dlfilter_al *al); /* Reserved */ - void *(*reserved[125])(void *); + void *(*reserved[124])(void *); }; /* -- 2.17.1