Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp18183lqg; Thu, 29 Feb 2024 18:04:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXFLOfsCKf011hNuSFDO8DNOOabgjGEYJEdEtxS9mYyPoLcZiLHyZ6y5JJVR3w9vQyBNvz1bPMgsRyezotHptB0U8bhTXvBwJ4MI9Y3cQ== X-Google-Smtp-Source: AGHT+IG2KpkoauDKWkdkmOIftW/L5eGsBJR3BLMz5UJWwc3FTji83biBDt6acmkXBlxdImeK/Sbr X-Received: by 2002:a05:620a:248b:b0:787:ffa9:b8a9 with SMTP id i11-20020a05620a248b00b00787ffa9b8a9mr439589qkn.11.1709258660462; Thu, 29 Feb 2024 18:04:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709258660; cv=pass; d=google.com; s=arc-20160816; b=Nqfs9YqTN/3TnHFvIh8NX+ZnXQcBIQNY5Diyjuscyn+9wGouX7qSl0cZUjwA4LR6IH /Omdi4B3khGie3O+y1QGsuX9gc+QD/uXET+jscn9lFl3dT20hPMCS+meMYUIAm4/MxjV +9b3v23xds57IOapt0yMQf2H9NKZfIgZN/qFkWqtwf54hfMU/FM3eMJPp8DycrD7XA/s 8VBaXTpZSPTUuGW04XITfeiYMKPhIboHoDRL++8YKqpeHYXAy0y58IJuoKORlndXmJfp JatpbF8M15Za1IQyRgp4Q4WP8EaEUxMnV7xQHKetquChulUJDP8UDD+K0FBBTPjaL+VQ r15A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=suOSlNRm11HwW5KZFh7zQNpV0hqocGQ1PpQrvLWCrew=; fh=hwTzs9G5Jq0Fe1Yb9qCV/PnONxwGBUFY1TFmER2ufIs=; b=SDt71UvGnBuKGYpnZ20H160TG6WSABMrmb8FTugWPKhFxNIl6r+Up2gfJvx0fof7Pb 7i5BPpjjSt7k/9K5qCAm7mRQfDGSBAiaN540g4kGUzhfQlGmpfkytxVpxa4HvPsg5vuk amB6igY8jYlRXz2IuxMN4YchyUreKZZ9OF5yHa+4NB5uyA6A54T8i8skbE82/JC1CAwB gryDE9Mo9gVBbpDEbpxWG6tOtDpQi2jtgjlIPfLv4bo80uOws7p9We0Fo9GkUbinvh4W hE9EfIYFu3328o5jKnp5UXCTuFN8U/ZmUUHAlsgg8lsfCXnW81/Ig6s5N8v2mzzQjrYU PUEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-87813-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87813-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w12-20020a05620a444c00b0078724563d65si3128309qkp.127.2024.02.29.18.04.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 18:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87813-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-87813-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87813-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0BEDA1C22A8A for ; Fri, 1 Mar 2024 02:04:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D03738F9D; Fri, 1 Mar 2024 02:04:13 +0000 (UTC) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 826B839AC9; Fri, 1 Mar 2024 02:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709258652; cv=none; b=POK981BhqEnF49C5nPkpio4gg7wH/Tukd+uyl19SYuGkkD92RB9rzvOtxaq+FnLq7PQcbuxsprY0lJ7OJkhPEgS+N6G/5iMFCZ+k+P5yCfzrDoUoocZTIU1xenWoxHnvrXaWFDtt4oEq3IjYvfH4NFU/rnwMfVUbufgD3/Zppe0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709258652; c=relaxed/simple; bh=/d9AG0yAYaKw80HGazSSs3yzEkw5b6BjdLgT2pIrXDE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=n5T/UkpjDIbnIy2zyOeBV+oLPgpKaNEib783aSDcmepOqjmuDkw6WCqiIjSFaHyo2/Jr63zko3DpoiOiZD2UR6qnZnTV97OkottCs3fnBOcY0thnq6lhVwTpykGPxXEHhhzSVcrMantY2TJ0dbeMo/fkJzPFz8B28k8ixAUKtrA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-29a6dcfdd30so1253187a91.0; Thu, 29 Feb 2024 18:04:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709258651; x=1709863451; 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=suOSlNRm11HwW5KZFh7zQNpV0hqocGQ1PpQrvLWCrew=; b=jxw8oA0c/53Uimm81rXTM8UYOL5UZIXWXgPhDnKa1HYxVI+7JjToInBZBCx6Ib5DPr +GKKUMV486IiAW4t5/5+LV21KeBppoaoFTgIFLf1mEtQQY8e8Elr6x6769MGlbvjpz7+ pjyesWodil2nY+x6kHmd2zkTsXcNEyWLqdm4dxPJKenu1F8y3E4pV8PNScRCT1s9fenh ZtZhCbQEllWnpa9JRLmYLMMa4CwNuV7mldxIiyVK/UBRIHNWjEk08UJBPhsaiYSxboBz 2DisNgaT6rzMR36RacE1E4va4Smp2y/GRGsoch5/bdZBnIlp94znKXJBIhgzV/GWma3V e3jw== X-Forwarded-Encrypted: i=1; AJvYcCWzH7rf+OxAuYTY9hQMgDIDiTz2v4J+R/qbi+9ITLdGEiT8vLoo0E4OehrLKqYJGwTA+gpjRWLD45JbJ134B/Q7jd9WKylf7wBL0ciedQIT+APimNPlC1Qb0wXwweLUXVxYdi/2iy/NBKUAI0BhKQ== X-Gm-Message-State: AOJu0YyMsKBrSyc0rbmjw1Cm2rUyNczuLs2yhAywAswsQV/0OnCzG4+Y y9j3VbAd9CsqGwARgnzPlGLvytZK+2yKTx+BWoTAaQtuac/oYjQxc8T5JqOF/HhVsHbCNBhYlcm RTTMzsnBwCQQOgCOOoMMUKhprYjY= X-Received: by 2002:a17:90a:d184:b0:29b:1e0a:10c8 with SMTP id fu4-20020a17090ad18400b0029b1e0a10c8mr396759pjb.4.1709258650888; Thu, 29 Feb 2024 18:04:10 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240229062048.558799-1-irogers@google.com> In-Reply-To: <20240229062048.558799-1-irogers@google.com> From: Namhyung Kim Date: Thu, 29 Feb 2024 18:04:00 -0800 Message-ID: Subject: Re: [PATCH v1] perf map: Fix map reference count issues To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Masami Hiramatsu , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 28, 2024 at 10:21=E2=80=AFPM Ian Rogers wr= ote: > > The find will get the map, ensure puts are done on all paths. > > Signed-off-by: Ian Rogers Acked-by: Namhyung Kim Thanks, Namhyung > --- > tools/perf/util/maps.c | 14 +++++++------- > tools/perf/util/probe-event.c | 4 +--- > 2 files changed, 8 insertions(+), 10 deletions(-) > > diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c > index 53aea6d2ef93..ce13145a9f8e 100644 > --- a/tools/perf/util/maps.c > +++ b/tools/perf/util/maps.c > @@ -611,14 +611,14 @@ struct symbol *maps__find_symbol(struct maps *maps,= u64 addr, struct map **mapp) > struct symbol *result =3D NULL; > > /* Ensure map is loaded before using map->map_ip */ > - if (map !=3D NULL && map__load(map) >=3D 0) { > - if (mapp) > - *mapp =3D map; > - > + if (map !=3D NULL && map__load(map) >=3D 0) > result =3D map__find_symbol(map, map__map_ip(map, addr)); > - if (!mapp) > - map__put(map); > - } > + > + if (mapp) > + *mapp =3D map; > + else > + map__put(map); > + > return result; > } > > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.= c > index be71abe8b9b0..2a0ad9ecf0a2 100644 > --- a/tools/perf/util/probe-event.c > +++ b/tools/perf/util/probe-event.c > @@ -2274,9 +2274,7 @@ static int find_perf_probe_point_from_map(struct pr= obe_trace_point *tp, > ret =3D pp->function ? 0 : -ENOMEM; > > out: > - if (map && !is_kprobe) { > - map__put(map); > - } > + map__put(map); > > return ret; > } > -- > 2.44.0.278.ge034bb2e1d-goog >