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


Groups > linux.kernel > #1214801 > unrolled thread

[PATCH V6 0/7] Freq/CPU%/CORE_BUSY% support

Started byKan Liang <kan.liang@intel.com>
First post2015-08-27 21:30 +0200
Last post2015-08-31 10:40 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V6 0/7] Freq/CPU%/CORE_BUSY% support Kan Liang <kan.liang@intel.com> - 2015-08-27 21:30 +0200
    [PATCH V6 3/7] perf,tools: rename perf_session_env and add backpointer to evlist Kan Liang <kan.liang@intel.com> - 2015-08-27 21:30 +0200
      Re: [PATCH V6 3/7] perf,tools: rename perf_session_env and add  backpointer to evlist Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-28 17:20 +0200
    [PATCH V6 6/7] perf,tools: caculate and save freq/CPU%/CORE_BUSY% in he_stat Kan Liang <kan.liang@intel.com> - 2015-08-27 21:30 +0200
    [PATCH V6 4/7] perf evsel: Add a backpointer to the evlist a evsel is in Kan Liang <kan.liang@intel.com> - 2015-08-27 21:30 +0200
      [tip:perf/core] perf evsel:   Add a backpointer to the evlist a evsel is in tip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com> - 2015-08-31 10:40 +0200

#1214801 — [PATCH V6 0/7] Freq/CPU%/CORE_BUSY% support

FromKan Liang <kan.liang@intel.com>
Date2015-08-27 21:30 +0200
Subject[PATCH V6 0/7] Freq/CPU%/CORE_BUSY% support
Message-ID<q2b21-5mX-3@gated-at.bofh.it>
This patch set supports per-sample freq/CPU%/CORE_BUSY% print in perf
report -D and --stdio.
For printing these information, the perf.data file must have been obtained
by group read and using special events cycles, ref-cycles, msr/tsc/,
msr/aperf/ or msr/mperf/.

 - Freq (MHz): The frequency during the sample interval. Needs cycles
   ref-cycles event.
 - CPU%: CPU utilization during the sample interval. Needs ref-cycles and
   msr/tsc/ events.
 - CORE_BUSY%: actual percent performance (APERF/MPERF%) during the
   sample interval. Needs msr/aperf/ and msr/mperf/ events.

Here is an example:

$ perf record -e
'{cycles,ref-cycles,msr/tsc/,msr/mperf/,msr/aperf/}:S' ~/tchain_edit

$ perf report --stdio --group --show-freq-perf

                                 Overhead   FREQ MHz   CPU%  CORE_BUSY%
Command      Shared Object     Symbol
 ........................................  .........  .....  ..........
...........  ................  ......................

    99.54%  99.54%  99.53%  99.53%  99.53%       2301     96         99
tchain_edit  tchain_edit       [.] f3
     0.20%   0.20%   0.20%   0.20%   0.20%       2301     98         99
tchain_edit  tchain_edit       [.] f2
     0.05%   0.05%   0.05%   0.05%   0.05%       2300     98         99
tchain_edit  [kernel.vmlinux]  [k] read_tsc

Changes since V1:
 - Save cpu max freq to header when recording
 - Read cpu max freq and msr type from header when reporting

Changes since V2:
 - Introduce generic FEAT for CPU related data stored
 - Make cpu max freq and msr type part of perf_session_env
 - rename cpu_u to cpu_util
 - Don't save sample value in perf_sample and discards new iterator.
   Calculating the freq_perf_info in add_entry_cb callback
 - Introduce symbol_conf.freq_perf_type for related hpp column visibility

Changes since V3:
 - add a identifier 'tag' for CPU attributes, max frequency.
 - add backpointers to evlist for env, and evsel for evlist.
 - Use bitmask for freq_perf_type
 - Replace macros by functions to caculate freq, cpu_util and core_busy
 - Move all caculation codes under symbol_conf.show_freq_perf condition.

Changes since V4:
 - Store cpu attributes id as tag and more readable cpu_attr

Changes since V5:
 - Rename freq to max_freq and use it
 - Add a loop in process_cpu_attributes to facility future extension

Arnaldo Carvalho de Melo (1):
  perf evsel: Add a backpointer to the evlist a evsel is in

