Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1399698ybh; Fri, 13 Mar 2020 00:13:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs3hblo6WiMkeVPUT17yq+yONvJxbWlkoBWszb6fk229FN6XPIADI3b3UTGn8uaDQCjDkl+ X-Received: by 2002:a05:6830:15d3:: with SMTP id j19mr9761494otr.51.1584083581973; Fri, 13 Mar 2020 00:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584083581; cv=none; d=google.com; s=arc-20160816; b=DfaU5kJiGuYrOZ5+jLLO4sYjjugkoE4rS08j1PZkALFPCPRxHNDZFJ0keAsE+L0vol eJIIHyqclSOZSqS7PHYkatsRuAVOo9BmTDS6XLvOF1Wcrdq7UmgmpRAqcotXXyapwXvJ soHNoT7Ojr7JUOfgNG+xlGErgUHiQcx1Xc14CiYukuGvYLOjnlf2JoX1CLgos+zCWQJA GlIbZFCUbvJ8nPA/msg8Ljef80cezJcvmvXI5IMZVes2/eXXpM0AmRvl4AJoc2kN/kvj tfja0cDNSsyVA/xSXn8KHAHf+i/6ODkr9FoAZzWZWs/lgC2m61ASk7kxhlxc5YmQ/zCR p50w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=fCjvC6r4ZkH1wkFf8nspCrHKUtA9FUFY/duIZUJj4Fo=; b=sXDU8+eoQXsU8yM8C4SdMqhXES0EdQU3xT6kGMIFEPpQibPFTpHUOf1rk+2cScD/Hy mHCTLth65hnJ1LQp7EFcHDKJ4+k6Py2gCoH7jw+IHd2SAusRSN4FRbBWurHrGN2Z6EcR IwaEXYJvRAcaVXF2VZ0gKHa2uvgsrytrnUl4YyLvIYkQFLCI9Wj8MRH6caRWcefuIA70 tMxQ/hqjZjSgbf0eHqwXNLNnbol+AVnqoR9f+LanfVR8s6Xb1h8Qv44x0/zHNATZTRxy UuGVCNDscn3tUwtqXOg5pPWo3ETT2k5zAYiJhVs6TWV+7vVf+RWAZA6gjxZRnEXH7QN9 4omw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9si4496376oia.47.2020.03.13.00.12.49; Fri, 13 Mar 2020 00:13:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbgCMHMS (ORCPT + 99 others); Fri, 13 Mar 2020 03:12:18 -0400 Received: from mga02.intel.com ([134.134.136.20]:7824 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726682AbgCMHMR (ORCPT ); Fri, 13 Mar 2020 03:12:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2020 00:12:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,547,1574150400"; d="scan'208";a="266642296" Received: from kbl.sh.intel.com ([10.239.159.24]) by fmsmga004.fm.intel.com with ESMTP; 13 Mar 2020 00:12:14 -0700 From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, Jin Yao Subject: [PATCH v2 10/14] perf util: Enable block source line comparison Date: Fri, 13 Mar 2020 15:11:14 +0800 Message-Id: <20200313071118.11983-11-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200313071118.11983-1-yao.jin@linux.intel.com> References: <20200313071118.11983-1-yao.jin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously we only supported address comparison, but it was not good for the case that address might be changed if source code was updated. This patch enables for the source line comparison. 1. If all of the source lines in a block are not changed (or only moved some offsets as a whole), we think the block is not changed. 2. If we can aware any source line in this block is changed, we think this block is changed. 3. If 1 and 2 are both not matched, fallback to address comparison. Signed-off-by: Jin Yao --- tools/perf/util/block-info.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/block-info.c b/tools/perf/util/block-info.c index 96b7b81cabd5..4d0275fbd0df 100644 --- a/tools/perf/util/block-info.c +++ b/tools/perf/util/block-info.c @@ -93,11 +93,12 @@ struct block_info *block_info__new(void) } int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right, - struct srclist *src_list __maybe_unused) + struct srclist *src_list) { struct block_info *bi_l = left->block_info; struct block_info *bi_r = right->block_info; int cmp; + bool changed; if (!bi_l->sym || !bi_r->sym) { if (!bi_l->sym && !bi_r->sym) @@ -112,6 +113,27 @@ int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right, if (cmp) return cmp; + if (src_list && bi_l->line && bi_r->line) { + if (block_same_srcfiles(bi_l->line, bi_r->line) && + bi_l->line->start_rel) { + + if (block_srclist_matched(src_list, + bi_l->line->start_rel, + bi_l->line->start_nr, + bi_l->line->end_nr, + bi_r->line->start_nr, + bi_r->line->end_nr, + &changed)) { + bi_l->srcline_matched = true; + return 0; + } else if (changed) { + bi_l->block_changed = true; + return 0; + } else + return -1; + } + } + if (bi_l->start != bi_r->start) return (int64_t)(bi_r->start - bi_l->start); -- 2.17.1