Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1286993 > unrolled thread

[PATCH perf/core 18/22] perf stat: Fix cmd_stat to release cpu_map

Started byMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
First post2015-12-09 03:20 +0100
Last post2015-12-10 09:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH perf/core 18/22] perf stat: Fix cmd_stat to release cpu_map Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-12-09 03:20 +0100
    Re: [PATCH perf/core 18/22] perf stat: Fix cmd_stat to release  cpu_map Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-12-09 16:10 +0100
    [tip:perf/core] perf stat: Fix cmd_stat to release cpu_map tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-12-10 09:20 +0100

#1286993 — [PATCH perf/core 18/22] perf stat: Fix cmd_stat to release cpu_map

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-12-09 03:20 +0100
Subject[PATCH perf/core 18/22] perf stat: Fix cmd_stat to release cpu_map
Message-ID<qDCwj-25G-29@gated-at.bofh.it>
Fix cmd_stat() to release cpu_map objects (aggr_map and
cpus_aggr_map) afterwards.

refcnt debugger shows that the cmd_stat initializes cpu_map
but not puts it.
  ----
  # ./perf stat -v ls
  ....
  REFCNT: BUG: Unreclaimed objects found.
  ==== [0] ====
  Unreclaimed cpu_map@0x29339c0
  Refcount +1 => 1 at
    ./perf(cpu_map__empty_new+0x6d) [0x4e64bd]
    ./perf(cmd_stat+0x5fe) [0x43594e]
    ./perf() [0x47b785]
    ./perf(main+0x617) [0x422587]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2dff420af5]
    ./perf() [0x4226fd]
  REFCNT: Total 1 objects are not reclaimed.
    "cpu_map" leaks 1 objects
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/builtin-stat.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index e74712d..eb6da8f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1094,6 +1094,16 @@ static int perf_stat_init_aggr_mode(void)
 	return cpus_aggr_map ? 0 : -ENOMEM;
 }
 
