Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp282836pxf; Wed, 17 Mar 2021 23:15:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRncUx4BVF+dAphgUF6hrbGzqpKwhAULBMgnFdwFWewHDK3K69R2Kl9hWHl74UCewKjoAz X-Received: by 2002:a17:906:f9cc:: with SMTP id lj12mr38465827ejb.544.1616048116962; Wed, 17 Mar 2021 23:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616048116; cv=none; d=google.com; s=arc-20160816; b=anWtktxiKR86N+GYjaSyZQ0TI+fAx22lNuWqY0OYgWQ9kY8TJvPoHLsHsaX3un8kmQ R65cDsYkJI93Lgpg1mxB1KK9dS5zs6RO3RLlQEfhahxuqxT6OORzOfGTAny5jtzqbRac bsih1Ig+encIrZzfFJDd8rQuq5rEpcPrqxO5TN3wrO21t5ZLHHAB0Ugp5EwTkk/XwlMC XelEjl45pDRmc227WtxuheZkrUJc8A4UJiimXnYj58sUrqZoRVXcSQwyen2azjILCB57 M0k84rBsqiOeHyXv8+f2owPZ5PNm7Yy7f6OHf665TDDmaxUOu++fCbtJny0oio+7XkTn YtXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=eRpkqVfWMOikxM6ZwfLrrgVLEZOXSDhaDwqwMwZfRaI=; b=iY1JSH8j9Dv4mO3Pek2D8WJ+tHbamEUeR5ekM0T9lVlyM5KMN95ZdkmeOanEtuAosQ Z+LLl1/ssDAP6vGmrOubgVa329aHtVpnOLun8izVHYuB+8xh/jTmNL8wK2JXZRISo1xi ICGadjUOf1LoGkh0FL9+i+Ci5E66/iNM8RFLtdFqrNzuiUI0BWtlIkoOUg2tFsrw3CaB uwj7dx8rpPjdnaslJygJIJaUbJ1O0P/C96u1+3LAB6t5sFX9uvR6D7/B8Wo3PZ0nhpeO I/zQz8dqR1jzDTjfCPr7VuL/y7es7bMl7ifWTqN7+gFgmw0VsUjMWC19FyiwtOEErkJo hN5w== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si802687edd.8.2021.03.17.23.14.53; Wed, 17 Mar 2021 23:15:16 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbhCRGN6 (ORCPT + 99 others); Thu, 18 Mar 2021 02:13:58 -0400 Received: from mail-lf1-f42.google.com ([209.85.167.42]:33520 "EHLO mail-lf1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbhCRGNu (ORCPT ); Thu, 18 Mar 2021 02:13:50 -0400 Received: by mail-lf1-f42.google.com with SMTP id m17so2710061lfg.0 for ; Wed, 17 Mar 2021 23:13:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eRpkqVfWMOikxM6ZwfLrrgVLEZOXSDhaDwqwMwZfRaI=; b=bjzAYG0MtGPAjDOkV633E+Wo1a7S3YNWKHcycui1rqDDQH1blq8lQcOXFbYYWH5QUs 0I/d+uWSEZrW4izcjnS3qDI/bBKsWttdpfywQEQLwB2bzMbKfn9segiL9CL/d0vcGDf7 2UA0xLkz1wyCA1+V2EPC80aEv7BQqnMjqC52LSXbGxzCEG8xS2kHu5YD1ccomHkHiSMx vE/+TOEKYlK0tWJUlQBzIETay1jIx6v+gXn0CdKtdtxDM/JkcMk0KSlGMpWSD7T6bLAM uP7s13GczWjZCb3lUG0l9m0yfrGPprk8lDthWVPsr4J9YhqIkI8LWLFa1dT5Jm3YnxTN LE8g== X-Gm-Message-State: AOAM530gUxq0YZ3omP+ZxAzvcYSqk6QNCUFVAHzBXxNBWS+pzyxiE0up gOADh6uHjkBCS95UbZ3es0210AHNQ1VgPQ4xkGs= X-Received: by 2002:ac2:51b4:: with SMTP id f20mr1145697lfk.509.1616048028865; Wed, 17 Mar 2021 23:13:48 -0700 (PDT) MIME-Version: 1.0 References: <20210317094409.94293-1-yangjihong1@huawei.com> In-Reply-To: <20210317094409.94293-1-yangjihong1@huawei.com> From: Namhyung Kim Date: Thu, 18 Mar 2021 15:13:37 +0900 Message-ID: Subject: Re: [PATCH v6] perf annotate: Fix sample events lost in stdio mode To: Yang Jihong Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Yao Jin , gustavoars@kernel.org, mliska@suse.cz, linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Wed, Mar 17, 2021 at 6:44 PM 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. > > Signed-off-by: Yang Jihong > --- > > Changes since v5: > - Add Signed-off-by tag. > > Changes since v4: > - Use the same sort key "dso,symbol" in branch stack mode. > > Changes since v3: > - Modify the first line of comments. > > Changes since v2: > - Remove zfree in hists__find_annotations. > - Change sort order to avoid duplicate output. > > Changes since v1: > - Change processed flag variable from u8 to bool. > > 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..92c55f292c11 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); > } > } > } > @@ -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"; At this point, I think there's not much value having separate setup_sorting() for branch mode. Thanks, Namhyung > if ((use_browser == 1 || annotate.use_stdio2) && annotate.has_br_stack) { > sort__mode = SORT_MODE__BRANCH; > if (setup_sorting(annotate.session->evlist) < 0) > -- > 2.30.GIT >