Kan Liang (6):
  perf,tools: introduce generic FEAT for CPU attributes
  perf,tools: read msr pmu type from header.
  perf,tools: rename perf_session_env and add backpointer to evlist
  perf,tools: Dump per-sample freq/CPU%/CORE_BUSY% in report -D
  perf,tools: caculate and save freq/CPU%/CORE_BUSY% in he_stat
  perf,tools: Show freq/CPU%/CORE_BUSY% in perf report --stdio

 tools/perf/Documentation/perf-report.txt | 12 ++++++
 tools/perf/arch/common.c                 |  4 +-
 tools/perf/arch/common.h                 |  2 +-
 tools/perf/builtin-report.c              | 56 +++++++++++++++++++++++++
 tools/perf/ui/browser.h                  |  4 +-
 tools/perf/ui/browsers/header.c          |  2 +-
 tools/perf/ui/browsers/hists.c           | 12 +++---
 tools/perf/ui/hist.c                     | 71 +++++++++++++++++++++++++++++---
 tools/perf/util/cpumap.c                 | 32 ++++++++++++++
 tools/perf/util/cpumap.h                 |  1 +
 tools/perf/util/evlist.c                 |  2 +
 tools/perf/util/evlist.h                 |  1 +
 tools/perf/util/evsel.c                  |  2 +
 tools/perf/util/evsel.h                  |  4 ++
 tools/perf/util/header.c                 | 63 ++++++++++++++++++++++++++++
 tools/perf/util/header.h                 | 17 +++++++-
 tools/perf/util/hist.h                   |  7 +++-
 tools/perf/util/session.c                | 36 +++++++++++++---
 tools/perf/util/session.h                | 64 ++++++++++++++++++++++++++++
 tools/perf/util/sort.c                   |  3 ++
 tools/perf/util/sort.h                   |  3 ++
 tools/perf/util/symbol.c                 |  4 +-
 tools/perf/util/symbol.h                 | 16 +++++--
 23 files changed, 387 insertions(+), 31 deletions(-)

-- 
1.8.3.1

--
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]


#1214802 — [PATCH V6 3/7] perf,tools: rename perf_session_env and add backpointer to evlist

FromKan Liang <kan.liang@intel.com>
Date2015-08-27 21:30 +0200
Subject[PATCH V6 3/7] perf,tools: rename perf_session_env and add backpointer to evlist
Message-ID<q2b23-5mX-31@gated-at.bofh.it>
In reply to#1214801
From: Kan Liang <kan.liang@intel.com>

Rename perf_session_env to perf_env.
Add backpointer to evlist, so we can easily access env when processing
something where we have a evsel or evlist.

Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/arch/common.c        |  4 ++--
 tools/perf/arch/common.h        |  2 +-
 tools/perf/ui/browser.h         |  4 ++--
 tools/perf/ui/browsers/header.c |  2 +-
 tools/perf/ui/browsers/hists.c  | 12 ++++++------
 tools/perf/util/evlist.h        |  1 +
 tools/perf/util/header.c        |  1 +
 tools/perf/util/header.h        |  4 ++--
 tools/perf/util/hist.h          |  4 ++--
 tools/perf/util/session.c       |  2 +-
 tools/perf/util/symbol.c        |  4 ++--
 tools/perf/util/symbol.h        |  4 ++--
 12 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index b7bb42c..b00dfd92 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -128,7 +128,7 @@ static const char *normalize_arch(char *arch)
 	return arch;
 }
 
-static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
+static int perf_session_env__lookup_binutils_path(struct perf_env *env,
 						  const char *name,
 						  const char **path)
 {
@@ -206,7 +206,7 @@ out_error:
 	return -1;
 }
 
-int perf_session_env__lookup_objdump(struct perf_session_env *env)
+int perf_session_env__lookup_objdump(struct perf_env *env)
 {
 	/*
 	 * For live mode, env->arch will be NULL and we can use
diff --git a/tools/perf/arch/common.h b/tools/perf/arch/common.h
index ede246e..20176df 100644
--- a/tools/perf/arch/common.h
+++ b/tools/perf/arch/common.h
@@ -5,6 +5,6 @@
 
 extern const char *objdump_path;
 
-int perf_session_env__lookup_objdump(struct perf_session_env *env);
+int perf_session_env__lookup_objdump(struct perf_env *env);
 
 #endif /* ARCH_PERF_COMMON_H */
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
index 52be871..f3cef56 100644
--- a/tools/perf/ui/browser.h
+++ b/tools/perf/ui/browser.h
@@ -61,8 +61,8 @@ int ui_browser__help_window(struct ui_browser *browser, const char *text);
 bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text);
 int ui_browser__input_window(const char *title, const char *text, char *input,
 			     const char *exit_msg, int delay_sec);
