From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28570C7EE29 for ; Fri, 9 Jun 2023 19:48:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230244AbjFITsM (ORCPT ); Fri, 9 Jun 2023 15:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjFITsJ (ORCPT ); Fri, 9 Jun 2023 15:48:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07A0BE4A; Fri, 9 Jun 2023 12:48:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9938C65B55; Fri, 9 Jun 2023 19:48:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2C3CC433EF; Fri, 9 Jun 2023 19:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686340088; bh=vRa5+x8YqrUPTrMvhWgSuXzIjrvokCR+9EDGmt85tqM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ChS1WcA0jb9t3utyWXMEm7DclUZ62ObuGUG46Swbeqx1GbA1hlbcJQHlu2stE9hIv GH1NSTdsT/MseOoSIUE54kM+kcazwtBa97h+DOy5EJ/b2dDWy077Tv5RIfj3UnsA14 7LuDRvovdrXGN4yO8NgoQqmE8OIDhgO0MvuReZ0DK2VSXv9AMXdTlwEr4jb0ZztOFT PIl40lOqD+NoJZkGwcMITMb7yHdAgAaHoHSk1cxDrS6qaIkEsOZxQU9TUM7MKRvjvB jZ2ok9uKAnj5r4yhw+ekgoIrVEf0ZJDPs99Z/ihWppNQcf89FrxJLj7SZKalOxIxAK xOv1EQ/We2oAg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id BAEE940692; Fri, 9 Jun 2023 16:48:04 -0300 (-03) Date: Fri, 9 Jun 2023 16:48:04 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Suzuki K Poulose , "Naveen N. Rao" , Kan Liang , German Gomez , Ali Saidi , Jing Zhang , Athira Rajeev , Miguel Ojeda , ye xingchen , Liam Howlett , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , K Prateek Nayak , Changbin Du , Ravi Bangoria , Sean Christopherson , Andi Kleen , "Steinar H. Gunderson" , Yuan Can , Brian Robbins , liuwenyu , Ivan Babrou , Fangrui Song , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org Subject: Re: [PATCH v2 06/26] perf addr_location: Add init/exit/copy functions Message-ID: References: <20230608232823.4027869-1-irogers@google.com> <20230608232823.4027869-7-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230608232823.4027869-7-irogers@google.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Jun 08, 2023 at 04:28:03PM -0700, Ian Rogers escreveu: > +++ b/tools/perf/builtin-kmem.c > @@ -399,7 +399,9 @@ static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample) > struct addr_location al; > struct machine *machine = &kmem_session->machines.host; > struct callchain_cursor_node *node; > + u64 result; > > + addr_location__init(&al); > if (alloc_func_list == NULL) { > if (build_alloc_func_list() < 0) > goto out; > @@ -427,16 +429,19 @@ static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample) > else > addr = node->ip; > > - return addr; > + result = addr; > + goto out; > } else > pr_debug3("skipping alloc function: %s\n", caller->name); > > callchain_cursor_advance(&callchain_cursor); > } > > -out: > pr_debug2("unknown callsite: %"PRIx64 "\n", sample->ip); > - return sample->ip; > + result = sample->ip; > +out: > + addr_location__exit(&al); > + return result; > } I needed this to make sure result is set to something, mostly keeping the previous logic as build_alloc_func_list() already does debugging/error prints about what went wrong if it takes the 'goto out'. - Arnaldo diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index a11f280d20bd3d12..96a6611e4e53f448 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -399,7 +399,7 @@ static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample) struct addr_location al; struct machine *machine = &kmem_session->machines.host; struct callchain_cursor_node *node; - u64 result; + u64 result = sample->ip; addr_location__init(&al); if (alloc_func_list == NULL) { @@ -438,7 +438,6 @@ static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample) } pr_debug2("unknown callsite: %"PRIx64 "\n", sample->ip); - result = sample->ip; out: addr_location__exit(&al); return result;