Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3123205pxf; Mon, 15 Mar 2021 01:50:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEIgR+T5ND1j9bNTrO4bGPoiw0ZiqO7WHHMafjqYzcUzYt7DPxS2oTmTuVs0Aq1+b2yx7X X-Received: by 2002:aa7:c353:: with SMTP id j19mr28497927edr.263.1615798258852; Mon, 15 Mar 2021 01:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615798258; cv=none; d=google.com; s=arc-20160816; b=uyhmn4WFH9mvy6oEOCHwgh+Jutjo8pXMZTa9NPJkGjTCId4zupRNYc6VOXnbgAJody L9TSlZKhhJKEgIx8JFvE568QbIcsqhAR2zqa0caOz4mbMMZ3pjUdR8m0NuONzRN2sbRR eLQGtMDCGxHwm6RxvJJlXkKLCegU5bDXxFCGRlWkUKZ3m+lwulH9CEJ3SICDcDfR2yht mRp7kk9V7D0BjV/V8Ik+V6JCuFeGH95g7RBlURbcO0y7L1PngrD0JtHJJ48CQw0+GrN5 AnkFmOkUPy+7Rdq2d6bbUieP9epEF4AoWJPd0ryMxuQVCYRKE95j95GKdwGgEuGwDBON kWRg== 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=KrAT1fOYzswhsNRApYdzOo5RU3MoW4uoEPoA1CvSEzc=; b=T92AUuMdLIRkyLW5WTIarqmKYLxWOWDvQWEsq9dvWma2/8u63HI25qnyjLkkTSrX7y Ui1BasiGy3BjBr0XGODPytG5LY6Hh9hqrl/b2cMR8fg+DWPjesglNYz2f3pj4bivnIMh /sPUn6LwRC6FY4QG1hysMJFUmPau5nNRWscvlVRsKtL1r7Ip+1Bh1nJ4hKdNZyrLWP/I S5WFbxeicsKDyBMmxuLtduCWkbOpEsgy3HMA7Gkc1DDRU0VeJj2D2J33PfpGNNcBsBy6 XjmAhc5tM3N9awktVe8SQwtzwO/UAbh+SNKRXoVq9cECaETVSCcTzj1BLL6nBKqq/5Zv mOQQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x12si9908995edd.423.2021.03.15.01.50.36; Mon, 15 Mar 2021 01:50:58 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229532AbhCOIrj (ORCPT + 99 others); Mon, 15 Mar 2021 04:47:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:13536 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhCOIrY (ORCPT ); Mon, 15 Mar 2021 04:47:24 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DzVNS5jQ9zNn8j; Mon, 15 Mar 2021 16:44:56 +0800 (CST) Received: from [10.67.102.248] (10.67.102.248) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Mon, 15 Mar 2021 16:47:12 +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: Mon, 15 Mar 2021 16:47:11 +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 Hi, 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. > > Jin Yao, what do you think? > > Thanks, > Namhyung > Is it changed to the following? --- 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); } } } @@ -619,6 +612,12 @@ int cmd_annotate(int argc, const char **argv) setup_browser(true); + /* + * 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 ((use_browser == 1 || annotate.use_stdio2) && annotate.has_br_stack) { sort__mode = SORT_MODE__BRANCH; if (setup_sorting(annotate.session->evlist) < 0) I think branch stack mode also don't care about the processes. >> --- >> 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 >> > . >