-struct perf_session_env;
-int tui__header_window(struct perf_session_env *env);
+struct perf_env;
+int tui__header_window(struct perf_env *env);
 
 void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
 unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
diff --git a/tools/perf/ui/browsers/header.c b/tools/perf/ui/browsers/header.c
index f106817..edbeaaf 100644
--- a/tools/perf/ui/browsers/header.c
+++ b/tools/perf/ui/browsers/header.c
@@ -91,7 +91,7 @@ static int ui__list_menu(int argc, char * const argv[])
 	return list_menu__run(&menu);
 }
 
-int tui__header_window(struct perf_session_env *env)
+int tui__header_window(struct perf_env *env)
 {
 	int i, argc = 0;
 	char **argv;
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 10c7ec0..cf86f2d 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -26,7 +26,7 @@ struct hist_browser {
 	struct map_symbol   *selection;
 	struct hist_browser_timer *hbt;
 	struct pstack	    *pstack;
-	struct perf_session_env *env;
+	struct perf_env *env;
 	int		     print_seq;
 	bool		     show_dso;
 	bool		     show_headers;
@@ -1214,7 +1214,7 @@ static int hist_browser__dump(struct hist_browser *browser)
 
 static struct hist_browser *hist_browser__new(struct hists *hists,
 					      struct hist_browser_timer *hbt,
-					      struct perf_session_env *env)
+					      struct perf_env *env)
 {
 	struct hist_browser *browser = zalloc(sizeof(*browser));
 
@@ -1695,7 +1695,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				    bool left_exits,
 				    struct hist_browser_timer *hbt,
 				    float min_pcnt,
-				    struct perf_session_env *env)
+				    struct perf_env *env)
 {
 	struct hists *hists = evsel__hists(evsel);
 	struct hist_browser *browser = hist_browser__new(hists, hbt, env);
@@ -2016,7 +2016,7 @@ struct perf_evsel_menu {
 	struct perf_evsel *selection;
 	bool lost_events, lost_events_warned;
 	float min_pcnt;
-	struct perf_session_env *env;
+	struct perf_env *env;
 };
 
 static void perf_evsel_menu__write(struct ui_browser *browser,
@@ -2169,7 +2169,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
 					   int nr_entries, const char *help,
 					   struct hist_browser_timer *hbt,
 					   float min_pcnt,
-					   struct perf_session_env *env)
+					   struct perf_env *env)
 {
 	struct perf_evsel *pos;
 	struct perf_evsel_menu menu = {
@@ -2202,7 +2202,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
 int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
 				  struct hist_browser_timer *hbt,
 				  float min_pcnt,
-				  struct perf_session_env *env)
+				  struct perf_env *env)
 {
 	int nr_entries = evlist->nr_entries;
 
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 436e358..b39a619 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -56,6 +56,7 @@ struct perf_evlist {
 	struct cpu_map	  *cpus;
 	struct perf_evsel *selected;
 	struct events_stats stats;
+	struct perf_env	*env;
 };
 
 struct perf_evsel_str_handler {
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 8df0582..c3c79cb 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2576,6 +2576,7 @@ int perf_session__read_header(struct perf_session *session)
 	if (session->evlist == NULL)
 		return -ENOMEM;
 
+	session->evlist->env = &header->env;
 	if (perf_data_file__is_pipe(file))
 		return perf_header__read_pipe(session);
 
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index a2c8c90..921b3ee 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -72,7 +72,7 @@ enum perf_header_cpu_attr {
 	PERF_HEADER_CPU_ATTR_MAX,
 };
 
-struct perf_session_env {
+struct perf_env {
 	char			*hostname;
 	char			*os_release;
 	char			*version;
@@ -111,7 +111,7 @@ struct perf_header {
 	u64				data_size;
 	u64				feat_offset;
 	DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
-	struct perf_session_env 	env;
+	struct perf_env 	env;
 };
 
 struct perf_evlist;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index bc528d5..de6d58e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -313,7 +313,7 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
 int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
 				  struct hist_browser_timer *hbt,
 				  float min_pcnt,
-				  struct perf_session_env *env);
+				  struct perf_env *env);
 int script_browse(const char *script_opt);
 #else
 static inline
@@ -321,7 +321,7 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,
 				  const char *help __maybe_unused,
 				  struct hist_browser_timer *hbt __maybe_unused,
 				  float min_pcnt __maybe_unused,
-				  struct perf_session_env *env __maybe_unused)
+				  struct perf_env *env __maybe_unused)
 {
 	return 0;
 }
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 18722e7..8a4537e 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -170,7 +170,7 @@ static void perf_session__delete_threads(struct perf_session *session)
 	machine__delete_threads(&session->machines.host);
 }
 
