lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 22 Dec 2021 09:36:53 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Kajol Jain <kjain@...ux.ibm.com>
Cc:     mpe@...erman.id.au, linuxppc-dev@...ts.ozlabs.org,
        linux-kernel@...r.kernel.org, peterz@...radead.org,
        mingo@...hat.com, jolsa@...nel.org, namhyung@...nel.org,
        ak@...ux.intel.com, linux-perf-users@...r.kernel.org,
        maddy@...ux.ibm.com, atrajeev@...ux.vnet.ibm.com,
        rnsastry@...ux.ibm.com, yao.jin@...ux.intel.com, ast@...nel.org,
        daniel@...earbox.net, songliubraving@...com,
        kan.liang@...ux.intel.com, mark.rutland@....com,
        alexander.shishkin@...ux.intel.com, paulus@...ba.org
Subject: Re: [PATCH 2/4] tools/perf: Add new macros for mem_hops field

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@...ux.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