lkml.org 
[lkml]   [2020]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V2 03/12] perf script: Support data page size
On Mon, Nov 30, 2020 at 09:27:54AM -0800, kan.liang@linux.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

\
 
 \ /
  Last update: 2020-12-05 00:31    [W:0.766 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site