From patchwork Tue Sep 22 03:34:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 53995 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id DD5E022B1E for ; Tue, 22 Sep 2015 03:35:53 +0000 (UTC) Received: by lanb10 with SMTP id b10sf48873149lan.3 for ; Mon, 21 Sep 2015 20:35:52 -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 :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=AH9BHMCgXj80ijHahDX6MEcftdnnut10vfHIR3yivVE=; b=CZKH0WMoQ94Kihyk1n0bUaKtsAtBvMc99sngA8i2RDAbpT6RSX/s3atnLWovFIDBiL o1Tsg6fjrvv3KZVSfLilYyXdB5Ar85fRJTSxKrsbDvv6h59uDcCjiQPKnNLxw8VUHqqN vUOXPsWtoc9behAGcgd8fqUH+mNgiXwV4kkq6Th3f/zD1LfIqf8YrIiwrYIzb550xP+e eqh/HMb6fxKt8OWp+GIFXd62dHVO7mpN1b9w7GlZEpcdr6X5h607vQOyTH9mxKz8bzAZ 9Jb2Hn7DTj+BKXjWhi6MX4CJkvYapihVBmC+U9tzAK1rMaraiICMS0+7NvEDSUnW/5dy 5fGw== X-Gm-Message-State: ALoCoQml7H4cqz7ZeAUL/eXFIHH4AxH61OwFhiqY8BLm5ZCxxaEuhHhAwfuYAfz5GUwGBg4kaxPS X-Received: by 10.112.12.132 with SMTP id y4mr3827914lbb.0.1442892952062; Mon, 21 Sep 2015 20:35:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.209.80 with SMTP id i77ls38862lfg.0.gmail; Mon, 21 Sep 2015 20:35:51 -0700 (PDT) X-Received: by 10.152.44.132 with SMTP id e4mr8756991lam.3.1442892951874; Mon, 21 Sep 2015 20:35:51 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id l64si995313lfb.88.2015.09.21.20.35.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 20:35:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lagj9 with SMTP id j9so80864307lag.2 for ; Mon, 21 Sep 2015 20:35:51 -0700 (PDT) X-Received: by 10.152.161.232 with SMTP id xv8mr9087822lab.32.1442892951659; Mon, 21 Sep 2015 20:35:51 -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 w3csp241283lbq; Mon, 21 Sep 2015 20:35:50 -0700 (PDT) X-Received: by 10.68.137.202 with SMTP id qk10mr29021069pbb.30.1442892950575; Mon, 21 Sep 2015 20:35:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si42561628pas.176.2015.09.21.20.35.50; Mon, 21 Sep 2015 20:35:50 -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 S1757739AbbIVDfM (ORCPT + 30 others); Mon, 21 Sep 2015 23:35:12 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:30955 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757505AbbIVDfK (ORCPT ); Mon, 21 Sep 2015 23:35:10 -0400 Received: from 172.24.1.48 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.48]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CVO52729; Tue, 22 Sep 2015 11:34:49 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Tue, 22 Sep 2015 11:34:46 +0800 From: Wang Nan To: CC: , , , Wang Nan , Namhyung Kim , Jiri Olsa , Masami Hiramatsu Subject: [PATCH] perf probe: Fix module probing with shortname Date: Tue, 22 Sep 2015 03:34:32 +0000 Message-ID: <1442892872-33708-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 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.43 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 Acked-by: Masami Hiramatsu --- I think there may be other places where dso->kernel is misused. machine__process_kernel_mmap_event() may be one of them. If I understand correctly, 'dso->kernel && is_kernel_module(dso->long_name)' should always false theoretically. However, I don't have enough time to check whether that code really cause problem. --- 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)