+static void perf_stat_exit_aggr_mode(void)
+{
+	if (aggr_map)
+		cpu_map__put(aggr_map);
+	if (cpus_aggr_map)
+		cpu_map__put(cpus_aggr_map);
+	aggr_map = NULL;
+	cpus_aggr_map = NULL;
+}
+
 /*
  * Add default attributes, if there were no attributes specified or
  * if -d/--detailed, -d -d or -d -d -d is used:
@@ -1442,6 +1452,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (!forever && status != -1 && !interval)
 		print_counters(NULL, argc, argv);
 
+	perf_stat_exit_aggr_mode();
 	perf_evlist__free_stats(evsel_list);
 out:
 	perf_evlist__delete(evsel_list);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1287544 — Re: [PATCH perf/core 18/22] perf stat: Fix cmd_stat to release cpu_map

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-12-09 16:10 +0100
SubjectRe: [PATCH perf/core 18/22] perf stat: Fix cmd_stat to release cpu_map
Message-ID<qDOxr-1zF-5@gated-at.bofh.it>
In reply to#1286993
Em Wed, Dec 09, 2015 at 11:11:27AM +0900, Masami Hiramatsu escreveu:
> Fix cmd_stat() to release cpu_map objects (aggr_map and
> cpus_aggr_map) afterwards.
> 
> refcnt debugger shows that the cmd_stat initializes cpu_map
> but not puts it.
>   ----
>   # ./perf stat -v ls
>   ....
>   REFCNT: BUG: Unreclaimed objects found.
>   ==== [0] ====
>   Unreclaimed cpu_map@0x29339c0
>   Refcount +1 => 1 at
>     ./perf(cpu_map__empty_new+0x6d) [0x4e64bd]
>     ./perf(cmd_stat+0x5fe) [0x43594e]
>     ./perf() [0x47b785]
>     ./perf(main+0x617) [0x422587]
>     /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2dff420af5]
>     ./perf() [0x4226fd]
>   REFCNT: Total 1 objects are not reclaimed.
>     "cpu_map" leaks 1 objects
>   ----
> 
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> ---
>  tools/perf/builtin-stat.c |   11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index e74712d..eb6da8f 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -1094,6 +1094,16 @@ static int perf_stat_init_aggr_mode(void)
>  	return cpus_aggr_map ? 0 : -ENOMEM;
>  }
>  
> +static void perf_stat_exit_aggr_mode(void)
> +{
> +	if (aggr_map)
> +		cpu_map__put(aggr_map);
> +	if (cpus_aggr_map)
> +		cpu_map__put(cpus_aggr_map);

No need to check if it is NULL, as the other __put operations,
cpu_map__put() checks it:


void cpu_map__put(struct cpu_map *map)
{
	if (map && atomic_dec_and_test(&map->refcnt))
		cpu_map__delete(map);
}

I'm removing those checks and applying this patch, thanks!

> +	aggr_map = NULL;
> +	cpus_aggr_map = NULL;
> +}
> +
>  /*
>   * Add default attributes, if there were no attributes specified or
>   * if -d/--detailed, -d -d or -d -d -d is used:
> @@ -1442,6 +1452,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
>  	if (!forever && status != -1 && !interval)
>  		print_counters(NULL, argc, argv);
>  
> +	perf_stat_exit_aggr_mode();
>  	perf_evlist__free_stats(evsel_list);
>  out:
>  	perf_evlist__delete(evsel_list);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1288327 — [tip:perf/core] perf stat: Fix cmd_stat to release cpu_map

Fromtip-bot for Masami Hiramatsu <tipbot@zytor.com>
Date2015-12-10 09:20 +0100
Subject[tip:perf/core] perf stat: Fix cmd_stat to release cpu_map
Message-ID<qE4Ce-3wi-3@gated-at.bofh.it>
In reply to#1286993
Commit-ID:  544c2ae7b1a794ad0bc5ec24d832ab5658d5aef6
Gitweb:     http://git.kernel.org/tip/544c2ae7b1a794ad0bc5ec24d832ab5658d5aef6
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Wed, 9 Dec 2015 11:11:27 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Dec 2015 13:41:59 -0300

perf stat: Fix cmd_stat to release cpu_map

Fix cmd_stat() to release cpu_map objects (aggr_map and
cpus_aggr_map) afterwards.

refcnt debugger shows that the cmd_stat initializes cpu_map
but not puts it.
  ----
  # ./perf stat -v ls
  ....
  REFCNT: BUG: Unreclaimed objects found.
  ==== [0] ====
  Unreclaimed cpu_map@0x29339c0
  Refcount +1 => 1 at
    ./perf(cpu_map__empty_new+0x6d) [0x4e64bd]
    ./perf(cmd_stat+0x5fe) [0x43594e]
    ./perf() [0x47b785]
    ./perf(main+0x617) [0x422587]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2dff420af5]
    ./perf() [0x4226fd]
  REFCNT: Total 1 objects are not reclaimed.
    "cpu_map" leaks 1 objects
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021127.10245.93697.stgit@localhost.localdomain
[ Remove NULL checks before calling the put operation, it checks it already ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index e74712d..25a95f4 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1094,6 +1094,14 @@ static int perf_stat_init_aggr_mode(void)
 	return cpus_aggr_map ? 0 : -ENOMEM;
 }
 
+static void perf_stat__exit_aggr_mode(void)
+{
+	cpu_map__put(aggr_map);
+	cpu_map__put(cpus_aggr_map);
+	aggr_map = NULL;
+	cpus_aggr_map = NULL;
+}
+
 /*
  * Add default attributes, if there were no attributes specified or
  * if -d/--detailed, -d -d or -d -d -d is used:
@@ -1442,6 +1450,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (!forever && status != -1 && !interval)
 		print_counters(NULL, argc, argv);
 
+	perf_stat__exit_aggr_mode();
 	perf_evlist__free_stats(evsel_list);
 out:
 	perf_evlist__delete(evsel_list);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web