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 D7AD6C433EF for ; Fri, 11 Feb 2022 17:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352170AbiBKR2Y (ORCPT ); Fri, 11 Feb 2022 12:28:24 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240606AbiBKR2M (ORCPT ); Fri, 11 Feb 2022 12:28:12 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 155712BF; Fri, 11 Feb 2022 09:28:11 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id C5F59B82B23; Fri, 11 Feb 2022 17:28:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40141C340EF; Fri, 11 Feb 2022 17:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644600488; bh=LK/7kZ1wCa9ctZCetD4KcUNk2hYQK+I+NhyvbffF6es=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gd+FXfH0nF0oMxPJPuSCsG8ogN7gx0WiHg8kndf6TBFE6Ywa+fWinCWI6GkdSDtOf u0YXgmh789/xN01FMbrk2/kpLiHrI9bcDQ90VC826TlwgDO/jefwNuq8l5SpEEeMam zbmdc0ucjlVLgVkhzXt73t8jr0bLIIZW0uEXJ3z/POjhHwGEjg5V40SkRMvofIb263 kbdLtDDo0SLAk91Wi/DCRtyOZe1JPwp42PP231hRSA7vvhru+p9sikCCNxgQQt3MxH XZpzLcHj64lB+VvPCVNUZdkrzcgji436wGVNQ0Kgm0I991ELe6Dj/1dqui2vDmzR1q UxqHkJOB7LYmA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 73116400FE; Fri, 11 Feb 2022 14:28:06 -0300 (-03) Date: Fri, 11 Feb 2022 14:28:06 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Darren Hart , Davidlohr Bueso , =?iso-8859-1?Q?Andr=E9?= Almeida , James Clark , John Garry , Riccardo Mancini , Yury Norov , Andy Shevchenko , Andrew Morton , Jin Yao , Adrian Hunter , Leo Yan , Andi Kleen , Thomas Richter , Kan Liang , Madhavan Srinivasan , Shunsuke Nakamura , Song Liu , Masami Hiramatsu , Steven Rostedt , Miaoqian Lin , Stephen Brennan , Kajol Jain , Alexey Bayduraev , German Gomez , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Dmitry Vyukov , Hao Luo , eranian@google.com Subject: Re: [PATCH v3 09/22] perf map: Add const to map_ip and unmap_ip Message-ID: References: <20220211103415.2737789-1-irogers@google.com> <20220211103415.2737789-10-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220211103415.2737789-10-irogers@google.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Feb 11, 2022 at 02:34:02AM -0800, Ian Rogers escreveu: > Functions purely determine a value from the map and don't need to modify > it. Move functions to C file as they are most commonly used via a > function pointer. Builds, applied. - Arnaldo > Signed-off-by: Ian Rogers > --- > tools/perf/util/map.c | 15 +++++++++++++++ > tools/perf/util/map.h | 24 ++++++++---------------- > 2 files changed, 23 insertions(+), 16 deletions(-) > > diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c > index 2cfe5744b86c..b98fb000eb5c 100644 > --- a/tools/perf/util/map.c > +++ b/tools/perf/util/map.c > @@ -563,3 +563,18 @@ struct maps *map__kmaps(struct map *map) > } > return kmap->kmaps; > } > + > +u64 map__map_ip(const struct map *map, u64 ip) > +{ > + return ip - map->start + map->pgoff; > +} > + > +u64 map__unmap_ip(const struct map *map, u64 ip) > +{ > + return ip + map->start - map->pgoff; > +} > + > +u64 identity__map_ip(const struct map *map __maybe_unused, u64 ip) > +{ > + return ip; > +} > diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h > index 973dce27b253..212a9468d5e1 100644 > --- a/tools/perf/util/map.h > +++ b/tools/perf/util/map.h > @@ -29,9 +29,9 @@ struct map { > u64 reloc; > > /* ip -> dso rip */ > - u64 (*map_ip)(struct map *, u64); > + u64 (*map_ip)(const struct map *, u64); > /* dso rip -> ip */ > - u64 (*unmap_ip)(struct map *, u64); > + u64 (*unmap_ip)(const struct map *, u64); > > struct dso *dso; > refcount_t refcnt; > @@ -44,20 +44,12 @@ struct kmap *__map__kmap(struct map *map); > struct kmap *map__kmap(struct map *map); > struct maps *map__kmaps(struct map *map); > > -static inline u64 map__map_ip(struct map *map, u64 ip) > -{ > - return ip - map->start + map->pgoff; > -} > - > -static inline u64 map__unmap_ip(struct map *map, u64 ip) > -{ > - return ip + map->start - map->pgoff; > -} > - > -static inline u64 identity__map_ip(struct map *map __maybe_unused, u64 ip) > -{ > - return ip; > -} > +/* ip -> dso rip */ > +u64 map__map_ip(const struct map *map, u64 ip); > +/* dso rip -> ip */ > +u64 map__unmap_ip(const struct map *map, u64 ip); > +/* Returns ip */ > +u64 identity__map_ip(const struct map *map __maybe_unused, u64 ip); > > static inline size_t map__size(const struct map *map) > { > -- > 2.35.1.265.g69c8d7142f-goog -- - Arnaldo