Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp524559ybx; Wed, 30 Oct 2019 00:10:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqysaf6f2+NL5t5g0hDqXc7yKRwtg+FTpu3pdRgOckPHxt/pe1oORa87zbYsG8eVpfSLrTX5 X-Received: by 2002:a50:b685:: with SMTP id d5mr30510870ede.276.1572419448850; Wed, 30 Oct 2019 00:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572419448; cv=none; d=google.com; s=arc-20160816; b=us1BUPTcD4zZXU9nePXkO9n1mMv6A8o6kal4qgzo5WvOmCW7I0wOeCWads73+UjSdH 6e8QKjPDPMOWWFvTqNrfFK3chQXR12lV+mEaAZwTSGnJ03jyEE3pdxtueZskSqm9HpRo Uk5FOiEeCJNjDUuwKsonAsTK8By/EKkwLvlcVWFhferLUkc2kedkjcqU0lxmnxROD8no tChfwuaTTcrUXmCPFjBWw387ErZvLtiZfcrgpZdFu5D3PH4xacE0a5xptZsKqw/mG+0k pUznJJpEwowDpRZKT/1qga2rcPAUuQn0PMsoHKF0FC7XAUINqsKGHQBAuQvoIKaT0RKw kZ5Q== 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=5x60PrLsh+1KK+wL8LZe6ypYbxkh55RXB7oPGGDvyHw=; b=z3KEyYdwui9A6obxCazsdgZzT9EK6gp1EARQbP8lBsFYkLBgXD3JXsZqe5sqAGZTd9 alQFjp4SDS3b4BuqrG6QapeKvbuVHsc23IqS2MQ7wrwvG5uI05J1fMkqbZwjNkh55VER cT1+dbFK7NZga8tku0dNpWrllNcYfM0L3cEueJNLtHMjGzeuX5cx3FUuJQKMaEqIm/O/ UzZkufVqifZN1FXDese7lCFQrAdga2JZ46pVnTFxYw+nxgOegno+cOZQTh7jpAFRJ2zw WdqgchHlLJ9MSiMMQZNvOue2ZvQszmw7DG5QfmQBuaO1+53NQpM857oDJokSzU7pEJn/ +Flg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vGbowppJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si1093662eda.131.2019.10.30.00.10.24; Wed, 30 Oct 2019 00:10:48 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vGbowppJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbfJ3HJ0 (ORCPT + 99 others); Wed, 30 Oct 2019 03:09:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:43092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbfJ3HJ0 (ORCPT ); Wed, 30 Oct 2019 03:09:26 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D110120874; Wed, 30 Oct 2019 07:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572419365; bh=XMwWjvlfkKHHww7Ks8HvSGOaLb6jeQzakvfWivfDqbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vGbowppJBlrf5Mz3oIW/SFlp0lELV3rDYmiG0P/47b9clc18RTQFatBCQoXQAYIiS +oKjl/hUJOh6zmueTDLux8xgnfhXixwI2SUG0H+3+iRlsxHNJqd1wzky+cVwO9tZ1g 5nTsePIcK488DioKMu5pNKhzCLeTOvZGACLQb38I= From: Masami Hiramatsu To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Masami Hiramatsu , linux-kernel@vger.kernel.org Subject: [BUGFIX PATCH 1/4] perf probe: Skip end-of-sequence and non statement lines Date: Wed, 30 Oct 2019 16:09:21 +0900 Message-Id: <157241936090.32002.12156347518596111660.stgit@devnote2> X-Mailer: git-send-email 2.20.1 In-Reply-To: <157241935028.32002.10228194508152968737.stgit@devnote2> References: <157241935028.32002.10228194508152968737.stgit@devnote2> User-Agent: StGit/0.17.1-dirty 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 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. Fixes: 4cc9cec636e7 ("perf probe: Introduce lines walker interface") Signed-off-by: Masami Hiramatsu --- 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 ac82fd937e4b..f31001d13bfb 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -782,6 +782,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) { @@ -812,6 +813,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) { /*