Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10400526rwd; Wed, 21 Jun 2023 22:39:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+pdQux2iQv9Jcxtb2T8uHNriRx37RIf5+UVg2wQAShSRQ46lYNcSR9KkyC+WKzxoS6rGO X-Received: by 2002:a05:6870:d88b:b0:19f:a340:232 with SMTP id dv11-20020a056870d88b00b0019fa3400232mr10557296oab.10.1687412348210; Wed, 21 Jun 2023 22:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687412348; cv=none; d=google.com; s=arc-20160816; b=DE8H78K3GPhzAlp/vSwr12wSr9z8StXX43mXlhsPu2VwBeXvfcA2et0vM83VfXt8R4 9gISBAB4+XfE/rSUZ91RbvpRHlCSei7gfyN4sv5PfW/1M7Xk42t3R1iE4XLJZERJRKpE yC3rUh+ilj+0DGTg98tRjZsO4fkjfmwn/3kZ96ogb0MiqL91B/0Dzrdqyb4DX0ScnFe6 zh5rqaFHzNOCW/wp+nQrZqvUS450Qq4XHY2MuBD/bM60cfgciLoDzgyZ2dv7+b4DMkrO UINJX5ce/FomzaMWZ3fQGrX0F0fpwF5+WwNWJsvC+DMIXieM0CEFOQ9oni5RVPzF37FY 0+fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=Iwkvo3drwBmCh3irzLZqUQdw68f0F8NzA1rA0HnILRE=; b=gU8Uv3mWsQM85oE3UucAmrPToF/7mdVXwiqGnZq1aDBOOQNDhfvl5bJ9Wqyf//Sedv ccS5wJF1/DZLnwBN/Ddw2sWiSC7qXyKR3uyhoxnRtW380Ra2xd/wcSjhUO4PSG+aPPCu N3wX1TPg1vz/aHqAuXDr3PIHsJt7iu4DM8A0mcRNMm8m5MlgR8eWeD35IMJN7wAmXt1C QMkoX6q0gMt7MQHsP4C2vwRWwyMZ8A9P5+aj+l77zqDYicaXWdOS2ZiXn+uLVnh9lzvx PJSqz46yGUONGFpaReKoJVuoiQsSfc+BHCYLPsqfA7VVA9iW+aIgiRgKy/CdnglWhG7H bcLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=DhKdtVPr; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k129-20020a633d87000000b00551bb2b99besi5959419pga.85.2023.06.21.22.38.56; Wed, 21 Jun 2023 22:39:08 -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; dkim=pass header.i=@google.com header.s=20221208 header.b=DhKdtVPr; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbjFVFLD (ORCPT + 99 others); Thu, 22 Jun 2023 01:11:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbjFVFKo (ORCPT ); Thu, 22 Jun 2023 01:10:44 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A4DF1BCB for ; Wed, 21 Jun 2023 22:10:33 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5704995f964so82246727b3.2 for ; Wed, 21 Jun 2023 22:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687410632; x=1690002632; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=Iwkvo3drwBmCh3irzLZqUQdw68f0F8NzA1rA0HnILRE=; b=DhKdtVPrmYHxiqjIKCbVGRxMjbXrvSQn+TCrG60I5aPx7c7YMFttQxbOAnjuiNvSKt ZBZ64IyZ6mpIB4RKj4p4a89tn8PJjxXPagqSybROjPUgGS0esLOwOEWVfi3U41BZrUKg Pr0ZYPWUaLrEeNgzVXC6UNOtI8+cFJKyDveKgVvWtzn4RxbD+CF1FbKnoaa58+ROWh5L InT4O4Bzo/yyWR3xkWxHPIoW/V3Jthf6X6MVMpCrFl8rTr/mtKpGB1bQvA7GIbYr1b8q B6eVEqekcxhU4dSVNyP3JbV8XRuhEhyfgwc6OEFURVr9h49gl+/Bh0Peos6QsbUGeJbs ov5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687410632; x=1690002632; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Iwkvo3drwBmCh3irzLZqUQdw68f0F8NzA1rA0HnILRE=; b=Zuc18KZI2bLpkfz5bIJnGm0Sa3E3VaawF+2vspQ36xAYAJig7SqHno1kyy0B31Cpaw W8I+6zVOlZc+nqTZIShmASirqDSK9xr8skIEVdpo3WpQdczD0dVKNeLAjhqbS8dbpUUg vZ50nhmaG9BNBbgkdSqQy7uSbnTNO3JCfaCCFVx7E2zyJdrskMggrPgKKVOVsYRWvI9W FC60FoprEtALXG4LkCkd5wluhAwAlHAQA2lPCuJdYyI+eykRZniLMU0kPO+0JFlvpmJ+ fTokVPV+q9IZwKgfzFScbfjvIWGb57mrkfgPgtdF0BcnE0KNHuSee8j3ImbboS5Wk8T2 arnQ== X-Gm-Message-State: AC+VfDzXHxWFW+Z3apalqGpxtXrF4NDY4nnVrMkdFYLTpy3wasfe975N 8huYjxEuNdjKt0u1m9EHIT4e4aUCpfMc X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:91f3:1da5:6427:50d6]) (user=irogers job=sendgmr) by 2002:a05:690c:70e:b0:573:4ed9:c69a with SMTP id bs14-20020a05690c070e00b005734ed9c69amr3818009ywb.10.1687410632774; Wed, 21 Jun 2023 22:10:32 -0700 (PDT) Date: Wed, 21 Jun 2023 22:10:29 -0700 Message-Id: <20230622051029.3733815-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Subject: [PATCH v1 1/1] perf unwind: Fix map reference counts From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Ivan Babrou , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham 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 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. 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