Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13401906ybl; Sun, 29 Dec 2019 11:02:15 -0800 (PST) X-Google-Smtp-Source: APXvYqx3SbIQEE0i3wH7B5J+ykSc/VmKPJRBtSgUASw6ri6vt0RA7krYdAWeks1UEAXuwtjUvhji X-Received: by 2002:a05:6830:1608:: with SMTP id g8mr66205903otr.169.1577646135221; Sun, 29 Dec 2019 11:02:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577646135; cv=none; d=google.com; s=arc-20160816; b=uE8bHYjsfOqkdjfaEXukiCMMJvDeieJJdl9oJzdM/F5TLW+pfPgDkxTT/dqGSjdMve idBHERnu42jYXHwOrfCD3RW1j92jBLhNmXuIiRdWeBOI1RppJzZdCKJbR2ydFMb0b1op bvd0AyXbd+vIFd9FKWOsd7bm8KQlFPpMg5idKYKO7DR+yX0g086Xlo3D6iu+05FFO/Fq 9rUPB7V5yhNc7hZN3QEwzSFaNw/NPUFbkQ6udGOqHbmIpuukfT1Xo2yyQ+AUjRIKyVzF ffN/PdeMqFwGejejECU4yfr+CeDG+iZiB59R0E3e8CiYCrt08kM8C3nI3rItKnxGUmqF YF2w== 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=mU61ugkUM12XDaLT7z71ZwW0NXzqD5bkHhV61w48sl0=; b=HyQGZQK27N7PbcATs4VqrpU1vbmn06AZfHlzTeVck+GCW2u7NsgGMkbEt+JuxQ4etr aLH/TNPp7lOAdCKFt4jgqlPHOfsHIxTDIV6NJQjFp7S20dMDTJYjTTvcw/RACAuuG5vI AzaxeQsST5QExOUrjgVUUZZME8Iuf8frfZzHCJ1umOJK3wumvPwV8lU4Xos5qatyn6Nl Jlj4vFA/o2f9nj10PLV4amYHcsftmHGxa3LTQDbenL2XejxueScas9sHizu7sHHuLLlN +Ez24eO4ieUJVDkNvUaYi+56jn7IYX8/9bV0gCkIUURF71bDBF9ebbq+otzJuOhp4A4u h05w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Nny48fn2; 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 q126si19891413oia.8.2019.12.29.11.02.03; Sun, 29 Dec 2019 11:02:15 -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=Nny48fn2; 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 S1727169AbfL2RZN (ORCPT + 99 others); Sun, 29 Dec 2019 12:25:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:44714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727168AbfL2RZL (ORCPT ); Sun, 29 Dec 2019 12:25:11 -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 41DD521744; Sun, 29 Dec 2019 17:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640310; bh=hCqjKv4rt0Sl6CUHUt0sISqRLv1CwQ+3nWjUB7KQUxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nny48fn2BCoyK3vULJL6ccqR9Ku+b0/FQiQg0fncBwQgh3q6MaSvn9QIuKmTp8a8R OsPXGQX6U3hft6goHwUbAyTtU1f12SOIyfzUSsHHGe2qW0yLj08D+YDhspGp60s0Vm TiANU3dPW6HffIQpXGacwGwrtVydzyIEpdvYKWzk= 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.14 105/161] perf probe: Skip end-of-sequence and non statement lines Date: Sun, 29 Dec 2019 18:19:13 +0100 Message-Id: <20191229162428.598950715@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@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 49f9c65f1a9c..d48bd5eaa0f2 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -773,6 +773,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) { @@ -803,6 +804,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