Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1049072rwd; Wed, 7 Jun 2023 10:13:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KQMB5wYSvKHHkHyG4drXNp1lFyvfJOM8/3y6/82aXKSpP0V47DfySebeq4w5T5JTSjdzr X-Received: by 2002:a05:6a21:339f:b0:10b:a9ca:97bf with SMTP id yy31-20020a056a21339f00b0010ba9ca97bfmr2970633pzb.24.1686158003665; Wed, 07 Jun 2023 10:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686158003; cv=none; d=google.com; s=arc-20160816; b=qE3fDHAyObR5rvSv9HmrQSzUWJFkUCIeK/97Zme6+EDCvTIo68t0fEjK8j3F0JXz1t PGG85rVmdUUOQf6jl1mJXSCZ0oDV0EX7xSDtWpenZDeMo1x6AmZig6LfjfDuprVltLEl Ev4uq42InSuoMpFdrxQN/jUgFcQ28TGpfjIevJ8JveSXx15r0id7f34VtZYEjE/UepWq qZIA043V+Z8CdvoQajK8yvvsWynpDeAuWFZ21bij3QIthpn1aRI16MfRW/58aT+ognYJ NUOkQNtvpB4yxFot9v2M11Wvyll+yq8HwAyEkhkjEJdNSCi4WuDLsnJLmZ2qOyILjUel Lfpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=wxC5qpGyskintAbU7bLmH+KqI5+mVdMb55tw1mYzgIM=; b=WLwvk2Epc51XfmJ3snqOvOF486YV/fNKY53EowksCT/idLpOiDjfyhKWT27IN2uDby Ka02smEBnPX8OdBOWGaZWtGZdaL0v/tkRxOznn1YGqPVBy9WK1Dc7hduesSQsMR2+Kbf lFZx+iaqclJ1Swk2z7vdUPw3Wvwv8caVYv+aNHiHzdKVwYEYol9GsKHm4buy2Fdv7H3h XjNCdFaDg/pWuywRUlCkfSgEqzrN5h8xbS9/akjbnpRR9JPt3l3x85Hd4STbX7iO/hpQ ctRCojmd0eebCpet8lqW7fB1OwIrLemd9kC4OXUJD+fQwhcTr0EIEKp9VjpUpvbF8Z51 n2BA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x2-20020aa79402000000b006581d3c44d1si6119031pfo.89.2023.06.07.10.13.09; Wed, 07 Jun 2023 10:13:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229556AbjFGQuS convert rfc822-to-8bit (ORCPT + 99 others); Wed, 7 Jun 2023 12:50:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbjFGQuQ (ORCPT ); Wed, 7 Jun 2023 12:50:16 -0400 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFDEC1FC0; Wed, 7 Jun 2023 09:50:14 -0700 (PDT) Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-55a35e2a430so1591586eaf.0; Wed, 07 Jun 2023 09:50:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686156612; x=1688748612; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Uznm7d6ydDZWyl996H+0J1qZvqt3MWV+OPBkSeFo+4=; b=BED/IIH3ggEYYvOW8djgDDeFMrxnu2iGYc5prYpI6AOmoKCRbvU0v9evn1Jx8qCkAM hyRD3Uh4os4bfNmds7WzzZMQo3iZ0WhQftYUgsv9KtSW+Y/P64AjQ0d0tvydITAgXgcG 5+h0OpHKghWC1/JxVu93cZLEB6T9dNbBcfoA4KOg6ktBVMicwLaKd8ausraIQly8rRPA 1x/aTizH4DWgasHedMcfQefhLaBbTxxWrODCqmXYwYYfRYXYhxKAoXkRsLGhFnK4OHnm 8AZeV/Qw4CsKrNsPo0an5Qx7lu7VkHqZ1X+PhQbpV/mkTGBp8T1+qNBIYyCacIE30pRS PaGw== X-Gm-Message-State: AC+VfDxlDyYqslHwfskHknBVcCSW7d+OZvSTQOVjHeDUgLiB8m1Qt7iX p6zbNJkmL/ngCUkFd9MaA+oKe7yrtdtxf6E2YUY= X-Received: by 2002:a05:6359:399:b0:129:c526:bddb with SMTP id eg25-20020a056359039900b00129c526bddbmr1790108rwb.13.1686156612356; Wed, 07 Jun 2023 09:50:12 -0700 (PDT) MIME-Version: 1.0 References: <20230531115014.161454-1-asavkov@redhat.com> <20230531115014.161454-3-asavkov@redhat.com> <20230602081811.GA240769@samus.usersys.redhat.com> In-Reply-To: <20230602081811.GA240769@samus.usersys.redhat.com> From: Namhyung Kim Date: Wed, 7 Jun 2023 09:50:01 -0700 Message-ID: Subject: Re: [PATCH 2/2] perf tools: allow running annotation browser from c2c-report To: Artem Savkov Cc: linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Sorry for the late reply. On Fri, Jun 2, 2023 at 1:18 AM Artem Savkov wrote: > > Hello, > > Thank you for the review. > > On Thu, Jun 01, 2023 at 02:26:48PM -0700, Namhyung Kim wrote: > > Hello, > > > > On Wed, May 31, 2023 at 4:50 AM Artem Savkov wrote: > > > > > > Add a shortcut to run annotation browser for selected symbol from > > > c2c report TUI. > > > > > > Signed-off-by: Artem Savkov > > > --- > > > tools/perf/builtin-c2c.c | 76 +++++++++++++++++++++++++++++++++++++--- > > > 1 file changed, 71 insertions(+), 5 deletions(-) > > > > > > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c > > > index 05dfd98af170b..96e66289c2576 100644 > > > --- a/tools/perf/builtin-c2c.c > > > +++ b/tools/perf/builtin-c2c.c > > > @@ -19,11 +19,13 @@ > > snip > > > > struct c2c_hists { > > > @@ -79,6 +83,7 @@ struct c2c_hist_entry { > > > * because of its callchain dynamic entry > > > */ > > > struct hist_entry he; > > > + struct evsel *evsel; > > > > I'm not sure if it's needed. It seems c2c command doesn't collect > > samples per evsel. It uses c2c.hists.hists for all evsels. Then it > > might not be worth keeping an evsel in a c2c_hist_entry and > > just use a random evsel in the evlist. > > > > Right, but annotation browser does use it for line usage percentage > calculation. So does this mean it won't be showing correct percentages > whatever evsel is chosen and that's why it is possible to just select a > random one? Right, annotation can be correct but c2c hist entry is not tied to an evsel so there's no need to save the evsel for each hist entry. > > As far as I can tell evlist is not currently available in > perf_c2c__browse_cacheline(), but it can be added to struct perf_c2c. Sure, please do. > > > > }; > > snip > > > > + " a Annotate current symbol\n" > > > " n Toggle Node details info \n" > > > " s Toggle full length of symbol and source line columns \n" > > > " q Return back to cacheline list \n"; > > > @@ -2650,6 +2670,44 @@ static int perf_c2c__browse_cacheline(struct hist_entry *he) > > > key = hist_browser__run(browser, "? - help", true, 0); > > > > > > switch (key) { > > > + case 'a': > > > > I think it's better to factor this code out to a function. > > Ok, will do. > > > > + if (!browser->selection || > > > + !browser->selection->map || > > > + !browser->selection->map->dso || > > > + browser->selection->map->dso->annotate_warned) { > > > + continue; > > > + } > > > + > > > + ms.map = browser->selection->map; > > > + > > > + if (!browser->selection->sym) { > > > + if (!browser->he_selection) > > > + continue; > > > + > > > + ms.sym = symbol__new_unresolved(browser->he_selection->ip, > > > + browser->selection->map); > > > + > > > + if (!ms.sym) > > > + continue; > > > + } else { > > > + if (symbol__annotation(browser->selection->sym)->src == NULL) { > > > + ui_browser__warning(&browser->b, 0, > > > + "No samples for the \"%s\" symbol.\n\n", > > > + browser->selection->sym->name); > > > + continue; > > > + } > > > + ms.sym = browser->selection->sym; > > > + } > > > + > > > + err = map_symbol__tui_annotate(&ms, c2c_he->evsel, browser->hbt, &c2c.annotation_opts); > > > + > > > + ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); > > > > c2c_browser__update_nr_entries() ? > > Will it change from the previous call before the while loop? This part > was mostly copied over from do_annotate() in ui/browsers/hists.c so I am > a bit hazy here. My understanding is that update_nr_entries and handle > resize are called here mostly for refresh/reset of the ui and > recalculation of number of entries is not needed Hmm.. right. I thought you should check the number of entries again but c2c doesn't have filtering or hierarchy output so you can use hists->nr_entries always. But now I wonder if it's really needed as the annotate will use its own browser so the c2c browser won't be affected. > > > > > > + if ((err == 'q' || err == CTRL('c')) && browser->he_selection->branch_info) > > > > Why check branch_info? > > This was copied over as well and the comment in hists.c states "offer > option to annotate the other branch source or target (if they exists) > when returning from annotate". So I now think this might not be needed > here at all? Yeah, I don't think we need it. Thanks, Namhyung > > > > + continue; > > > + if (err) > > > + ui_browser__handle_resize(&browser->b); > > > + > > > + continue; > > > > It'd be natural to use 'break' instead of 'continue' here. > > Yes, will change this. > > > > case 's': > > > c2c.symbol_full = !c2c.symbol_full; > > snip > > > > perf_session__delete(session); > > > out: > > > + annotation_options__init(&c2c.annotation_opts); > > > > __exit() ? > > Ouch, thanks for noticing! > > -- > Artem >