Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13474508ybl; Sun, 29 Dec 2019 12:47:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwBEQncnba5EEJDomJISoT/ragaDuVs/cjUCmk5pB3wXRpMoG2exXn7V+zzDazo1FlxG0rC X-Received: by 2002:a05:6830:151a:: with SMTP id k26mr52799439otp.74.1577652437383; Sun, 29 Dec 2019 12:47:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652437; cv=none; d=google.com; s=arc-20160816; b=Kd39uy58h6E+3IpnLPI4i3qY7nXXeOLTsA7+vhaUJM1Td/MXYdpjORLmgG7qvcZO6Z bz6yNq9TFvbkytTAvPaWOnY2Z3/SfKer7qhndTdOH5ywQvk1YiQ4c/+lHlDZLZucoEhQ BI82JPzFVtXFokNOgIVbePhzwOLO79XEcTLZTG/trwvkrlem8T4r7/k6iflyFCIx+8pk E1xOi+GkdDD+m8bNdp6QR5ypGOL4vBHvQJkJ3feYJSRRhOh/WV/cC69S4hgxre7y2OJ3 XR8L/BoE0Ar8HK53RJ3Q/v6wVBQ6zAGCJG1FT4Ext9vpGe/9LIJ44/o3heawFLVJR9he R0iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fsh48zCu8x3eB71Yt3qOn/0/LsfafcoXrqdxbZS2RAM=; b=oS2J31akpgzqpf3+Zm8e//5pOIuhuJdNTBgDHDpVvVeeuRjrMR5cg3lfIudepHFPLI 3sHG8JSFuCalSfXzxh42CtRg7Jx1byy+hIicj5tG0+T6AG3lIkDdwSZ9aK9/udi4NMgk RRjDGq8gjduk2j6DR0SksKwEjSQbMCss2iKF+0GcFtdaZMGpDrXQvZ8gy5CZUEOjTsoY yU3WxiPbQFtyEwjWH8qcS+3LJmzIX/NE/ehk4Dzkv1so0lJXQXViMyy7OSuaWTlr3U6u +915k8jmgQMjTNOyQf30subsOCSpx7dBQFvs90K4jr4oZiUzZxe0hscE9EE4PgCX4i8n axqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="G/qJeZwG"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si26340550otg.248.2019.12.29.12.47.06; Sun, 29 Dec 2019 12:47:17 -0800 (PST) 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; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="G/qJeZwG"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731785AbfL2Rv0 (ORCPT + 99 others); Sun, 29 Dec 2019 12:51:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:36666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732072AbfL2RvY (ORCPT ); Sun, 29 Dec 2019 12:51:24 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC59920718; Sun, 29 Dec 2019 17:51:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641883; bh=vwhE9Lb82quyMJwQCSJAsu3MVGD0hjqpeFiWyHf1JvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G/qJeZwGfx/0YjGbq/H9L802+sT6FhNjf15grShWiCtAQQoyf3V0dgpgBmY6JAgMN TodghggUZqaxbPpwEBQY3PA5UcDJHmW5aNDGgRvqir43ycaQJL2kLAg7tQAWqwZIeD 9I28VekhTv4jhOtM2+K5sLGKWTgS9vTXZJFlaDPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Masami Hiramatsu , Jiri Olsa , Namhyung Kim , Sasha Levin Subject: [PATCH 5.4 252/434] perf probe: Fix to probe a function which has no entry pc Date: Sun, 29 Dec 2019 18:25:05 +0100 Message-Id: <20191229172718.657510315@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit 5d16dbcc311d91267ddb45c6da4f187be320ecee ] Fix 'perf probe' to probe a function which has no entry pc or low pc but only has ranges attribute. probe_point_search_cb() uses dwarf_entrypc() to get the probe address, but that doesn't work for the function DIE which has only ranges attribute. Use die_entrypc() instead. Without this fix: # perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0 Probe point 'clear_tasks_mm_cpumask' not found. Error: Failed to add events. With this: # perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0 Committer testing: Before: [root@quaco ~]# perf probe clear_tasks_mm_cpumask:0 Probe point 'clear_tasks_mm_cpumask' not found. Error: Failed to add events. [root@quaco ~]# After: [root@quaco ~]# perf probe clear_tasks_mm_cpumask:0 Added new event: probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask) You can now use it in all perf tools, such as: perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1 [root@quaco ~]# Using it with 'perf trace': [root@quaco ~]# perf trace -e probe:clear_tasks_mm_cpumask Doesn't seem to be used in x86_64: $ find . -name "*.c" | xargs grep clear_tasks_mm_cpumask ./kernel/cpu.c: * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU ./kernel/cpu.c:void clear_tasks_mm_cpumask(int cpu) ./arch/xtensa/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/csky/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/sh/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/arm/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/powerpc/mm/nohash/mmu_context.c: clear_tasks_mm_cpumask(cpu); $ find . -name "*.h" | xargs grep clear_tasks_mm_cpumask ./include/linux/cpu.h:void clear_tasks_mm_cpumask(int cpu); $ find . -name "*.S" | xargs grep clear_tasks_mm_cpumask $ Fixes: e1ecbbc3fa83 ("perf probe: Fix to handle optimized not-inlined functions") Reported-by: Arnaldo Carvalho de Melo Tested-by: Arnaldo Carvalho de Melo Signed-off-by: Masami Hiramatsu Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lore.kernel.org/lkml/157199319438.8075.4695576954550638618.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 7857ae7a10b7..4079ed617f53 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -994,7 +994,7 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data) param->retval = find_probe_point_by_line(pf); } else if (die_is_func_instance(sp_die)) { /* Instances always have the entry address */ - dwarf_entrypc(sp_die, &pf->addr); + die_entrypc(sp_die, &pf->addr); /* But in some case the entry address is 0 */ if (pf->addr == 0) { pr_debug("%s has no entry PC. Skipped\n", -- 2.20.1