Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp14242rdb; Wed, 18 Oct 2023 16:16:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFe9B3Z4d63iSjpGStF5TupFwLJi1XtTt3VEk3uDuvlYJLcL+IkKpWa/habgf4o0rNefX4L X-Received: by 2002:a05:6a20:2589:b0:17a:e2b9:77e0 with SMTP id k9-20020a056a20258900b0017ae2b977e0mr371331pzd.7.1697671013394; Wed, 18 Oct 2023 16:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697671013; cv=none; d=google.com; s=arc-20160816; b=fe/QPKiExXZCH2+NqqxZXtIRJKbHJcP2yN/BS1DLAnWFnI0yOBTXUhmFSzBi7zLasi 8OMjHUZJSBqhxC1E+dfpYzIPZywXANG5s+undZJcdzBqc2mp7KeWnoKLIykj0ZvuX4lS G2ToFd9+QVeqNC5WQWfWZqiScJWaBIH+KgkuMFvrOjpJe3AGy8zenliZi8uV0wjdd56K QsF/96NBkrOFPBMcKhb3eIEMKJUZ33pJDGbRcMmaL/DATgo28vmG2GnEA2mXaI6HMfAL 5YslK9VkZduaXaF1NyeA85r2xOYZuYdACEfE//92+56rWJpD06k/SgjVDAXXAqQL3qW7 HjcA== 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=o4Q9xtlB7Z0jbiD0ztPNItIGr5nsOMJpGiwNtOHfc5k=; fh=E10VZPe6Co8ezsBgErBfA67AzM7mDmfOH0ZUqd+UkZw=; b=zyoKdTBV8nF+5qGbnDyEwsylQ1VxL8LciknqgZMhkis1AB1FPxI4bYiQrz0smrqsRK uHG0UJjwXgDCpisk0RU25pMmbQFGefjUiIy3vp5v9esZE/Z6uJmd1owGPqg1FrykwKVU 6zyRhdMWj+YyqmFsN/lLCtE9I6xV/jffeam1TorrbtrSjG4CT3kVCfT79u/14urvERje +B2tOz1e2ztGVZDElsZKeLeHmDlFHUsV3ojF1yAS3PLhlrCgyWaJuz2OY/3xkdvdvqiT rj8/nw4Hiy/8V0sz00aEgs/0YVRzacoBAHSMDOCiN4lhHQoeoI6OP6D+72SGC1cSQla3 WYtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id g10-20020a636b0a000000b005b837c29d22si1722064pgc.177.2023.10.18.16.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 16:16:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 260AA8100D9F; Wed, 18 Oct 2023 16:16:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjJRXQ0 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 18 Oct 2023 19:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjJRXQY (ORCPT ); Wed, 18 Oct 2023 19:16:24 -0400 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC43113; Wed, 18 Oct 2023 16:16:23 -0700 (PDT) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-27d4b280e4eso155072a91.1; Wed, 18 Oct 2023 16:16:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697670983; x=1698275783; 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=sIqkHqDOHQuBjbbW3lZ0aMJK1GXnPfSHH5+VnCKa+5E=; b=PryT3oDclSMTVDDg6fYZn8mkmOYWiwHOVa+kxvOv3kkZ0TfNV/te79BmguKR66ut1H Rt5kndlH+ufb97DwvBSlgPGG8BX2M5SHzgQAnjgy5DlFicaZeWIwP1idTVuiGzcdToH5 DyDYSylfWfh91NH7ycwOcCabWAu7didEqdPJndcC24KYLfOBgLTQJDUtMsPgJqOpA0MC KBtvngeHpFd0KRZWQhmUtVIMOlu8JTn+cZ12pnOALreMkkvAlR4RYisEZe6Y8JEQH9Ej M7DBtiUPpws5vqnEfzsOQNxDZQsnpsdbfGI2k08GphGUwd0K7cLCajCQ8Yw2KpgD+zf4 4nxA== X-Gm-Message-State: AOJu0YxnlRPCN0AjubabwH7TF4+NA8GYLPB6E8f35pFI2d5V7BsjzExa yDLRBh1fSTn2f+Pswi64EIaqN3t/u3VCwtLur0Y= X-Received: by 2002:a17:90a:11:b0:27d:df04:d109 with SMTP id 17-20020a17090a001100b0027ddf04d109mr409283pja.2.1697670982818; Wed, 18 Oct 2023 16:16:22 -0700 (PDT) MIME-Version: 1.0 References: <20231012062359.1616786-1-irogers@google.com> <20231012062359.1616786-4-irogers@google.com> In-Reply-To: <20231012062359.1616786-4-irogers@google.com> From: Namhyung Kim Date: Wed, 18 Oct 2023 16:16:11 -0700 Message-ID: Subject: Re: [PATCH v2 03/13] perf hist: Add missing puts to hist__account_cycles To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Nick Terrell , Kan Liang , Song Liu , Sandipan Das , Anshuman Khandual , James Clark , Liam Howlett , Miguel Ojeda , Leo Yan , German Gomez , Ravi Bangoria , Artem Savkov , Athira Rajeev , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 16:16:43 -0700 (PDT) Hi Ian, On Wed, Oct 11, 2023 at 11:24 PM Ian Rogers wrote: > > Caught using reference count checking on perf top with > "--call-graph=lbr". After this no memory leaks were detected. > > Fixes: 57849998e2cd ("perf report: Add processing for cycle histograms") > Signed-off-by: Ian Rogers > --- > tools/perf/util/hist.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c > index 3dc8a4968beb..ac8c0ef48a7f 100644 > --- a/tools/perf/util/hist.c > +++ b/tools/perf/util/hist.c > @@ -2676,8 +2676,6 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al, > > /* If we have branch cycles always annotate them. */ > if (bs && bs->nr && entries[0].flags.cycles) { > - int i; > - Seems not necessary. > bi = sample__resolve_bstack(sample, al); It looks like this increases the refcount for each bi entry and it didn't put the refcounts. > if (bi) { > struct addr_map_symbol *prev = NULL; > @@ -2692,7 +2690,7 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al, > * Note that perf stores branches reversed from > * program order! > */ > - for (i = bs->nr - 1; i >= 0; i--) { > + for (int i = bs->nr - 1; i >= 0; i--) { > addr_map_symbol__account_cycles(&bi[i].from, > nonany_branch_mode ? NULL : prev, > bi[i].flags.cycles); > @@ -2701,6 +2699,12 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al, > if (total_cycles) > *total_cycles += bi[i].flags.cycles; > } > + for (unsigned int i = 0; i < bs->nr; i++) { Can we just reuse the int i above? Thanks, Namhyung > + map__put(bi[i].to.ms.map); > + maps__put(bi[i].to.ms.maps); > + map__put(bi[i].from.ms.map); > + maps__put(bi[i].from.ms.maps); > + } > free(bi); > } > } > -- > 2.42.0.609.gbb76f46606-goog >