linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Leo Yan <leo.yan@linaro.org>
Cc: 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@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Kajol Jain <kjain@linux.ibm.com>,
	Li Huafei <lihuafei1@huawei.com>, Ali Saidi <alisaidi@amazon.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf mem: Print memory operation type
Date: Mon, 18 Apr 2022 11:45:07 -0300	[thread overview]
Message-ID: <Yl15c78idxjn3sKb@kernel.org> (raw)
In-Reply-To: <20220417124524.901148-1-leo.yan@linaro.org>

Em Sun, Apr 17, 2022 at 08:45:24PM +0800, Leo Yan escreveu:
> The memory operation types are not only for load and store, for easier
> reviewing the memory operation type, this patch prints out it.
> 
> Before:
>   ls 14753 [011]  3678.072400:          1      l1d-miss:         88000182 L1 miss|SNP N/A|TLB Walker hit|LCK No|BLK  N/A ffffa7c22b4b2a00 [unknown] ([kernel.kallsyms])
>   ls 14753 [011]  3678.072400:          1    l1d-access:         88000182 L1 miss|SNP N/A|TLB Walker hit|LCK No|BLK  N/A ffffa7c22b4b2a00 [unknown] ([kernel.kallsyms])
>   ls 14753 [011]  3678.072400:          1    tlb-access:         88000182 L1 miss|SNP N/A|TLB Walker hit|LCK No|BLK  N/A ffffa7c22b4b2a00 [unknown] ([kernel.kallsyms])
>   ls 14753 [011]  3678.072400:          1        memory:         88000182 L1 miss|SNP N/A|TLB Walker hit|LCK No|BLK  N/A ffffa7c22b4b2a00 [unknown] ([kernel.kallsyms])
> 
> After:
> 
>   ls 14753 [011]  3678.072400:          1      l1d-miss:         88000182 |OP LOAD|LVL L1 miss|SNP N/A|TLB Walker hit|LCK No|BLK  N/A ffffa7c22b4b2a00 [unknown] ([kernel.kallsyms])
>   ls 14753 [011]  3678.072400:          1    l1d-access:         88000182 |OP LOAD|LVL L1 miss|SNP N/A|TLB Walker hit|LCK No|BLK  N/A ffffa7c22b4b2a00 [unknown] ([kernel.kallsyms])
>   ls 14753 [011]  3678.072400:          1    tlb-access:         88000182 |OP LOAD|LVL L1 miss|SNP N/A|TLB Walker hit|LCK No|BLK  N/A ffffa7c22b4b2a00 [unknown] ([kernel.kallsyms])
>   ls 14753 [011]  3678.072400:          1        memory:         88000182 |OP LOAD|LVL L1 miss|SNP N/A|TLB Walker hit|LCK No|BLK  N/A ffffa7c22b4b2a00 [unknown] ([kernel.kallsyms])

Thanks, applied to perf/core.

- Arnaldo

 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/util/mem-events.c | 29 ++++++++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
> index e5e405185498..f8f234251f92 100644
> --- a/tools/perf/util/mem-events.c
> +++ b/tools/perf/util/mem-events.c
> @@ -314,6 +314,30 @@ static const char * const mem_hops[] = {
>  	"board",
>  };
>  
> +static int perf_mem__op_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
> +{
> +	u64 op = PERF_MEM_LOCK_NA;
> +	int l;
> +
> +	if (mem_info)
> +		op = mem_info->data_src.mem_op;
> +
> +	if (op & PERF_MEM_OP_NA)
> +		l = scnprintf(out, sz, "N/A");
> +	else if (op & PERF_MEM_OP_LOAD)
> +		l = scnprintf(out, sz, "LOAD");
> +	else if (op & PERF_MEM_OP_STORE)
> +		l = scnprintf(out, sz, "STORE");
> +	else if (op & PERF_MEM_OP_PFETCH)
> +		l = scnprintf(out, sz, "PFETCH");
> +	else if (op & PERF_MEM_OP_EXEC)
> +		l = scnprintf(out, sz, "EXEC");
> +	else
> +		l = scnprintf(out, sz, "No");
> +
> +	return l;
> +}
> +
>  int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
>  {
>  	size_t i, l = 0;
> @@ -466,7 +490,10 @@ int perf_script__meminfo_scnprintf(char *out, size_t sz, struct mem_info *mem_in
>  {
>  	int i = 0;
>  
> -	i += perf_mem__lvl_scnprintf(out, sz, mem_info);
> +	i += scnprintf(out, sz, "|OP ");
> +	i += perf_mem__op_scnprintf(out + i, sz - i, mem_info);
> +	i += scnprintf(out + i, sz - i, "|LVL ");
> +	i += perf_mem__lvl_scnprintf(out + i, sz, mem_info);
>  	i += scnprintf(out + i, sz - i, "|SNP ");
>  	i += perf_mem__snp_scnprintf(out + i, sz - i, mem_info);
>  	i += scnprintf(out + i, sz - i, "|TLB ");
> -- 
> 2.25.1

-- 

- Arnaldo

      reply	other threads:[~2022-04-18 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-17 12:45 [PATCH] perf mem: Print memory operation type Leo Yan
2022-04-18 14:45 ` Arnaldo Carvalho de Melo [this message]

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=Yl15c78idxjn3sKb@kernel.org \
    --to=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alisaidi@amazon.com \
    --cc=jolsa@kernel.org \
    --cc=kjain@linux.ibm.com \
    --cc=leo.yan@linaro.org \
    --cc=lihuafei1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).