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]
Message-ID: <20201204232739.GI3613628@krava>
Date:   Sat, 5 Dec 2020 00:27:39 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     kan.liang@...ux.intel.com
Cc:     acme@...nel.org, mingo@...nel.org, linux-kernel@...r.kernel.org,
        namhyung@...nel.org, eranian@...gle.com, ak@...ux.intel.com,
        mark.rutland@....com, will@...nel.org, mpe@...erman.id.au
Subject: Re: [PATCH V2 03/12] perf script: Support data page size

On Mon, Nov 30, 2020 at 09:27:54AM -0800, kan.liang@...ux.intel.com wrote:

SNIP

>  #endif /* __PERF_RECORD_H */
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 5cc722b6fe7c..e73f579f31d3 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -1260,10 +1260,30 @@ static void dump_event(struct evlist *evlist, union perf_event *event,
>  	       event->header.size, perf_event__name(event->header.type));
>  }
>  
> +char *get_page_size_name(u64 size, char *str)
> +{
> +	const char suffixes[5] = { 'B', 'K', 'M', 'G', 'T' };
> +	int i;
> +
> +	if (size == 0) {
> +		snprintf(str, PAGE_SIZE_NAME_LEN, "%s", "N/A");
> +		return str;
> +	}
> +	for (i = 0; i < 5; i++) {
> +		if (size < 1024)
> +			break;
> +		size /= 1024;
> +	}
> +
> +	snprintf(str, PAGE_SIZE_NAME_LEN, "%lu%c", size, suffixes[i]);
> +	return str;
> +}

we have the same code in unit_number__scnprintf,
you just need to add support for 'T' and 'N/A'

jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