-static void perf_session_env__exit(struct perf_session_env *env)
+static void perf_session_env__exit(struct perf_env *env)
 {
 	zfree(&env->hostname);
 	zfree(&env->os_release);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 725640f..f14c06e 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1843,7 +1843,7 @@ static void vmlinux_path__exit(void)
 	zfree(&vmlinux_path);
 }
 
-static int vmlinux_path__init(struct perf_session_env *env)
+static int vmlinux_path__init(struct perf_env *env)
 {
 	struct utsname uts;
 	char bf[PATH_MAX];
@@ -1954,7 +1954,7 @@ static bool symbol__read_kptr_restrict(void)
 	return value;
 }
 
-int symbol__init(struct perf_session_env *env)
+int symbol__init(struct perf_env *env)
 {
 	const char *symfs;
 
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index a4cde92..440ba8a 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -252,8 +252,8 @@ int modules__parse(const char *filename, void *arg,
 int filename__read_debuglink(const char *filename, char *debuglink,
 			     size_t size);
 
-struct perf_session_env;
-int symbol__init(struct perf_session_env *env);
+struct perf_env;
+int symbol__init(struct perf_env *env);
 void symbol__exit(void);
 void symbol__elf_init(void);
 struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
-- 
1.8.3.1

--
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]


#1215394 — Re: [PATCH V6 3/7] perf,tools: rename perf_session_env and add backpointer to evlist

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-28 17:20 +0200
SubjectRe: [PATCH V6 3/7] perf,tools: rename perf_session_env and add backpointer to evlist
Message-ID<q2tBE-71T-19@gated-at.bofh.it>
In reply to#1214802
Em Thu, Aug 27, 2015 at 08:07:39AM -0400, Kan Liang escreveu:
> From: Kan Liang <kan.liang@intel.com>
> 
> Rename perf_session_env to perf_env.

the above is a separate patch.

> Add backpointer to evlist, so we can easily access env when processing
> something where we have a evsel or evlist.

This one is another, please break it down. I was almost cherry picking
this one :-)

Try to avoid folding multiple stuff in a single patch, we have to try
hard to ease reviewing, as the upstream you go, the more patches one has
to process, anything you can do to ease the reviewing process adds up.

Also please try collecting "Acked-by" as you go bumping your patch
series version, i.e. maybe Jiri has acked some of the patches when you
published V4 or V5, those should be here, kudos if you've already did
this.

- Arnaldo

