All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Matheus Marchini <mmarchini@netflix.com>,
	linux-perf-users@vger.kernel.org, jkoch@netflix.com,
	khlebnikov@yandex-team.ru, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Changbin Du <changbin.du@intel.com>,
	Song Liu <songliubraving@fb.com>,
	John Keeping <john@metanate.com>, Andi Kleen <ak@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf map: fix infinite loop on map_groups__fixup_overlappings
Date: Wed, 11 Dec 2019 15:13:13 -0300	[thread overview]
Message-ID: <20191211181313.GE13965@kernel.org> (raw)
In-Reply-To: <20191211160734.18087-1-mmarchini@netflix.com>

Em Wed, Dec 11, 2019 at 08:07:31AM -0800, Matheus Marchini escreveu:
> In some cases, when using perf inject and there are JIT_CODE_MOVE
> records in the jitdump file, perf will end up in an infinite loop on
> map_groups__fixup_overlappings, which will keep allocating memory
> indefinitely. This issue was observed on Node.js (with changes to
> generate JIT_CODE_MOVE records) and on Java.
> 
> This issue started to occur after 6a9405b56c274 (perf map:
> Optimize maps__fixup_overlappings()). To prevent it from happening,
> partially revert those changes without losing the optimizations
> introduced in it.

Konstantin, can you please take a look and provide your Acked-by or
Reviewed-by?

- Arnaldo
 
> Signed-off-by: Matheus Marchini <mmarchini@netflix.com>
> ---
>  tools/perf/util/map.c | 17 +++++++++++++++++
>  tools/perf/util/map.h |  1 +
>  2 files changed, 18 insertions(+)
> 
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index 744bfbaf35cf..8918fdb8ddab 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -781,6 +781,21 @@ static void __map_groups__insert(struct map_groups *mg, struct map *map)
>  	__maps__insert(&mg->maps, map);
>  }
>  
> +int map__overlap(struct map *l, struct map *r)
> +{
> +	if (l->start > r->start) {
> +		struct map *t = l;
> +
> +		l = r;
> +		r = t;
> +	}
> +
> +	if (l->end > r->start)
> +		return 1;
> +
> +	return 0;
> +}
> +
>  int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE *fp)
>  {
>  	struct maps *maps = &mg->maps;
> @@ -821,6 +836,8 @@ int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE
>  		 */
>  		if (pos->start >= map->end)
>  			break;
> +		if (!map__overlap(map, pos))
> +			continue;
>  
>  		if (verbose >= 2) {
>  
> diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
> index 5e8899883231..1383571437aa 100644
> --- a/tools/perf/util/map.h
> +++ b/tools/perf/util/map.h
> @@ -132,6 +132,7 @@ static inline void __map__zput(struct map **map)
>  
>  #define map__zput(map) __map__zput(&map)
>  
> +int map__overlap(struct map *l, struct map *r);
>  size_t map__fprintf(struct map *map, FILE *fp);
>  size_t map__fprintf_dsoname(struct map *map, FILE *fp);
>  char *map__srcline(struct map *map, u64 addr, struct symbol *sym);
> -- 
> 2.17.1

-- 

- Arnaldo

WARNING: multiple messages have this Message-ID (diff)
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: Matheus Marchini <mmarchini@netflix.com>,
	linux-perf-users@vger.kernel.org, jkoch@netflix.com,
	khlebnikov@yandex-team.ru, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Changbin Du <changbin.du@intel.com>,
	Song Liu <songliubraving@fb.com>,
	John Keeping <john@metanate.com>, Andi Kleen <ak@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf map: fix infinite loop on map_groups__fixup_overlappings
Date: Wed, 11 Dec 2019 15:13:13 -0300	[thread overview]
Message-ID: <20191211181313.GE13965@kernel.org> (raw)
In-Reply-To: <20191211160734.18087-1-mmarchini@netflix.com>

Em Wed, Dec 11, 2019 at 08:07:31AM -0800, Matheus Marchini escreveu:
> In some cases, when using perf inject and there are JIT_CODE_MOVE
> records in the jitdump file, perf will end up in an infinite loop on
> map_groups__fixup_overlappings, which will keep allocating memory
> indefinitely. This issue was observed on Node.js (with changes to
> generate JIT_CODE_MOVE records) and on Java.
> 
> This issue started to occur after 6a9405b56c274 (perf map:
> Optimize maps__fixup_overlappings()). To prevent it from happening,
> partially revert those changes without losing the optimizations
> introduced in it.

Konstantin, can you please take a look and provide your Acked-by or
Reviewed-by?

- Arnaldo
 
> Signed-off-by: Matheus Marchini <mmarchini@netflix.com>
> ---
>  tools/perf/util/map.c | 17 +++++++++++++++++
>  tools/perf/util/map.h |  1 +
>  2 files changed, 18 insertions(+)
> 
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index 744bfbaf35cf..8918fdb8ddab 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -781,6 +781,21 @@ static void __map_groups__insert(struct map_groups *mg, struct map *map)
>  	__maps__insert(&mg->maps, map);
>  }
>  
> +int map__overlap(struct map *l, struct map *r)
> +{
> +	if (l->start > r->start) {
> +		struct map *t = l;
> +
> +		l = r;
> +		r = t;
> +	}
> +
> +	if (l->end > r->start)
> +		return 1;
> +
> +	return 0;
> +}
> +
>  int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE *fp)
>  {
>  	struct maps *maps = &mg->maps;
> @@ -821,6 +836,8 @@ int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE
>  		 */
>  		if (pos->start >= map->end)
>  			break;
> +		if (!map__overlap(map, pos))
> +			continue;
>  
>  		if (verbose >= 2) {
>  
> diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
> index 5e8899883231..1383571437aa 100644
> --- a/tools/perf/util/map.h
> +++ b/tools/perf/util/map.h
> @@ -132,6 +132,7 @@ static inline void __map__zput(struct map **map)
>  
>  #define map__zput(map) __map__zput(&map)
>  
> +int map__overlap(struct map *l, struct map *r);
>  size_t map__fprintf(struct map *map, FILE *fp);
>  size_t map__fprintf_dsoname(struct map *map, FILE *fp);
>  char *map__srcline(struct map *map, u64 addr, struct symbol *sym);
> -- 
> 2.17.1

-- 

- Arnaldo

  reply	other threads:[~2019-12-11 18:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-11 16:07 [PATCH] perf map: fix infinite loop on map_groups__fixup_overlappings Matheus Marchini
2019-12-11 18:13 ` Arnaldo Carvalho de Melo [this message]
2019-12-11 18:13   ` Arnaldo Carvalho de Melo
2019-12-14 11:16 ` Konstantin Khlebnikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191211181313.GE13965@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=changbin.du@intel.com \
    --cc=jkoch@netflix.com \
    --cc=john@metanate.com \
    --cc=jolsa@redhat.com \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=mmarchini@netflix.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.