All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, paulus@samba.org,
	hpa@zytor.com, mingo@kernel.org, a.p.zijlstra@chello.nl,
	minchan@kernel.org, namhyung.kim@lge.com, namhyung@kernel.org,
	jolsa@redhat.com, adrian.hunter@intel.com, dsahern@gmail.com,
	tglx@linutronix.de
Subject: [tip:perf/core] perf kmem: Move session handling out of __cmd_kmem()
Date: Thu, 14 Aug 2014 01:46:55 -0700	[thread overview]
Message-ID: <tip-2b2b2c68c64fb9db392940b42355944064f2a4ca@git.kernel.org> (raw)
In-Reply-To: <1407825645-24586-7-git-send-email-namhyung@kernel.org>

Commit-ID:  2b2b2c68c64fb9db392940b42355944064f2a4ca
Gitweb:     http://git.kernel.org/tip/2b2b2c68c64fb9db392940b42355944064f2a4ca
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Tue, 12 Aug 2014 15:40:38 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Aug 2014 16:33:07 -0300

perf kmem: Move session handling out of __cmd_kmem()

This is a preparation of fixing dso__load_kernel_sym().  It needs a
session info before calling symbol__init().

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1407825645-24586-7-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-kmem.c | 49 +++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 84b8239..349d9b4 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -405,10 +405,9 @@ static void sort_result(void)
 	__sort_result(&root_caller_stat, &root_caller_sorted, &caller_sort);
 }
 
-static int __cmd_kmem(void)
+static int __cmd_kmem(struct perf_session *session)
 {
 	int err = -EINVAL;
-	struct perf_session *session;
 	const struct perf_evsel_str_handler kmem_tracepoints[] = {
 		{ "kmem:kmalloc",		perf_evsel__process_alloc_event, },
     		{ "kmem:kmem_cache_alloc",	perf_evsel__process_alloc_event, },
@@ -417,31 +416,22 @@ static int __cmd_kmem(void)
 		{ "kmem:kfree",			perf_evsel__process_free_event, },
     		{ "kmem:kmem_cache_free",	perf_evsel__process_free_event, },
 	};
-	struct perf_data_file file = {
-		.path = input_name,
-		.mode = PERF_DATA_MODE_READ,
-	};
-
-	session = perf_session__new(&file, false, &perf_kmem);
-	if (session == NULL)
-		return -ENOMEM;
 
 	if (!perf_session__has_traces(session, "kmem record"))
-		goto out_delete;
+		goto out;
 
 	if (perf_session__set_tracepoints_handlers(session, kmem_tracepoints)) {
 		pr_err("Initializing perf session tracepoint handlers failed\n");
-		return -1;
+		goto out;
 	}
 
 	setup_pager();
 	err = perf_session__process_events(session, &perf_kmem);
 	if (err != 0)
-		goto out_delete;
+		goto out;
 	sort_result();
 	print_result(session);
-out_delete:
-	perf_session__delete(session);
+out:
 	return err;
 }
 
@@ -688,29 +678,46 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 		NULL,
 		NULL
 	};
+	struct perf_session *session;
+	struct perf_data_file file = {
+		.path = input_name,
+		.mode = PERF_DATA_MODE_READ,
+	};
+	int ret = -1;
+
 	argc = parse_options_subcommand(argc, argv, kmem_options,
 					kmem_subcommands, kmem_usage, 0);
 
 	if (!argc)
 		usage_with_options(kmem_usage, kmem_options);
 
-	symbol__init();
-
 	if (!strncmp(argv[0], "rec", 3)) {
+		symbol__init();
 		return __cmd_record(argc, argv);
-	} else if (!strcmp(argv[0], "stat")) {
+	}
+
+	session = perf_session__new(&file, false, &perf_kmem);
+	if (session == NULL)
+		return -ENOMEM;
+
+	symbol__init();
+
+	if (!strcmp(argv[0], "stat")) {
 		if (cpu__setup_cpunode_map())
-			return -1;
+			goto out_delete;
 
 		if (list_empty(&caller_sort))
 			setup_sorting(&caller_sort, default_sort_order);
 		if (list_empty(&alloc_sort))
 			setup_sorting(&alloc_sort, default_sort_order);
 
-		return __cmd_kmem();
+		ret = __cmd_kmem(session);
 	} else
 		usage_with_options(kmem_usage, kmem_options);
 
-	return 0;
+out_delete:
+	perf_session__delete(session);
+
+	return ret;
 }
 

  reply	other threads:[~2014-08-14  8:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12  6:40 [PATCHSET 00/13] perf tools: Fix vmlinux search path initialization Namhyung Kim
2014-08-12  6:40 ` [PATCH 01/13] perf script: Fix possible memory leaks Namhyung Kim
2014-08-13  6:21   ` Adrian Hunter
2014-08-13  7:05     ` Namhyung Kim
2014-08-13 19:27       ` Arnaldo Carvalho de Melo
2014-08-14  8:45   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 02/13] perf tools: Fix a memory leak in vmlinux_path__init() Namhyung Kim
2014-08-14  8:45   ` [tip:perf/core] perf symbols: " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 03/13] perf annotate: Move session handling out of __cmd_annotate() Namhyung Kim
2014-08-13 11:48   ` Jiri Olsa
2014-08-19  6:03     ` Namhyung Kim
2014-08-14  8:46   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 04/13] perf buildid-cache: Move session handling into cmd_buildid_cache() Namhyung Kim
2014-08-14  8:46   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 05/13] perf inject: Move session handling out of __cmd_inject() Namhyung Kim
2014-08-14  8:46   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 06/13] perf kmem: Move session handling out of __cmd_kmem() Namhyung Kim
2014-08-14  8:46   ` tip-bot for Namhyung Kim [this message]
2014-08-12  6:40 ` [PATCH 07/13] perf kvm: Move call to symbol__init() after creating session Namhyung Kim
2014-08-14  8:47   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 08/13] perf lock: " Namhyung Kim
2014-08-14  8:47   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 09/13] perf sched: " Namhyung Kim
2014-08-14  8:47   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 10/13] perf script: " Namhyung Kim
2014-08-14  8:47   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 11/13] perf timechart: " Namhyung Kim
2014-08-14  8:48   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 12/13] perf trace: " Namhyung Kim
2014-08-14  8:48   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-12  6:40 ` [PATCH 13/13] perf tools: Check recorded kernel version when finding vmlinux Namhyung Kim
2014-08-14  8:48   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-08-13 12:49 ` [PATCHSET 00/13] perf tools: Fix vmlinux search path initialization Jiri Olsa

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=tip-2b2b2c68c64fb9db392940b42355944064f2a4ca@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    --cc=tglx@linutronix.de \
    /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.