> 
> Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> Signed-off-by: Kan Liang <kan.liang@intel.com>
> ---
>  tools/perf/arch/common.c        |  4 ++--
>  tools/perf/arch/common.h        |  2 +-
>  tools/perf/ui/browser.h         |  4 ++--
>  tools/perf/ui/browsers/header.c |  2 +-
>  tools/perf/ui/browsers/hists.c  | 12 ++++++------
>  tools/perf/util/evlist.h        |  1 +
>  tools/perf/util/header.c        |  1 +
>  tools/perf/util/header.h        |  4 ++--
>  tools/perf/util/hist.h          |  4 ++--
>  tools/perf/util/session.c       |  2 +-
>  tools/perf/util/symbol.c        |  4 ++--
>  tools/perf/util/symbol.h        |  4 ++--
>  12 files changed, 23 insertions(+), 21 deletions(-)
> 
> diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
> index b7bb42c..b00dfd92 100644
> --- a/tools/perf/arch/common.c
> +++ b/tools/perf/arch/common.c
> @@ -128,7 +128,7 @@ static const char *normalize_arch(char *arch)
>  	return arch;
>  }
>  
> -static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
> +static int perf_session_env__lookup_binutils_path(struct perf_env *env,
>  						  const char *name,
>  						  const char **path)
>  {
> @@ -206,7 +206,7 @@ out_error:
>  	return -1;
>  }
>  
> -int perf_session_env__lookup_objdump(struct perf_session_env *env)
> +int perf_session_env__lookup_objdump(struct perf_env *env)
>  {
>  	/*
>  	 * For live mode, env->arch will be NULL and we can use
> diff --git a/tools/perf/arch/common.h b/tools/perf/arch/common.h
> index ede246e..20176df 100644
> --- a/tools/perf/arch/common.h
> +++ b/tools/perf/arch/common.h
> @@ -5,6 +5,6 @@
>  
>  extern const char *objdump_path;
>  
> -int perf_session_env__lookup_objdump(struct perf_session_env *env);
> +int perf_session_env__lookup_objdump(struct perf_env *env);
>  
>  #endif /* ARCH_PERF_COMMON_H */
> diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
> index 52be871..f3cef56 100644
> --- a/tools/perf/ui/browser.h
> +++ b/tools/perf/ui/browser.h
> @@ -61,8 +61,8 @@ int ui_browser__help_window(struct ui_browser *browser, const char *text);
>  bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text);
>  int ui_browser__input_window(const char *title, const char *text, char *input,
>  			     const char *exit_msg, int delay_sec);
> -struct perf_session_env;
> -int tui__header_window(struct perf_session_env *env);
> +struct perf_env;
> +int tui__header_window(struct perf_env *env);
>  
>  void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
>  unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
> diff --git a/tools/perf/ui/browsers/header.c b/tools/perf/ui/browsers/header.c
> index f106817..edbeaaf 100644
> --- a/tools/perf/ui/browsers/header.c
> +++ b/tools/perf/ui/browsers/header.c
> @@ -91,7 +91,7 @@ static int ui__list_menu(int argc, char * const argv[])
>  	return list_menu__run(&menu);
>  }
>  
> -int tui__header_window(struct perf_session_env *env)
> +int tui__header_window(struct perf_env *env)
>  {
>  	int i, argc = 0;
>  	char **argv;
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index 10c7ec0..cf86f2d 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -26,7 +26,7 @@ struct hist_browser {
>  	struct map_symbol   *selection;
>  	struct hist_browser_timer *hbt;
>  	struct pstack	    *pstack;
> -	struct perf_session_env *env;
> +	struct perf_env *env;
>  	int		     print_seq;
>  	bool		     show_dso;
>  	bool		     show_headers;
> @@ -1214,7 +1214,7 @@ static int hist_browser__dump(struct hist_browser *browser)
>  
>  static struct hist_browser *hist_browser__new(struct hists *hists,
>  					      struct hist_browser_timer *hbt,
> -					      struct perf_session_env *env)
> +					      struct perf_env *env)
>  {
>  	struct hist_browser *browser = zalloc(sizeof(*browser));
>  
> @@ -1695,7 +1695,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
>  				    bool left_exits,
>  				    struct hist_browser_timer *hbt,
>  				    float min_pcnt,
> -				    struct perf_session_env *env)
> +				    struct perf_env *env)
>  {
>  	struct hists *hists = evsel__hists(evsel);
>  	struct hist_browser *browser = hist_browser__new(hists, hbt, env);
> @@ -2016,7 +2016,7 @@ struct perf_evsel_menu {
>  	struct perf_evsel *selection;
>  	bool lost_events, lost_events_warned;
>  	float min_pcnt;
> -	struct perf_session_env *env;
> +	struct perf_env *env;
>  };
>  
>  static void perf_evsel_menu__write(struct ui_browser *browser,
> @@ -2169,7 +2169,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
>  					   int nr_entries, const char *help,
>  					   struct hist_browser_timer *hbt,
>  					   float min_pcnt,
> -					   struct perf_session_env *env)
> +					   struct perf_env *env)
>  {
>  	struct perf_evsel *pos;
>  	struct perf_evsel_menu menu = {
> @@ -2202,7 +2202,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
>  int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
>  				  struct hist_browser_timer *hbt,
>  				  float min_pcnt,
> -				  struct perf_session_env *env)
> +				  struct perf_env *env)
>  {
>  	int nr_entries = evlist->nr_entries;
>  
> diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
> index 436e358..b39a619 100644
> --- a/tools/perf/util/evlist.h
> +++ b/tools/perf/util/evlist.h
> @@ -56,6 +56,7 @@ struct perf_evlist {
>  	struct cpu_map	  *cpus;
>  	struct perf_evsel *selected;
>  	struct events_stats stats;
> +	struct perf_env	*env;
>  };
>  
>  struct perf_evsel_str_handler {
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index 8df0582..c3c79cb 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -2576,6 +2576,7 @@ int perf_session__read_header(struct perf_session *session)
>  	if (session->evlist == NULL)
>  		return -ENOMEM;
>  
> +	session->evlist->env = &header->env;
>  	if (perf_data_file__is_pipe(file))
>  		return perf_header__read_pipe(session);
>  
> diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
> index a2c8c90..921b3ee 100644
> --- a/tools/perf/util/header.h
> +++ b/tools/perf/util/header.h
> @@ -72,7 +72,7 @@ enum perf_header_cpu_attr {
>  	PERF_HEADER_CPU_ATTR_MAX,
>  };
>  
> -struct perf_session_env {
> +struct perf_env {
>  	char			*hostname;
>  	char			*os_release;
>  	char			*version;
> @@ -111,7 +111,7 @@ struct perf_header {
>  	u64				data_size;
>  	u64				feat_offset;
>  	DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
> -	struct perf_session_env 	env;
> +	struct perf_env 	env;
>  };
>  
>  struct perf_evlist;
> diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
> index bc528d5..de6d58e 100644
> --- a/tools/perf/util/hist.h
> +++ b/tools/perf/util/hist.h
> @@ -313,7 +313,7 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
>  int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
>  				  struct hist_browser_timer *hbt,
>  				  float min_pcnt,
> -				  struct perf_session_env *env);
> +				  struct perf_env *env);
>  int script_browse(const char *script_opt);
>  #else
>  static inline
> @@ -321,7 +321,7 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,
>  				  const char *help __maybe_unused,
>  				  struct hist_browser_timer *hbt __maybe_unused,
>  				  float min_pcnt __maybe_unused,
> -				  struct perf_session_env *env __maybe_unused)
> +				  struct perf_env *env __maybe_unused)
>  {
>  	return 0;
>  }
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 18722e7..8a4537e 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -170,7 +170,7 @@ static void perf_session__delete_threads(struct perf_session *session)
>  	machine__delete_threads(&session->machines.host);
>  }
>  
> -static void perf_session_env__exit(struct perf_session_env *env)
> +static void perf_session_env__exit(struct perf_env *env)
>  {
>  	zfree(&env->hostname);
>  	zfree(&env->os_release);
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 725640f..f14c06e 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -1843,7 +1843,7 @@ static void vmlinux_path__exit(void)
>  	zfree(&vmlinux_path);
>  }
>  
> -static int vmlinux_path__init(struct perf_session_env *env)
> +static int vmlinux_path__init(struct perf_env *env)
>  {
>  	struct utsname uts;
>  	char bf[PATH_MAX];
> @@ -1954,7 +1954,7 @@ static bool symbol__read_kptr_restrict(void)
>  	return value;
>  }
>  
> -int symbol__init(struct perf_session_env *env)
> +int symbol__init(struct perf_env *env)
>  {
>  	const char *symfs;
>  
> diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
> index a4cde92..440ba8a 100644
> --- a/tools/perf/util/symbol.h
> +++ b/tools/perf/util/symbol.h
> @@ -252,8 +252,8 @@ int modules__parse(const char *filename, void *arg,
>  int filename__read_debuglink(const char *filename, char *debuglink,
>  			     size_t size);
>  
> -struct perf_session_env;
> -int symbol__init(struct perf_session_env *env);
> +struct perf_env;
> +int symbol__init(struct perf_env *env);
>  void symbol__exit(void);
>  void symbol__elf_init(void);
>  struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
> -- 
> 1.8.3.1
--
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]


#1214803 — [PATCH V6 6/7] perf,tools: caculate and save freq/CPU%/CORE_BUSY% in he_stat

FromKan Liang <kan.liang@intel.com>
Date2015-08-27 21:30 +0200
Subject[PATCH V6 6/7] perf,tools: caculate and save freq/CPU%/CORE_BUSY% in he_stat
Message-ID<q2b23-5mX-33@gated-at.bofh.it>
In reply to#1214801
From: Kan Liang <kan.liang@intel.com>

Caculate freq/CPU%/CORE_BUSY% in add_entry_cb, and update the value in
he_stat.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/builtin-report.c | 36 ++++++++++++++++++++++++++++++++++++
 tools/perf/util/sort.h      |  3 +++
 2 files changed, 39 insertions(+)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 62b285e..e108729 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -89,6 +89,38 @@ static int report__config(const char *var, const char *value, void *cb)
 	return perf_default_config(var, value, cb);
 }
 
