lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Ygacpt3tdaLyTPrb@kernel.org>
Date:   Fri, 11 Feb 2022 14:28:06 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Darren Hart <dvhart@...radead.org>,
        Davidlohr Bueso <dave@...olabs.net>,
        André Almeida <andrealmeid@...labora.com>,
        James Clark <james.clark@....com>,
        John Garry <john.garry@...wei.com>,
        Riccardo Mancini <rickyman7@...il.com>,
        Yury Norov <yury.norov@...il.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Jin Yao <yao.jin@...ux.intel.com>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Leo Yan <leo.yan@...aro.org>, Andi Kleen <ak@...ux.intel.com>,
        Thomas Richter <tmricht@...ux.ibm.com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Madhavan Srinivasan <maddy@...ux.ibm.com>,
        Shunsuke Nakamura <nakamura.shun@...itsu.com>,
        Song Liu <song@...nel.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Miaoqian Lin <linmq006@...il.com>,
        Stephen Brennan <stephen.s.brennan@...cle.com>,
        Kajol Jain <kjain@...ux.ibm.com>,
        Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>,
        German Gomez <german.gomez@....com>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
        Eric Dumazet <edumazet@...gle.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Hao Luo <haoluo@...gle.com>, eranian@...gle.com
Subject: Re: [PATCH v3 09/22] perf map: Add const to map_ip and unmap_ip

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 <irogers@...gle.com>
> ---
>  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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