Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp121336rdf; Thu, 2 Nov 2023 15:59:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1HqYO48Xsy+CQgom4sGuCQKkMCkKNSz5UT+9EFs3OgpN3XyYyqg3uTTMKsF8ck6ASlp5J X-Received: by 2002:a05:6a20:7f92:b0:17e:5d2f:f439 with SMTP id d18-20020a056a207f9200b0017e5d2ff439mr25644399pzj.46.1698965983415; Thu, 02 Nov 2023 15:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698965983; cv=none; d=google.com; s=arc-20160816; b=HSD0hImWaOVBNOMJ1JUij3E9Tn2bfW0AegGGW5GwjdS5D9bT6b683fQHXoJ2mKSdMm CxBkdAct5so2y3ViRmdII5o7QALP94ULgFHGSVE8u5fh1eE38XNj4eCBOOHEOu5WMK0c ftUTUc0o34l+Qg5gs6qCVBqOTHTM8Ugjzkgl6K+YnOMU2zTrUGGnaZ5LtFUeeDbPAF3j JYpEzXzNIxq+zlRa3cel401J7KxyLN1JySG4ogO4pPR0ChgUI7YTRZC55STRucOU/YSf EHAR4FHRyq2lsoLDoIhpjA9LRecUyEPVh3hXsHAagXjlZBhR5cupMflWDIolDLhJyzUv YtOA== 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 :dkim-signature; bh=QP31fLX+pxaO5hDZO6DHoxgvhUAHCcHqxZGWN/MwNfQ=; fh=Pbu1BQwhCOAA2d/C0IOLVYR5czI2/+Avx4u+s0uioL8=; b=sVHOSKGcq3rnASOUFT47tnePZkni3Y+ogwJQsPgAfOOR7boy6XzlnDoS1o93SVlvdF +1DsNzGp2FFABseOHT2D+V0Hc/TcLPiVgePRJ+5C5GQI3+unGdPHk8PuIt5RGRBE7BU0 RfQYUzw5nd9Nr77BXaxBFEHossccpBWqm2Uns0yhtZhsaiCw50zHArRg2Dc3+H1kU99u nULOy854rODZ2xiF0OTkpQaa8ZkkTJs7A0oetM32v7AKVsL8G4g/s4dkSZzMhuBIap8n XDtkwiqYYLjdFZMVoTJMJaa2OZJdWxPF0WKKLAhxjdJAuPv6r+uKrehqwPHzND6KqVlu diHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JHaMZxzz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id s189-20020a635ec6000000b005b8f9dbbd5fsi390405pgb.409.2023.11.02.15.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 15:59:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JHaMZxzz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 987E8811C14A; Thu, 2 Nov 2023 15:59:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377548AbjKBW7Z (ORCPT + 99 others); Thu, 2 Nov 2023 18:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377540AbjKBW7Y (ORCPT ); Thu, 2 Nov 2023 18:59:24 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5FF1193 for ; Thu, 2 Nov 2023 15:59:20 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-54366bb1c02so2347a12.1 for ; Thu, 02 Nov 2023 15:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698965959; x=1699570759; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QP31fLX+pxaO5hDZO6DHoxgvhUAHCcHqxZGWN/MwNfQ=; b=JHaMZxzzpF1Cn1yV/IA/F6iFUVhaXwA2p/OVH7ugye6yb3i9Ari5JBkjeNPBPfO5cT Fh2qxB8sJjjHk42A+Kg1i+UoTGzywh4EM3x+r0JuYXg3BjaFWjinvVx8b3AT7vQWPoTP m2p3YJsaHX2wIAoLRuCwMtO6NHiARKlQCxcMwg8HtchLMFKlMLs7FMeMPdmHQUTB2J+/ Ju0mZMhlbCWxyK3CqQEh4F7Vvfqj5a4oMNFuzxmL0EkcztD7J+pX1qBiTgRq7iLGBINE zie4hc6FIqClCPcGnwc35sEO98Qq0l5sIU4OzAtQ6UH9uB1VXywl+1vwSMlJ6dCWr5MA UjFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698965959; x=1699570759; 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=QP31fLX+pxaO5hDZO6DHoxgvhUAHCcHqxZGWN/MwNfQ=; b=fBbvQwhhBuWu48Zsyo3zrXVJcetgerFFKfXWwhAj8kU8WqWJJvhTKynA+PRlnFi3Di OgnxPSSPh3jnbX6lCWW6Q4C6H0WgXQ/hrm99bt7RlcFjL0dMFipupLmKhdxjjiatwWNZ KNkki+HW6z9GIEOeOYThQMi3j4uC9zaUI2pq/jkJ0BTIyPZtAzKtOiL5vnj3IFqObG0+ U4PuobdF3EJ/oCJAAu7CTgQMw5TB+9IqEVZ3wItLzXflH8TWK4ix9NOTU5AKEdPItaP2 NEzwElank/HDVDj/bMSj/ueY7X7Yg4phwgGybL690Hw1y7OQG1BfJlb45Hvy3Sg+PD53 kRMQ== X-Gm-Message-State: AOJu0Yxbyg+jkLJkwj2nRoWlRQU61XhrG8LNWkzlbwRMXm0SWAtGigKU 1nd/HwUM56Vr1rAbRBW5XPea0HVJMyFXg7tNBaHuHw== X-Received: by 2002:a05:6402:501c:b0:543:fa43:a361 with SMTP id p28-20020a056402501c00b00543fa43a361mr146040eda.1.1698965959359; Thu, 02 Nov 2023 15:59:19 -0700 (PDT) MIME-Version: 1.0 References: <20231102222653.4165959-1-namhyung@kernel.org> <20231102222653.4165959-4-namhyung@kernel.org> In-Reply-To: <20231102222653.4165959-4-namhyung@kernel.org> From: Ian Rogers Date: Thu, 2 Nov 2023 15:59:07 -0700 Message-ID: Subject: Re: [PATCH 3/5] perf annotate: Move max_coverage to annotated_branch To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 02 Nov 2023 15:59:40 -0700 (PDT) On Thu, Nov 2, 2023 at 3:27=E2=80=AFPM Namhyung Kim w= rote: > > The max_coverage is only used when branch stack info is available so > it'd be natural to move to the annotated_branch. > > Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers Thanks, Ian > --- > tools/perf/builtin-annotate.c | 7 +++++-- > tools/perf/util/annotate.c | 2 +- > tools/perf/util/annotate.h | 4 +++- > tools/perf/util/block-range.c | 7 ++++++- > 4 files changed, 15 insertions(+), 5 deletions(-) > > diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.= c > index aeeb801f1ed7..a9129b51d511 100644 > --- a/tools/perf/builtin-annotate.c > +++ b/tools/perf/builtin-annotate.c > @@ -94,6 +94,7 @@ static void process_basic_block(struct addr_map_symbol = *start, > struct annotation *notes =3D sym ? symbol__annotation(sym) : NULL= ; > struct block_range_iter iter; > struct block_range *entry; > + struct annotated_branch *branch; > > /* > * Sanity; NULL isn't executable and the CPU cannot execute backw= ards > @@ -105,6 +106,8 @@ static void process_basic_block(struct addr_map_symbo= l *start, > if (!block_range_iter__valid(&iter)) > return; > > + branch =3D annotation__get_branch(notes); > + > /* > * First block in range is a branch target. > */ > @@ -118,8 +121,8 @@ static void process_basic_block(struct addr_map_symbo= l *start, > entry->coverage++; > entry->sym =3D sym; > > - if (notes) > - notes->max_coverage =3D max(notes->max_coverage, = entry->coverage); > + if (branch) > + branch->max_coverage =3D max(branch->max_coverage= , entry->coverage); > > } while (block_range_iter__next(&iter)); > > diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c > index 2fa1ce3a0858..92a9adf9d5eb 100644 > --- a/tools/perf/util/annotate.c > +++ b/tools/perf/util/annotate.c > @@ -946,7 +946,7 @@ static int __symbol__inc_addr_samples(struct map_symb= ol *ms, > return 0; > } > > -static struct annotated_branch *annotation__get_branch(struct annotation= *notes) > +struct annotated_branch *annotation__get_branch(struct annotation *notes= ) > { > if (notes =3D=3D NULL) > return NULL; > diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h > index 9c199629305d..d8a221591926 100644 > --- a/tools/perf/util/annotate.h > +++ b/tools/perf/util/annotate.h > @@ -280,10 +280,10 @@ struct annotated_branch { > unsigned int total_insn; > unsigned int cover_insn; > struct cyc_hist *cycles_hist; > + u64 max_coverage; > }; > > struct LOCKABLE annotation { > - u64 max_coverage; > u64 start; > struct annotation_options *options; > struct annotation_line **offsets; > @@ -356,6 +356,8 @@ static inline struct annotation *symbol__annotation(s= truct symbol *sym) > int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct per= f_sample *sample, > struct evsel *evsel); > > +struct annotated_branch *annotation__get_branch(struct annotation *notes= ); > + > int addr_map_symbol__account_cycles(struct addr_map_symbol *ams, > struct addr_map_symbol *start, > unsigned cycles); > diff --git a/tools/perf/util/block-range.c b/tools/perf/util/block-range.= c > index 680e92774d0c..15c42196c24c 100644 > --- a/tools/perf/util/block-range.c > +++ b/tools/perf/util/block-range.c > @@ -311,6 +311,7 @@ struct block_range_iter block_range__create(u64 start= , u64 end) > double block_range__coverage(struct block_range *br) > { > struct symbol *sym; > + struct annotated_branch *branch; > > if (!br) { > if (block_ranges.blocks) > @@ -323,5 +324,9 @@ double block_range__coverage(struct block_range *br) > if (!sym) > return -1; > > - return (double)br->coverage / symbol__annotation(sym)->max_covera= ge; > + branch =3D symbol__annotation(sym)->branch; > + if (!branch) > + return -1; > + > + return (double)br->coverage / branch->max_coverage; > } > -- > 2.42.0.869.gea05f2083d-goog >