+static void set_he_freq_perf(struct perf_session *session,
+			     struct hist_entry_iter *iter)
+{
+	struct hist_entry *he = iter->he;
+	struct perf_evsel *evsel = iter->evsel;
+	struct perf_evsel *leader = evsel;
+	struct perf_sample *sample = iter->sample;
+	struct perf_evlist *evlist = session->evlist;
+	u64 cpu_max_freq = session->header.env.cpu.max_freq;
+	perf_freq_t data = { 0 };
+	u64 nr = 0;
+
+	perf_freq__init(session->header.env.msr_pmu_type,
+			evsel, data,
+			sample->read.group.values[nr].value);
+	evlist__for_each_continue(evlist, evsel) {
+		if ((evsel->leader != leader) ||
+		     (++nr >= sample->read.group.nr))
+			break;
+		perf_freq__init(session->header.env.msr_pmu_type,
+				evsel, data,
+				sample->read.group.values[nr].value);
+	}
+
+	if (perf_freq__has_freq(data))
+		he->stat.freq = perf_freq__get_freq(data, cpu_max_freq/1000);
+	if (perf_freq__has_cpu_util(data))
+		he->stat.cpu_util = perf_freq__get_cpu_util(data);
+	if (perf_freq__has_core_busy(data))
+		he->stat.core_busy = perf_freq__get_core_busy(data);
+}
+
 static int hist_iter__report_callback(struct hist_entry_iter *iter,
 				      struct addr_location *al, bool single,
 				      void *arg)
