Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp685948rdf; Fri, 3 Nov 2023 11:48:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRZLav4/KHV8gk838xK3Hc46prfNdZkpLsgI5G5wR5lG/HE4JsJEp2UDf0q6+tbs1bcBy5 X-Received: by 2002:a17:902:dacc:b0:1cc:4677:2f0e with SMTP id q12-20020a170902dacc00b001cc46772f0emr20847976plx.45.1699037338469; Fri, 03 Nov 2023 11:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699037338; cv=none; d=google.com; s=arc-20160816; b=qwPGHchsEnrGFmoBXKCNlXgTrBCbi2keZEy6uelzWEl15xhIos+2wSXhoN+jzj+f/r NounhcmrQTNER1dGO55LXIaCtHATCda6iBBqDIAZKMmZJVxxqDIGXhAGerkUz/MoyYnH 8RTI/SHFfIp4h3DO00UhHrQu9cLt82yGboKyluXOOkxYj76HbybLHjFGSERwUtbm2Ir9 EoDBHe9F6mrDkq1fcdT1I/qDJhS03mOKwogZR5FQgAEgreHaNY/1PW+/IxuKdhF0fG39 wVgxGI+ivbCv06oa4DTEAqboUEl1ouonj3Lr6vp6IwYXblwCJOzM0Kc4tJmu0nZxIdT6 rYXw== 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=DGouyKz4tP6QccluUsnd70H0TNrIIGX7wEIfxXF0KWs=; fh=4Kgt7kDtVrIXe4cKNywMQAY7jLnutXL9uOkaTa5MrMg=; b=k2d7sOu7Ue6dROM+ySS9qvnO0ciRgbVsQjISAH9Sy5uNXXBdlXoCSZEopRs9qsmdGO LybSJY/CRS67LMsKJ/a67tO0mnbnN81bM+7hND7s760QhIa5ZCFaMEA/aZBjIfa25yC9 GCIg/7CyyTkZd/pBEVPdnDiD1BBInlwGL8FLAzmZ6ZImnacSbuYPnqp51ecyxCqkHnx/ tujEwkhEfvjUlUDHhH5MjsUGSz/iXRxRFDu4wzFd7jmJhL0W83Hwp9E60xOFRqhw8DCT XQzIpLKX6iLycEKCD8pQsj7UOpIJIEi1vkxUp3ixTo2PSb5N8u5LQ27Lc0nvCq+tJjPa LXog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k20-20020a170902ba9400b001bb8c4279f5si1958973pls.148.2023.11.03.11.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 11:48:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 287E283DBECD; Fri, 3 Nov 2023 11:48:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345177AbjKCSsi convert rfc822-to-8bit (ORCPT + 99 others); Fri, 3 Nov 2023 14:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbjKCSsh (ORCPT ); Fri, 3 Nov 2023 14:48:37 -0400 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A9ED45; Fri, 3 Nov 2023 11:48:35 -0700 (PDT) Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-28019b66ad5so2157688a91.3; Fri, 03 Nov 2023 11:48:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699037315; x=1699642115; 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=0HYAQpuZLbZa219M3eCpKYKVGNMx7y39abDg1zJkZtI=; b=ihz7h5xnOTAFlXa+bbB6ESstP+NJpGiZL1+/cE/sM6vRXugNdNOVKbZSmZpiPI2UBA 9Z6AvFhNK1eEshPc7gryj6YxNKinapLNqG/h0C/RgNlBPqLrlj6oChCTeeHD/YNi9zpi 4IBr1fQITF9u9T7NtcuK03vI2fxLY1HaxUrIsS0ZQgf9EeNMPqyW0amqgXZfSLgpKlKv 8rM+rxQTPofnYxMR/QaOlsmB3UfxUaxuTi4ib0IyEilUGOWlJFFV37bpEEjpfHk+0/VD WC6OZAmsOvIYSyjlt6QqpUCyyavzEw/xsqieAPL3cXDS42lHP/UFVlZCFoTCmV0LafoG C1Nw== X-Gm-Message-State: AOJu0Yzw1P9Eu5HYhxH3XlUBx9orTBsL4WhBo1E2WFLlWOpbcHgsc/vx aUCgN8sKNBo6rNWk8ykx+3iuaVoFvZyUa+2tLnM= X-Received: by 2002:a17:90b:4f91:b0:27d:3f0c:f087 with SMTP id qe17-20020a17090b4f9100b0027d3f0cf087mr21908587pjb.25.1699037314556; Fri, 03 Nov 2023 11:48:34 -0700 (PDT) MIME-Version: 1.0 References: <20231102222653.4165959-1-namhyung@kernel.org> <20231102222653.4165959-2-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Fri, 3 Nov 2023 11:48:23 -0700 Message-ID: Subject: Re: [PATCH 1/5] perf annotate: Split struct cycles_info To: Ian Rogers 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: 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 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 11:48:44 -0700 (PDT) Hi Ian, On Thu, Nov 2, 2023 at 3:53 PM Ian Rogers wrote: > > On Thu, Nov 2, 2023 at 3:26 PM Namhyung Kim wrote: > > > > The cycles info is used only when branch stack is provided. Split them > > into a separate struct and lazy allocate them to save some memory. > > > > Signed-off-by: Namhyung Kim > > --- > > tools/perf/ui/browsers/annotate.c | 2 +- > > tools/perf/util/annotate.c | 34 ++++++++++++++++++------------- > > tools/perf/util/annotate.h | 14 ++++++++----- > > 3 files changed, 30 insertions(+), 20 deletions(-) > > > > diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c > > index ccdb2cd11fbf..d2470f87344d 100644 > > --- a/tools/perf/ui/browsers/annotate.c > > +++ b/tools/perf/ui/browsers/annotate.c > > @@ -337,7 +337,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, > > max_percent = percent; > > } > > > > - if (max_percent < 0.01 && pos->al.ipc == 0) { > > + if (max_percent < 0.01 && (!pos->al.cycles || pos->al.cycles->ipc == 0)) { > > RB_CLEAR_NODE(&pos->al.rb_node); > > continue; > > } > > diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c > > index 82956adf9963..3e7f75827270 100644 > > --- a/tools/perf/util/annotate.c > > +++ b/tools/perf/util/annotate.c > > @@ -1100,8 +1100,8 @@ static void annotation__count_and_fill(struct annotation *notes, u64 start, u64 > > for (offset = start; offset <= end; offset++) { > > struct annotation_line *al = notes->offsets[offset]; > > > > - if (al && al->ipc == 0.0) { > > - al->ipc = ipc; > > + if (al && al->cycles && al->cycles->ipc == 0.0) { > > + al->cycles->ipc = ipc; > > cover_insn++; > > } > > } > > @@ -1134,13 +1134,18 @@ void annotation__compute_ipc(struct annotation *notes, size_t size) > > if (ch && ch->cycles) { > > struct annotation_line *al; > > > > + al = notes->offsets[offset]; > > + if (al && al->cycles == NULL) { > > + al->cycles = zalloc(sizeof(*al->cycles)); > > + if (al->cycles == NULL) > > + continue; > > + } > > if (ch->have_start) > > annotation__count_and_fill(notes, ch->start, offset, ch); > > - al = notes->offsets[offset]; > > if (al && ch->num_aggr) { > > - al->cycles = ch->cycles_aggr / ch->num_aggr; > > - al->cycles_max = ch->cycles_max; > > - al->cycles_min = ch->cycles_min; > > Thanks for doing this! Would it make sense to do the zalloc here to be > lazier about allocation? annotation__count_and_fill() also needs it. Thanks, Namhyung > > Ian > > > + al->cycles->avg = ch->cycles_aggr / ch->num_aggr; > > + al->cycles->max = ch->cycles_max; > > + al->cycles->min = ch->cycles_min; > > } > > notes->have_cycles = true;