Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11591885rwd; Thu, 22 Jun 2023 15:53:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+zJK0xcwWnTK2kMSL51t6kMTSFxvBPAmHEinJ5EWsGyNdXpfYm67Q4hQaQvey9Y12tCUB X-Received: by 2002:a05:6a00:23c2:b0:668:69fa:f791 with SMTP id g2-20020a056a0023c200b0066869faf791mr11900712pfc.3.1687474434529; Thu, 22 Jun 2023 15:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687474434; cv=none; d=google.com; s=arc-20160816; b=uNtU02Vsmkd0Y2KdkBoCwC5fVZezqS29ZY9Pc6AuhGZWMYmmmAqZ+HkixWWlLxxlkC m9rBMUwFmbybSoYP6sXmfWyLZg3Zk5s5jEwbRs2rAA+1j5kJuSojCUMmoBqlbus5MYqF zgn1iRtsLQddhYW9AyWWTfWUW6rMlBvtImOwHPHbH5RjmUjmrjWgEiPh8+lpn2qDKoWU w386pqDXzeWASD5rFu6aHimsucCT4x0F2LgikhH2Fvs4xWd9A+ce4tktlzEvA+XSaAcD WFUTAFfwd+xzBtLtxYEAABm2GueU69EpMf2esKjredxX0Cc6N+jyWXFRE3KVvQv7NMPp p7xA== 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=VitScveuhO/Zv3njb1z+nLorTOoa4GfMerAjZXQBX74=; b=hpLwJR+b4FGy3oyC5Vd9UHKkM2fNO3GIol47emCa2FCHBewyHia6F6XmUOK2f6UGuz 80lL04Un88XzLpm6gIKInkB5tISpcj0WS/s70m01eWbPAg246/SQ9R41YTGiannF6lZA xD8VWR2U90MK/Osnwr/+RXFeT2LDFLNWkUvujzttCUHEn0aRpYHqX7IBoAMTF1e7yeeZ Ou8pmJjAIv++yh90E40x+nkyCAuoglBRZHqKbp9ImA1sFxVW/eEHr8etGXvUHvDZIRx3 KsPMi/EVc2PxMxzWFbsYGmo8EkYRLBi3SioG8Z7sasMfwgFuinOjMLs3PHQe3dZBIzcF rlJg== 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 j189-20020a636ec6000000b005572d19eea7si3771736pgc.798.2023.06.22.15.53.42; Thu, 22 Jun 2023 15:53:54 -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 S230180AbjFVWXj convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Jun 2023 18:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbjFVWXi (ORCPT ); Thu, 22 Jun 2023 18:23:38 -0400 Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D451BE7; Thu, 22 Jun 2023 15:23:37 -0700 (PDT) Received: by mail-vs1-f52.google.com with SMTP id ada2fe7eead31-440b31263f5so2032228137.0; Thu, 22 Jun 2023 15:23:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687472616; x=1690064616; 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=RqELWV0ctLE2v1qRE62B46rrBP0uVJy647v7XCR5BuI=; b=NAE2sq4iBv6oPwQb0LFotkVjDFDM3Cui6y7vaE+DOICHnoiZ1VhzkmDSSkhvvuomVD hQpEwXqzmpnery1OwroJZkSoDbTVepMSONca0g4XhKa/QXkgOOZaseEAyWzKc3t0x+Su aaBGz5aWt2K2m/JprD4EkyRwabWKY8GD8xa32km0FhkQmsCrjFoli+YSHws+U/Ua+W38 UaK/7GErBu7yR5aMv6w/uPVxZ0z6KGvT46Rvti1MsFTkWR2rzf+fnbeQgxwwy8J6o4HF fdWopVgdUcj/hHXLhvjGSebRYVgVfhIlZijzjRIwlsHZDrru0NIs/L70jdbvuEb8jJiu Y1GQ== X-Gm-Message-State: AC+VfDxUjL8jXLnFuNCh7b61vvNTBVTII06GZWscbb6n2fcPOaN7NWwg KcgFEYAKYQtYWVigAcJN7Cn0JHzFbGUSyAgHz3s= X-Received: by 2002:a67:fc82:0:b0:440:afe5:ac1b with SMTP id x2-20020a67fc82000000b00440afe5ac1bmr6227366vsp.35.1687472615964; Thu, 22 Jun 2023 15:23:35 -0700 (PDT) MIME-Version: 1.0 References: <20230622051029.3733815-1-irogers@google.com> In-Reply-To: <20230622051029.3733815-1-irogers@google.com> From: Namhyung Kim Date: Thu, 22 Jun 2023 15:23:24 -0700 Message-ID: Subject: Re: [PATCH v1 1/1] perf unwind: Fix map reference counts To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Ivan Babrou , linux-perf-users@vger.kernel.org, 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_H2,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 On Wed, Jun 21, 2023 at 10:10 PM Ian Rogers wrote: > > The result of thread__find_map is the map in the passed in > addr_location. Calling addr_location__exit puts that map and so copies > need to do a map__get. Add in the corresponding map__puts. It also needs map__put() when map__dso() returns NULL. Thanks, Namhyung > > Signed-off-by: Ian Rogers > --- > tools/perf/util/unwind-libunwind-local.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c > index 36bf5100bad2..9cb82d7c7dc7 100644 > --- a/tools/perf/util/unwind-libunwind-local.c > +++ b/tools/perf/util/unwind-libunwind-local.c > @@ -419,7 +419,8 @@ static struct map *find_map(unw_word_t ip, struct unwind_info *ui) > struct map *ret; > > addr_location__init(&al); > - ret = thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al); > + thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al); > + ret = map__get(al.map); > addr_location__exit(&al); > return ret; > } > @@ -476,11 +477,11 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, > > memset(&di, 0, sizeof(di)); > if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map))) > - return dwarf_search_unwind_table(as, ip, &di, pi, > - need_unwind_info, arg); > + ret = dwarf_search_unwind_table(as, ip, &di, pi, > + need_unwind_info, arg); > } > #endif > - > + map__put(map); > return ret; > } > > @@ -539,7 +540,7 @@ static int access_dso_mem(struct unwind_info *ui, unw_word_t addr, > > size = dso__data_read_addr(dso, map, ui->machine, > addr, (u8 *) data, sizeof(*data)); > - > + map__put(map); > return !(size == sizeof(*data)); > } > > -- > 2.41.0.162.gfafddb0af9-goog >