All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Stephane Eranian <eranian@google.com>,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH 05/15] perf tools: Introduce perf_mem__tlb_scnprintf function
Date: Wed, 24 Feb 2016 10:18:40 -0300	[thread overview]
Message-ID: <20160224131840.GD24505@kernel.org> (raw)
In-Reply-To: <1456303616-26926-6-git-send-email-jolsa@kernel.org>

Em Wed, Feb 24, 2016 at 09:46:46AM +0100, Jiri Olsa escreveu:
> Move meminfo's tlb display function into mem-events.c
> object, so it could be reused later from script code.
> 
> Link: http://lkml.kernel.org/n/tip-kdsvxdm3ucwknyvkluwavydh@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/util/mem-events.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
>  tools/perf/util/mem-events.h |  3 +++
>  tools/perf/util/sort.c       | 44 ++---------------------------------------
>  3 files changed, 52 insertions(+), 42 deletions(-)

Applied, with minimal adjusts due to other patch not being applied.

- Arnaldo
 
> diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
> index 3772a3a8a6ee..08c35dd7e335 100644
> --- a/tools/perf/util/mem-events.c
> +++ b/tools/perf/util/mem-events.c
> @@ -8,6 +8,7 @@
>  #include <api/fs/fs.h>
>  #include "mem-events.h"
>  #include "debug.h"
> +#include "symbol.h"
>  
>  unsigned int perf_mem_events__loads_ldlat = 30;
>  
> @@ -98,3 +99,49 @@ int perf_mem_events__init(void)
>  
>  	return found ? 0 : -ENOENT;
>  }
> +
> +static const char * const tlb_access[] = {
> +	"N/A",
> +	"HIT",
> +	"MISS",
> +	"L1",
> +	"L2",
> +	"Walker",
> +	"Fault",
> +};
> +
> +void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
> +{
> +	size_t l = 0, i;
> +	u64 m = PERF_MEM_TLB_NA;
> +	u64 hit, miss;
> +
> +	sz -= 1; /* -1 for null termination */
> +	out[0] = '\0';
> +
> +	if (mem_info)
> +		m = mem_info->data_src.mem_dtlb;
> +
> +	hit = m & PERF_MEM_TLB_HIT;
> +	miss = m & PERF_MEM_TLB_MISS;
> +
> +	/* already taken care of */
> +	m &= ~(PERF_MEM_TLB_HIT|PERF_MEM_TLB_MISS);
> +
> +	for (i = 0; m && i < ARRAY_SIZE(tlb_access); i++, m >>= 1) {
> +		if (!(m & 0x1))
> +			continue;
> +		if (l) {
> +			strcat(out, " or ");
> +			l += 4;
> +		}
> +		strncat(out, tlb_access[i], sz - l);
> +		l += strlen(tlb_access[i]);
> +	}
> +	if (*out == '\0')
> +		strcpy(out, "N/A");
> +	if (hit)
> +		strncat(out, " hit", sz - l);
> +	if (miss)
> +		strncat(out, " miss", sz - l);
> +}
> diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
> index 4ab437291589..b5067361a11c 100644
> --- a/tools/perf/util/mem-events.h
> +++ b/tools/perf/util/mem-events.h
> @@ -24,4 +24,7 @@ int perf_mem_events__parse(const char *str);
>  int perf_mem_events__init(void);
>  
>  char *perf_mem_events__name(int i);
> +
> +struct mem_info;
> +void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
>  #endif /* __PERF_MEM_EVENTS_H */
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 5388f7940474..160df202c34f 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -6,6 +6,7 @@
>  #include "evsel.h"
>  #include "evlist.h"
>  #include <traceevent/event-parse.h>
> +#include "mem-events.h"
>  
>  regex_t		parent_regex;
>  const char	default_parent_pattern[] = "^sys_|^do_page_fault";
> @@ -829,53 +830,12 @@ sort__tlb_cmp(struct hist_entry *left, struct hist_entry *right)
>  	return (int64_t)(data_src_r.mem_dtlb - data_src_l.mem_dtlb);
>  }
>  
> -static const char * const tlb_access[] = {
> -	"N/A",
> -	"HIT",
> -	"MISS",
> -	"L1",
> -	"L2",
> -	"Walker",
> -	"Fault",
> -};
> -
>  static int hist_entry__tlb_snprintf(struct hist_entry *he, char *bf,
>  				    size_t size, unsigned int width)
>  {
>  	char out[64];
> -	size_t sz = sizeof(out) - 1; /* -1 for null termination */
> -	size_t l = 0, i;
> -	u64 m = PERF_MEM_TLB_NA;
> -	u64 hit, miss;
> -
> -	out[0] = '\0';
> -
> -	if (he->mem_info)
> -		m = he->mem_info->data_src.mem_dtlb;
> -
> -	hit = m & PERF_MEM_TLB_HIT;
> -	miss = m & PERF_MEM_TLB_MISS;
> -
> -	/* already taken care of */
> -	m &= ~(PERF_MEM_TLB_HIT|PERF_MEM_TLB_MISS);
> -
> -	for (i = 0; m && i < ARRAY_SIZE(tlb_access); i++, m >>= 1) {
> -		if (!(m & 0x1))
> -			continue;
> -		if (l) {
> -			strcat(out, " or ");
> -			l += 4;
> -		}
> -		strncat(out, tlb_access[i], sz - l);
> -		l += strlen(tlb_access[i]);
> -	}
> -	if (*out == '\0')
> -		strcpy(out, "N/A");
> -	if (hit)
> -		strncat(out, " hit", sz - l);
> -	if (miss)
> -		strncat(out, " miss", sz - l);
>  
> +	perf_mem__tlb_scnprintf(out, sizeof(out), he->mem_info);
>  	return repsep_snprintf(bf, size, "%-*s", width, out);
>  }
>  
> -- 
> 2.4.3

  reply	other threads:[~2016-02-24 13:18 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-24  8:46 [PATCHv2 00/15] perf tools: Several memory events updates Jiri Olsa
2016-02-24  8:46 ` [PATCH 01/15] perf mem: Check for memory events support Jiri Olsa
2016-02-25  7:36   ` [tip:perf/core] perf mem record: " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 02/15] perf mem: Introduce perf_mem_events__name function Jiri Olsa
2016-02-25  7:36   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 03/15] perf mem: Add -l/--ldlat option Jiri Olsa
2016-02-24 13:14   ` Arnaldo Carvalho de Melo
2016-02-24 19:16     ` Jiri Olsa
2016-02-24  8:46 ` [PATCH 04/15] perf mem: Add -u/-k options Jiri Olsa
2016-02-24 13:17   ` Arnaldo Carvalho de Melo
2016-02-24 19:17     ` Jiri Olsa
2016-02-24  8:46 ` [PATCH 05/15] perf tools: Introduce perf_mem__tlb_scnprintf function Jiri Olsa
2016-02-24 13:18   ` Arnaldo Carvalho de Melo [this message]
2016-02-25  7:37   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 06/15] perf tools: Introduce perf_mem__lvl_scnprintf function Jiri Olsa
2016-02-25  7:37   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 07/15] perf tools: Introduce perf_mem__snp_scnprintf function Jiri Olsa
2016-02-25  7:37   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 08/15] perf tools: Introduce perf_mem__lck_scnprintf function Jiri Olsa
2016-02-25  7:38   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 09/15] perf tools: Change perf_mem__tlb_scnprintf to return nb of displayed bytes Jiri Olsa
2016-02-25  7:38   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 10/15] perf tools: Change perf_mem__lvl_scnprintf " Jiri Olsa
2016-02-25  7:38   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 11/15] perf tools: Change perf_mem__snp_scnprintf " Jiri Olsa
2016-02-25  7:39   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 12/15] perf tools: Change perf_mem__lck_scnprintf " Jiri Olsa
2016-02-25  7:39   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 13/15] perf script: Display data_src values Jiri Olsa
2016-02-24 13:34   ` Arnaldo Carvalho de Melo
2016-02-24 19:18     ` Jiri Olsa
2016-02-25  7:39   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-02-24  8:46 ` [PATCH 14/15] perf x86 intel: Add DATALA events into sysfs Jiri Olsa
2016-02-24 15:59   ` Andi Kleen
2016-02-24 18:54     ` Jiri Olsa
2016-02-24  8:46 ` [PATCH 15/15] perf mem: Add Intel DATALA memory events 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=20160224131840.GD24505@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=ak@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /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.