From patchwork Wed Sep 23 11:22:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 54045 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 6FDB922E14 for ; Wed, 23 Sep 2015 11:26:46 +0000 (UTC) Received: by lamf6 with SMTP id f6sf21786751lam.1 for ; Wed, 23 Sep 2015 04:26:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=yCJuIJ4hY7+9CyNk/nyrzZpzl96508LHn4UjG2j0fFs=; b=jpbPk/AVuegA/yV6QLBvWdBE+NDPr6OGy2G4bcGREMwAoAo0GrNZ2lzp28rJRXfv3k qGhCtyl7+0YWJhp+Mk3bVX2jCiFhc6BtMg3FaBkqI/llhngrq/LOVyIcLqVPb16upPxM MQfzAhPaudNxYPhQgpQSRKaxueFEemmdTrVPU9g5+5enSgJ0RLsiXbA+lkPDPX1m5DAG DwARaei++ucgKyTN6FDlYMFcmGFKFDpD06oJmVH4oMZ0L9U/QROpO3hLj5e88Wal+PQ0 j/pnJmis67DCDO7gAyZ+veVfpfSwmT5rXVhUPSXKJcNdgKpODGTPlVlcgYVhlJxPGxjA bD0A== X-Gm-Message-State: ALoCoQlCyg5sQCBQtRjaG6YErUaobWJ2iQBip2OKKmZ51wGg74WOihwi4Gd0eitxdngcRgE/Tp58 X-Received: by 10.112.132.6 with SMTP id oq6mr5123003lbb.1.1443007605342; Wed, 23 Sep 2015 04:26:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.206.211 with SMTP id e202ls105033lfg.109.gmail; Wed, 23 Sep 2015 04:26:45 -0700 (PDT) X-Received: by 10.112.199.70 with SMTP id ji6mr11382388lbc.73.1443007605041; Wed, 23 Sep 2015 04:26:45 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id ug6si1653241lbb.19.2015.09.23.04.26.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2015 04:26:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lacao8 with SMTP id ao8so23203990lac.3 for ; Wed, 23 Sep 2015 04:26:44 -0700 (PDT) X-Received: by 10.152.161.232 with SMTP id xv8mr11614850lab.32.1443007604896; Wed, 23 Sep 2015 04:26:44 -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.59.35 with SMTP id w3csp1044727lbq; Wed, 23 Sep 2015 04:26:43 -0700 (PDT) X-Received: by 10.66.251.35 with SMTP id zh3mr29100354pac.121.1443007603755; Wed, 23 Sep 2015 04:26:43 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si9950488pbq.44.2015.09.23.04.26.43; Wed, 23 Sep 2015 04:26:43 -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 S1754723AbbIWL02 (ORCPT + 30 others); Wed, 23 Sep 2015 07:26:28 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:57545 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754362AbbIWLXq (ORCPT ); Wed, 23 Sep 2015 07:23:46 -0400 Received: from 172.24.1.51 (EHLO szxeml426-hub.china.huawei.com) ([172.24.1.51]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CVR40146; Wed, 23 Sep 2015 19:23:27 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.235.1; Wed, 23 Sep 2015 19:23:16 +0800 From: Wang Nan To: CC: , , Wang Nan , Namhyung Kim , Jiri Olsa , Masami Hiramatsu Subject: [PATCH 22/22] perf probe: Fix module probing with shortname Date: Wed, 23 Sep 2015 11:22:43 +0000 Message-ID: <1443007363-124182-23-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1443007363-124182-1-git-send-email-wangnan0@huawei.com> References: <1443007363-124182-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected 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: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 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: , After commit 3d39ac538629e4f00a6e1c38d46346f1b8e69505 ("perf machine: No need to have two DSOs lists"), perf probe with module short name doesn't work again. For example: # lsmod | grep e1000e e1000e 233472 0 # cat /proc/modules | grep e1000e e1000e 233472 0 - Live 0xffffffffa0073000 # cat /proc/kallsyms | grep '\' ffffffffa0093860 t e1000e_up[e1000e] # perf probe -v -m e1000e --add e1000e_up probe-definition(0): e1000e_up symbol:e1000e_up file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments Failed to find module e1000e. Could not open debuginfo. Try to use symbols. Looking at the vmlinux_path (7 entries long) Using /lib/modules/4.2.0-rc7+/build/vmlinux for symbols e1000e_up is out of .text, skip it. Error: Failed to add events. Reason: No such file or directory (Code: -2) This is caused by a misunderstood of dso->kernel in kernel_get_module_dso() that, for kernel module, dso->kernel is DSO_TYPE_USER. dso->kernel is DSO_TYPE_KERNEL iff dso is vmlinux. This patch fix 'perf probe -m' with an ad-hoc way. After this patch: # perf probe -v -m e1000e --add e1000e_up probe-definition(0): e1000e_up symbol:e1000e_up file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments Open Debuginfo file: /lib/modules/4.2.0-rc7+/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko Try to find probe point from debuginfo. Matched function: e1000e_up Probe point found: e1000e_up+0 Found 1 probe_trace_events. Opening /sys/kernel/debug/tracing//kprobe_events write=1 Writing event: p:probe/e1000e_up e1000e:e1000e_up+0 Added new event: probe:e1000e_up (on e1000e_up in e1000e) You can now use it in all perf tools, such as: perf record -e probe:e1000e_up -aR sleep 1 # perf probe -l Failed to find debug information for address ffffffffa0093860 probe:e1000e_up (on e1000e_up in e1000e) Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Namhyung Kim Cc: Jiri Olsa Cc: Masami Hiramatsu Link: http://lkml.kernel.org/n/ebpf-6yw9eg0ej3l4jnqhinngkw86@git.kernel.org --- tools/perf/util/probe-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 2b78e8f..c7d6d3d 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -270,7 +270,7 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso) if (module) { list_for_each_entry(dso, &host_machine->dsos.head, node) { - if (!dso->kernel) + if (dso->kernel) continue; if (strncmp(dso->short_name + 1, module, dso->short_name_len - 2) == 0)