@@ -100,6 +132,10 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
 	struct mem_info *mi;
 	struct branch_info *bi;
 
+	if ((iter->ops == &hist_iter_normal) &&
+	    perf_evsel__is_group_leader(evsel))
+		set_he_freq_perf(rep->session, iter);
+
 	if (!ui__has_annotation())
 		return 0;
 
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 3c2a399..9ed52e6 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -54,6 +54,9 @@ struct he_stat {
 	u64			period_guest_us;
 	u64			weight;
 	u32			nr_events;
+	u64			freq;
+	u64			cpu_util;
+	u64			core_busy;
 };
 
 struct hist_entry_diff {
-- 
1.8.3.1

--
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]


#1214804 — [PATCH V6 4/7] perf evsel: Add a backpointer to the evlist a evsel is in

FromKan Liang <kan.liang@intel.com>
Date2015-08-27 21:30 +0200
Subject[PATCH V6 4/7] perf evsel: Add a backpointer to the evlist a evsel is in
Message-ID<q2b23-5mX-35@gated-at.bofh.it>
In reply to#1214801
From: Arnaldo Carvalho de Melo <acme@redhat.com>

So that functions that deal primarily with an evsel to access
information that concerns the whole evlist it is in.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/util/evlist.c | 2 ++
 tools/perf/util/evsel.c  | 2 ++
 tools/perf/util/evsel.h  | 4 ++++
 3 files changed, 8 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 373f65b..a8cc440 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -98,6 +98,7 @@ static void perf_evlist__purge(struct perf_evlist *evlist)
 
 	evlist__for_each_safe(evlist, n, pos) {
 		list_del_init(&pos->node);
+		pos->evlist = NULL;
 		perf_evsel__delete(pos);
 	}
 
