Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17940344ybl; Thu, 2 Jan 2020 15:13:20 -0800 (PST) X-Google-Smtp-Source: APXvYqz9p/+NTDwFRfroBo5a/aHhJJLjNsyktBAUPnwCKeGhgPNArlRdv8+hP0xd977H37WfG/kd X-Received: by 2002:a05:6830:10a:: with SMTP id i10mr90399720otp.365.1578006800150; Thu, 02 Jan 2020 15:13:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006800; cv=none; d=google.com; s=arc-20160816; b=i9mEif9tSvI0vy5CVO18nmL3o7v5aNPFotX4F5VVlj8jNXJvX/dbZxVo+7PTUA/neX rH5ym2tYYqJTRM1kMQheDmf9666OoyZ7qPa69XljkxAM1qVjcf7i0zlAzUdSzJd/6kOJ KFcKK88VpHAFMkxq5x+50vTrX3gxEa/JdLxxNP0bk4GlBG9kI5Ki+llQyOd8igUE4RyF gboJdYsKn64BVvSSEzXyCyCjZemNOcPnUqfrBDPEktFobCNSf8ZRQFNJGfQrOoaaof85 hr5lJpWIPXJaslsCOQhe8rOUhQYY0bka/UT/gwb2yExMN/Chyv0YP98feSqC01MVef/k ajdg== 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=CZy56xqbYyzIRu1cZa5vDS7pLzxklOoDACeibCrw+D0=; b=u8+JPUrD9xktbnUAcpNw9UPTW1KYp9mCtvM3+J7WBuqIEgzvbgIsPXUnTHmxcRchdr lNfdxJk6ElmykeUiCS789lhNmcmKjBINXy7OBJu68rCzCXMrzFCdES80tBizCKprijrK Qs1pvlxcWrR1RyMC8uPS50oABI9q1w6+DlUF+HveGRMFjCqJNg5K+i9uswEPalLT1Xh1 67tIoXCPTceaZekVGFm/CuCiVX8NQFhk9qX330b0u+pYXYPyhpkWAcuDzuKLahv6QQID z1gwPCRnu50adDmhal6NQl2JT4pfuPYq/B+yqSW9YOaXt0aJkGELCFy3Be6pNZ+Vs2vx tD2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vX7oYh4x; 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 p21si20400835otk.162.2020.01.02.15.13.08; Thu, 02 Jan 2020 15:13:20 -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=vX7oYh4x; 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 S1730708AbgABWrp (ORCPT + 99 others); Thu, 2 Jan 2020 17:47:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:60000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729706AbgABW3O (ORCPT ); Thu, 2 Jan 2020 17:29:14 -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 5111122525; Thu, 2 Jan 2020 22:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004152; bh=0q0liihG/rS2VbIemaU/lIs9XpyflQYud4IQ5oZsDHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vX7oYh4x/y2MSyuLvkhwINW92f0VgviREeYELIzZQe68eCQdvl9ysP9745EHy2jHl U/jpaTxxglxdoU1LW3dWN/7uCi+kITzjCCO7txcSmKptiZk4rVcKoYKaEaq3r3JI3v AINlCACrhKOq/2IViZ60l4rKs//nsXucYB0ubZr4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Sasha Levin Subject: [PATCH 4.9 060/171] perf probe: Skip end-of-sequence and non statement lines Date: Thu, 2 Jan 2020 23:06:31 +0100 Message-Id: <20200102220555.227215580@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.960200039@linuxfoundation.org> References: <20200102220546.960200039@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 f4d99bdfd124823a81878b44b5e8750b97f73902 ] Skip end-of-sequence and non-statement lines while walking through lines list. The "end-of-sequence" line information means: "the current address is that of the first byte after the end of a sequence of target machine instructions." (DWARF version 4 spec 6.2.2) This actually means out of scope and we can not probe on it. On the other hand, the statement lines (is_stmt) means: "the current instruction is a recommended breakpoint location. A recommended breakpoint location is intended to “represent” a line, a statement and/or a semantically distinct subpart of a statement." (DWARF version 4 spec 6.2.2) So, non-statement line info also should be skipped. These can reduce unneeded probe points and also avoid an error. E.g. without this patch: # perf probe -a "clear_tasks_mm_cpumask:1" Added new events: probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1) probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:1) probe:clear_tasks_mm_cpumask_2 (on clear_tasks_mm_cpumask:1) probe:clear_tasks_mm_cpumask_3 (on clear_tasks_mm_cpumask:1) probe:clear_tasks_mm_cpumask_4 (on clear_tasks_mm_cpumask:1) You can now use it in all perf tools, such as: perf record -e probe:clear_tasks_mm_cpumask_4 -aR sleep 1 # This puts 5 probes on one line, but acutally it's not inlined function. This is because there are many non statement instructions at the function prologue. With this patch: # perf probe -a "clear_tasks_mm_cpumask:1" Added new event: probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1) You can now use it in all perf tools, such as: perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1 # Now perf-probe skips unneeded addresses. Committer testing: Slightly different results, but similar: Before: # uname -a Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux # # perf probe -a "clear_tasks_mm_cpumask:1" Added new events: probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1) probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:1) probe:clear_tasks_mm_cpumask_2 (on clear_tasks_mm_cpumask:1) You can now use it in all perf tools, such as: perf record -e probe:clear_tasks_mm_cpumask_2 -aR sleep 1 # After: # perf probe -a "clear_tasks_mm_cpumask:1" Added new event: probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1) You can now use it in all perf tools, such as: perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1 # perf probe -l probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c) # Fixes: 4cc9cec636e7 ("perf probe: Introduce lines walker interface") Signed-off-by: Masami Hiramatsu Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lore.kernel.org/lkml/157241936090.32002.12156347518596111660.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/dwarf-aux.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 41bfb4c977d0..7eec3ae7b3c5 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -770,6 +770,7 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data) int decl = 0, inl; Dwarf_Die die_mem, *cu_die; size_t nlines, i; + bool flag; /* Get the CU die */ if (dwarf_tag(rt_die) != DW_TAG_compile_unit) { @@ -800,6 +801,12 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data) "Possible error in debuginfo.\n"); continue; } + /* Skip end-of-sequence */ + if (dwarf_lineendsequence(line, &flag) != 0 || flag) + continue; + /* Skip Non statement line-info */ + if (dwarf_linebeginstatement(line, &flag) != 0 || !flag) + continue; /* Filter lines based on address */ if (rt_die != cu_die) { /* -- 2.20.1