From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Kajol Jain <kjain@linux.ibm.com>
Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org, peterz@infradead.org,
mingo@redhat.com, jolsa@kernel.org, namhyung@kernel.org,
ak@linux.intel.com, linux-perf-users@vger.kernel.org,
maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com,
rnsastry@linux.ibm.com, yao.jin@linux.intel.com, ast@kernel.org,
daniel@iogearbox.net, songliubraving@fb.com,
kan.liang@linux.intel.com, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, paulus@samba.org
Subject: Re: [PATCH 2/4] tools/perf: Add new macros for mem_hops field
Date: Wed, 22 Dec 2021 09:36:53 -0300 [thread overview]
Message-ID: <YcMb5bUOW8BYw9fP@kernel.org> (raw)
In-Reply-To: <20211206091749.87585-3-kjain@linux.ibm.com>
Em Mon, Dec 06, 2021 at 02:47:47PM +0530, Kajol Jain escreveu:
> Add new macros for mem_hops field which can be used to
> represent remote-node, socket and board level details.
>
> Currently the code had macro for HOPS_0 which, corresponds
> to data coming from another core but same node.
> Add new macros for HOPS_1 to HOPS_3 to represent
> remote-node, socket and board level data.
>
> Also add corresponding strings in the mem_hops array to
> represent mem_hop field data in perf_mem__lvl_scnprintf function
>
> Incase mem_hops field is used, PERF_MEM_LVLNUM field also need
> to be set inorder to represent the data source. Hence printing
> data source via PERF_MEM_LVL field can be skip in that scenario.
>
> For ex: Encodings for mem_hops fields with L2 cache:
Thanks, applied.
- Arnaldo
> L2 - local L2
> L2 | REMOTE | HOPS_0 - remote core, same node L2
> L2 | REMOTE | HOPS_1 - remote node, same socket L2
> L2 | REMOTE | HOPS_2 - remote socket, same board L2
> L2 | REMOTE | HOPS_3 - remote board L2
>
> Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
> ---
> tools/include/uapi/linux/perf_event.h | 5 ++++-
> tools/perf/util/mem-events.c | 29 +++++++++++++++++----------
> 2 files changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
> index bd8860eeb291..4cd39aaccbe7 100644
> --- a/tools/include/uapi/linux/perf_event.h
> +++ b/tools/include/uapi/linux/perf_event.h
> @@ -1332,7 +1332,10 @@ union perf_mem_data_src {
>
> /* hop level */
> #define PERF_MEM_HOPS_0 0x01 /* remote core, same node */
> -/* 2-7 available */
> +#define PERF_MEM_HOPS_1 0x02 /* remote node, same socket */
> +#define PERF_MEM_HOPS_2 0x03 /* remote socket, same board */
> +#define PERF_MEM_HOPS_3 0x04 /* remote board */
> +/* 5-7 available */
> #define PERF_MEM_HOPS_SHIFT 43
>
> #define PERF_MEM_S(a, s) \
> diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
> index 3167b4628b6d..ed0ab838bcc5 100644
> --- a/tools/perf/util/mem-events.c
> +++ b/tools/perf/util/mem-events.c
> @@ -309,6 +309,9 @@ static const char * const mem_hops[] = {
> * to be set with mem_hops field.
> */
> "core, same node",
> + "node, same socket",
> + "socket, same board",
> + "board",
> };
>
> int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
> @@ -316,7 +319,7 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
> size_t i, l = 0;
> u64 m = PERF_MEM_LVL_NA;
> u64 hit, miss;
> - int printed;
> + int printed = 0;
>
> if (mem_info)
> m = mem_info->data_src.mem_lvl;
> @@ -335,18 +338,22 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
> l += 7;
> }
>
> - if (mem_info && mem_info->data_src.mem_hops)
> + /*
> + * Incase mem_hops field is set, we can skip printing data source via
> + * PERF_MEM_LVL namespace.
> + */
> + if (mem_info && mem_info->data_src.mem_hops) {
> l += scnprintf(out + l, sz - l, "%s ", mem_hops[mem_info->data_src.mem_hops]);
> -
> - printed = 0;
> - for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) {
> - if (!(m & 0x1))
> - continue;
> - if (printed++) {
> - strcat(out, " or ");
> - l += 4;
> + } else {
> + for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) {
> + if (!(m & 0x1))
> + continue;
> + if (printed++) {
> + strcat(out, " or ");
> + l += 4;
> + }
> + l += scnprintf(out + l, sz - l, mem_lvl[i]);
> }
> - l += scnprintf(out + l, sz - l, mem_lvl[i]);
> }
>
> if (mem_info && mem_info->data_src.mem_lvl_num) {
> --
> 2.27.0
--
- Arnaldo
next prev parent reply other threads:[~2021-12-22 12:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-06 9:17 [PATCH 0/4] perf: Add new macros for mem_hops field Kajol Jain
2021-12-06 9:17 ` [PATCH 1/4] " Kajol Jain
2021-12-10 8:21 ` Peter Zijlstra
2021-12-06 9:17 ` [PATCH 2/4] tools/perf: " Kajol Jain
2021-12-22 12:36 ` Arnaldo Carvalho de Melo [this message]
2021-12-06 9:17 ` [PATCH 3/4] powerpc/perf: Add encodings to represent data based on newer composite PERF_MEM_LVLNUM* fields Kajol Jain
2021-12-22 12:38 ` Arnaldo Carvalho de Melo
2021-12-06 9:17 ` [PATCH 4/4] powerpc/perf: Add data source encodings for power10 platform Kajol Jain
2021-12-22 12:41 ` Arnaldo Carvalho de Melo
2021-12-09 19:17 ` [PATCH 0/4] perf: Add new macros for mem_hops field Arnaldo Carvalho de Melo
2021-12-10 6:35 ` Michael Ellerman
2021-12-10 8:22 ` Peter Zijlstra
2021-12-21 12:14 ` Michael Ellerman
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=YcMb5bUOW8BYw9fP@kernel.org \
--to=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ast@kernel.org \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=rnsastry@linux.ibm.com \
--cc=songliubraving@fb.com \
--cc=yao.jin@linux.intel.com \
/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).