Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4040065pxf; Tue, 16 Mar 2021 04:24:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPZrs4ItMDR06/6Smujb6PwJuQw5UwPPI1ROikxM1M3McbFH1LgOLuxUOf0+4VYKcV64GL X-Received: by 2002:a17:906:130c:: with SMTP id w12mr28914796ejb.253.1615893861722; Tue, 16 Mar 2021 04:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615893861; cv=none; d=google.com; s=arc-20160816; b=VKUvZ2PCsQXIKLrZ6lyq6zP0xnenk77HTXk0g16cDTAsd1pvSKZeUNNoXiDr2PLFsd h2J5nI76Zl0kgSic0dFuZT7L+pD3wtCRpvhQdrEPYXXZdz5wRI87Nddocf0gIxzZhw+w RJ+pX7Hm6XIQYKIV8A/s9hJ0PpDSknalzmk/LsLRRXkS0e96tOJKM8Y15g5FzY7muXOB cJ3lM6nH7YaQPcn+rUJ2mcAjS/2dFVP95NpaFHpzT1tIED08L1hd0nAai7urbq0gS1df pRSNYCnsoZSy9ibbWqpUfhnnYneIGhsYhVT+GgTRaSN7R+2b+oUNqJsP+5PaWXYU6mJ8 ASIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=zteMBpFtqSLxhKRTU2jn1nj0+N1KiF+UlfdwBvDfNSU=; b=j6GmB18lQoqGssAJXGzDOGzo3U3UAU1DX9qq04pK7+8D/kPvtolarDLh9ZzqfFwPRe iTzNFNHv3nqfcqEhsUyhl+6AkZIXSzJhzSE2Ne4bZEuOB/u2iY8agaNJAcL48ULtxjSx 7RUnA0S/Z3JGCuYVsbyV8VC/XE/RtOKJgeR+NqnkE+0f10JPRyu4cVwxbnTuLaI9USSB nMkP9SAlGMOU1N4CeABE+jW49d2NBo9p0vyIQcw4bacGCYvAWfUkaKJ0KMkPuko3jJeP GEAsPHbaAVPUaRKiOuWdtkNfH+5qvHE/m5LQ5yFqKT4fvAhndCQF5Mj94mZgWommXavp eZpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si10852891edy.444.2021.03.16.04.23.56; Tue, 16 Mar 2021 04:24:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232760AbhCPCvk (ORCPT + 99 others); Mon, 15 Mar 2021 22:51:40 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13173 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbhCPCvg (ORCPT ); Mon, 15 Mar 2021 22:51:36 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DzyRV4HLyzmXjH; Tue, 16 Mar 2021 10:49:10 +0800 (CST) Received: from [10.67.102.248] (10.67.102.248) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 10:51:25 +0800 Subject: Re: [PATCH v4] perf annotate: Fix sample events lost in stdio mode To: Namhyung Kim , Yao Jin CC: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , , , linux-kernel , References: <20210313021540.219748-1-yangjihong1@huawei.com> From: Yang Jihong Message-ID: Date: Tue, 16 Mar 2021 10:51:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.248] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 2021/3/13 11:06, Namhyung Kim wrote: > On Sat, Mar 13, 2021 at 11:16 AM Yang Jihong wrote: >> >> In hist__find_annotations function, since different hist_entry may point to same >> symbol, we free notes->src to signal already processed this symbol in stdio mode; >> when annotate, entry will skipped if notes->src is NULL to avoid repeated output. >> >> However, there is a problem, for example, run the following command: >> >> # perf record -e branch-misses -e branch-instructions -a sleep 1 >> >> perf.data file contains different types of sample event. >> >> If the same IP sample event exists in branch-misses and branch-instructions, >> this event uses the same symbol. When annotate branch-misses events, notes->src >> corresponding to this event is set to null, as a result, when annotate >> branch-instructions events, this event is skipped and no annotate is output. >> >> Solution of this patch is to remove zfree in hists__find_annotations and >> change sort order to "dso,symbol" to avoid duplicate output when different >> processes correspond to the same symbol. > > Looks good. But I'm not sure about the branch stack mode. > I suspect we can use the same sort key there. > I've submitted the v5 patch which uses same sort key in branch stack mode, look forward to your review: https://lore.kernel.org/patchwork/patch/1396841/ Thanks, Yang. > Jin Yao, what do you think? > > Thanks, > Namhyung > >> --- >> tools/perf/builtin-annotate.c | 13 ++++++------- >> 1 file changed, 6 insertions(+), 7 deletions(-) >> >> diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c >> index a23ba6bb99b6..ad169e3e2e8f 100644 >> --- a/tools/perf/builtin-annotate.c >> +++ b/tools/perf/builtin-annotate.c >> @@ -374,13 +374,6 @@ static void hists__find_annotations(struct hists *hists, >> } else { >> hist_entry__tty_annotate(he, evsel, ann); >> nd = rb_next(nd); >> - /* >> - * Since we have a hist_entry per IP for the same >> - * symbol, free he->ms.sym->src to signal we already >> - * processed this symbol. >> - */ >> - zfree(¬es->src->cycles_hist); >> - zfree(¬es->src); >> } >> } >> } >> @@ -624,6 +617,12 @@ int cmd_annotate(int argc, const char **argv) >> if (setup_sorting(annotate.session->evlist) < 0) >> usage_with_options(annotate_usage, options); >> } else { >> + /* >> + * Events of different processes may correspond to the same >> + * symbol, we do not care about the processes in annotate, >> + * set sort order to avoid repeated output. >> + */ >> + sort_order = "dso,symbol"; >> if (setup_sorting(NULL) < 0) >> usage_with_options(annotate_usage, options); >> } >> -- >> 2.30.GIT >> > . >