@@ -125,6 +126,7 @@ void perf_evlist__delete(struct perf_evlist *evlist)
 
 void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
 {
+	entry->evlist = evlist;
 	list_add_tail(&entry->node, &evlist->entries);
 	entry->idx = evlist->nr_entries;
 	entry->tracking = !entry->idx;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index b096ef7..bac25f4 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -206,6 +206,7 @@ void perf_evsel__init(struct perf_evsel *evsel,
 	evsel->leader	   = evsel;
 	evsel->unit	   = "";
 	evsel->scale	   = 1.0;
+	evsel->evlist	   = NULL;
 	INIT_LIST_HEAD(&evsel->node);
 	INIT_LIST_HEAD(&evsel->config_terms);
 	perf_evsel__object.init(evsel);
@@ -1026,6 +1027,7 @@ void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
 void perf_evsel__exit(struct perf_evsel *evsel)
 {
 	assert(list_empty(&evsel->node));
+	assert(evsel->evlist == NULL);
 	perf_evsel__free_fd(evsel);
 	perf_evsel__free_id(evsel);
 	perf_evsel__free_config_terms(evsel);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 93ac6b1..298e6bb 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -60,6 +60,9 @@ struct perf_evsel_config_term {
 
 /** struct perf_evsel - event selector
  *
+ * @evlist - evlist this evsel is in, if it is in one.
+ * @node - To insert it into evlist->entries or in other list_heads, say in
+ *         the event parsing routines.
  * @name - Can be set to retain the original event name passed by the user,
  *         so that when showing results in tools such as 'perf stat', we
  *         show the name used, not some alias.
@@ -73,6 +76,7 @@ struct perf_evsel_config_term {
  */
 struct perf_evsel {
 	struct list_head	node;
+	struct perf_evlist	*evlist;
 	struct perf_event_attr	attr;
 	char			*filter;
 	struct xyarray		*fd;
-- 
1.8.3.1

--
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]


#1216101 — [tip:perf/core] perf evsel: Add a backpointer to the evlist a evsel is in

Fromtip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com>
Date2015-08-31 10:40 +0200
Subject[tip:perf/core] perf evsel: Add a backpointer to the evlist a evsel is in
Message-ID<q3sNc-2pJ-29@gated-at.bofh.it>
In reply to#1214804
Commit-ID:  d49e4695077278ee3016cd242967de23072ec331
Gitweb:     http://git.kernel.org/tip/d49e4695077278ee3016cd242967de23072ec331
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Thu, 27 Aug 2015 08:07:40 -0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 28 Aug 2015 14:53:49 -0300

perf evsel: Add a backpointer to the evlist a evsel is in

So that functions that deal primarily with an evsel to access
information that concerns the whole evlist it is in.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1440677263-21954-5-git-send-email-kan.liang@intel.com
Signed-off-by: Kan Liang <kan.liang@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 2 ++
 tools/perf/util/evsel.c  | 2 ++
 tools/perf/util/evsel.h  | 4 ++++
 3 files changed, 8 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e9a5d43..8d00039 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -98,6 +98,7 @@ static void perf_evlist__purge(struct perf_evlist *evlist)
 
 	evlist__for_each_safe(evlist, n, pos) {
 		list_del_init(&pos->node);
+		pos->evlist = NULL;
 		perf_evsel__delete(pos);
 	}
 
@@ -125,6 +126,7 @@ void perf_evlist__delete(struct perf_evlist *evlist)
 
 void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
 {
+	entry->evlist = evlist;
 	list_add_tail(&entry->node, &evlist->entries);
 	entry->idx = evlist->nr_entries;
 	entry->tracking = !entry->idx;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index b096ef7..bac25f4 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -206,6 +206,7 @@ void perf_evsel__init(struct perf_evsel *evsel,
 	evsel->leader	   = evsel;
 	evsel->unit	   = "";
 	evsel->scale	   = 1.0;
+	evsel->evlist	   = NULL;
 	INIT_LIST_HEAD(&evsel->node);
 	INIT_LIST_HEAD(&evsel->config_terms);
 	perf_evsel__object.init(evsel);
@@ -1026,6 +1027,7 @@ void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
 void perf_evsel__exit(struct perf_evsel *evsel)
 {
 	assert(list_empty(&evsel->node));
+	assert(evsel->evlist == NULL);
 	perf_evsel__free_fd(evsel);
 	perf_evsel__free_id(evsel);
 	perf_evsel__free_config_terms(evsel);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 93ac6b1..298e6bb 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -60,6 +60,9 @@ struct perf_evsel_config_term {
 
 /** struct perf_evsel - event selector
  *
+ * @evlist - evlist this evsel is in, if it is in one.
+ * @node - To insert it into evlist->entries or in other list_heads, say in
+ *         the event parsing routines.
  * @name - Can be set to retain the original event name passed by the user,
  *         so that when showing results in tools such as 'perf stat', we
  *         show the name used, not some alias.
@@ -73,6 +76,7 @@ struct perf_evsel_config_term {
  */
 struct perf_evsel {
 	struct list_head	node;
+	struct perf_evlist	*evlist;
 	struct perf_event_attr	attr;
 	char			*filter;
 	struct xyarray		*fd;
--
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