Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11949895rwd; Thu, 22 Jun 2023 22:27:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+M0iSQ6S4Nt2JuFaEPpPMsSVXIlrek0LyBKijommR9luW9uBgLOCPPEhRLR0FOsvfrG9d X-Received: by 2002:a17:90a:f0cc:b0:253:266a:3b00 with SMTP id fa12-20020a17090af0cc00b00253266a3b00mr15411604pjb.37.1687498071867; Thu, 22 Jun 2023 22:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687498071; cv=none; d=google.com; s=arc-20160816; b=vtUcYEdMkFkSrzQu8jWLaOyxSz3ABK4bgi1NlHHkO1anEkt2lIdbrz4hjZMsMQ5Tbj yXOvO4gF+xkZzr19kR814U0nHInC3LQZgJXzC2uka4fuUTDMzYvr9khtD7pgVLT9Oc4l Z5Dq97w+1v70LAQ0w0Ob0c3WNao4b61Dg8o8tLhyFnCoGBS4CcPdaByREwPVD6XKvQlZ rqtxA2tKxOVpOWZ3LlYO/o8hBQSjs+Ucf83bTOFMEFrXscCNHQKm+dIt93G4YcbHEV/x COfc++d5lxegvmgNG6mPgfHF8mfFisy3mX3rNGFwhMTvMo/S0Y/5ldggssn0+2TiuT8Q imgA== 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=YIOH5L+HoGnPF4eL1Betw8AXXV0t5V/gGi5fTb8E750=; b=v80n41dEPxryOTGQWYAk8Jx0MQjoFU9czsDa4esMkCndP1sbvfrxXjyXfC4b/EEpNr WNUdDnAcOKAzg/9iP9OGTGmh53+IfpyABtppbRCW+e5+GDN77uMR3cW5dnoyYcfBu3Uv ant6mvT+Wtqy7I4A6DqfJuL3R5HGs7fi1YZUYL0VJnpwxRqkIC4c7h+dRriHdXkelPJ2 LYmSHUwTJV303E+IKxQ2UvgaW+ULUBcvQJWEdy50T2DEg+mdLnJPbnQ6dDGZj/RTgMGE 0a+8DBTxZh8CdT5/crLWpT2bYZ0I1TfhIpl+a0sCB8KRPOYr7RGTyppwTXA3KQ9FUb39 fvbA== 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 s30-20020a63925e000000b0054fd8d57b1esi6546971pgn.668.2023.06.22.22.27.36; Thu, 22 Jun 2023 22:27:51 -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 S229961AbjFWFCR convert rfc822-to-8bit (ORCPT + 99 others); Fri, 23 Jun 2023 01:02:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbjFWFCP (ORCPT ); Fri, 23 Jun 2023 01:02:15 -0400 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EC37E4B; Thu, 22 Jun 2023 22:02:12 -0700 (PDT) Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-bfe6ea01ff5so211427276.3; Thu, 22 Jun 2023 22:02:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687496532; x=1690088532; 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=0lbYvnRG7m7BdPVBK4RGAv7DA18uMbVSHdxUyBaBHkc=; b=eKMEtxuG++jUx3UjilDm/wbGYewuEPxhmOauXLayCsxA2gVmoZx0Z7KnWTu7Afwyqo B3IryYuZcQt2ZXIa6TltkpM0zkQVK1vaoByWhP52cFk5EhqdBNgm3Fv1X2qTtm0f2dXB BeF1cz3zuSlPk8gnH3u/SkB6hM2gxwKTr5XwIXoKi3NXFdC0fqdAoHoV1d/dIOdXqJfi IBqQJ8SlC+PB+hWECIxVkQmn/Ksa4qIL1jYhUtorGwVUvwkyKoMQMrn9AEI/Z7KUmZcu v2+K9BcE6tG/ROqsKiIKGXuRFrR1BBlJ5sxoteyP/RMw1Vv/H3uaz3AoDtdeYMim7M2p svZA== X-Gm-Message-State: AC+VfDzvicyzbaK9IeRgerBS5/WaYqf7vDTSEQ8UhNmRevrCbA09mvUA pqjkPytxmYU0vXDMwKlGZ2YfXq75U4gx1yppQ3g= X-Received: by 2002:a25:5f4d:0:b0:bcb:caf8:7aae with SMTP id h13-20020a255f4d000000b00bcbcaf87aaemr16378378ybm.44.1687496531735; Thu, 22 Jun 2023 22:02:11 -0700 (PDT) MIME-Version: 1.0 References: <20230623043107.4077510-1-irogers@google.com> In-Reply-To: <20230623043107.4077510-1-irogers@google.com> From: Namhyung Kim Date: Thu, 22 Jun 2023 22:01:59 -0700 Message-ID: Subject: Re: [PATCH v2] 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 Thu, Jun 22, 2023 at 9:31 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. > > Signed-off-by: Ian Rogers Acked-by: Namhyung Kim Thanks, Namhyung > > v2. Add missing map__put when dso is missing. > --- > tools/perf/util/unwind-libunwind-local.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c > index 36bf5100bad2..ebfde537b99b 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; > } > @@ -440,8 +441,10 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, > return -EINVAL; > > dso = map__dso(map); > - if (!dso) > + if (!dso) { > + map__put(map); > return -EINVAL; > + } > > pr_debug("unwind: find_proc_info dso %s\n", dso->name); > > @@ -476,11 +479,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; > } > > @@ -534,12 +537,14 @@ static int access_dso_mem(struct unwind_info *ui, unw_word_t addr, > > dso = map__dso(map); > > - if (!dso) > + if (!dso) { > + map__put(map); > return -1; > + } > > 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 >