Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp76565imm; Fri, 10 Aug 2018 07:53:33 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzZooxkdkLdbYcomBm2SaaJ4PBddHmD3xmluZWImi0MmD4cvJ+Ucog5505nLKTfV8Z4uvJC X-Received: by 2002:a62:1449:: with SMTP id 70-v6mr7452314pfu.222.1533912813025; Fri, 10 Aug 2018 07:53:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533912812; cv=none; d=google.com; s=arc-20160816; b=uCW8LWPvlrDDwMUOqxg4x7TLWmRLebislCVK3/yaTsRZnT2JezqUpG0W/dQ1DD+9RJ YibgRgfwVKjvDcSlzLuJc9Wwrsi24J+TG8phHs/bDhlxz7os5nlnDucYrzb+JrK6UAgW FbVudo0D+vEMs62gbnfwK8pSdozvqxlWRSuValkQLFapUT0XYG/jZczHoEpAji7F5pQc RI88V56zv5iUPotqaK4PG2YsflR8wbpu2VEeOXpFX1DPWAigzv3+byZbN+oPJyGsqGEF mZTf/aCDjLfoPjIyRp/CP9I4+VcOOcPgCtgca5FvxTtHIUjMoZmu4RhC2VoeoyVPXdir zaXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=5n+bO3nQc6v67IwVk8rdx7mHJd6GjeoeO6Wu8u8nP8w=; b=uHFzCUF0bhk3Mi2w32u5RSmwedg7e1aCZvAdvsQhoNm7ygdgV6tTSYzdvP/mZDj4yo FcY3O64ViRGQ9ipn94vOo6mS32yc9BBFyu+z2cnJ/mjpUtw/6DQf/nc330fbh73SGhlD /XluUzc4PVXoqwuGdqvA2rmgb/J5ti0ygyNNnTxXOdCSasH0a+67bm9SaCnDhx9Kj9WH BHuo1QIjtjTLZDhKKqiuIi5uToJl+iNz15WtC23hlwO0qGE7AkzhTMkxEI34JnUhNE/q zWuLrqWG992jqMV/BJES+SUYclwa+VaOCUVIjJqeHRnEQ5mdFHchkhvTgTLKH3eLo2Zi zoOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14-v6si10206442pga.270.2018.08.10.07.53.18; Fri, 10 Aug 2018 07:53:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728747AbeHJQHx (ORCPT + 99 others); Fri, 10 Aug 2018 12:07:53 -0400 Received: from mga12.intel.com ([192.55.52.136]:31362 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727996AbeHJQHx (ORCPT ); Fri, 10 Aug 2018 12:07:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Aug 2018 06:37:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,219,1531810800"; d="scan'208";a="80633134" Received: from otc-lr-04.jf.intel.com ([10.54.39.114]) by orsmga001.jf.intel.com with ESMTP; 10 Aug 2018 06:37:55 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, acme@kernel.org, tglx@linutronix.de, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: eranian@google.com, jolsa@redhat.com, namhyung@kernel.org, ak@linux.intel.com, Kan Liang Subject: [PATCH RFC 3/7] perf script: Support page size Date: Fri, 10 Aug 2018 06:36:23 -0700 Message-Id: <1533908187-25204-3-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533908187-25204-1-git-send-email-kan.liang@linux.intel.com> References: <1533908187-25204-1-git-send-email-kan.liang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang Display the page size if it is available. Can be configured by the user, for example: perf script --fields comm,event,phys_addr,page_size dtlb mem-loads:uP: 3fec82ea8 4K dtlb mem-loads:uP: 3fec82e90 4K dtlb mem-loads:uP: 3e23700a4 4K dtlb mem-loads:uP: 3fec82f20 4K dtlb mem-loads:uP: 3e23700a4 4K dtlb mem-loads:uP: 3b4211bec 4K dtlb mem-loads:uP: 382205dc0 2M dtlb mem-loads:uP: 36fa082c0 2M dtlb mem-loads:uP: 377607340 2M dtlb mem-loads:uP: 330010180 2M dtlb mem-loads:uP: 33200fd80 2M dtlb mem-loads:uP: 31b012b80 2M Signed-off-by: Kan Liang --- tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/builtin-script.c | 18 ++++++++++++++++-- tools/perf/util/event.h | 2 ++ tools/perf/util/session.c | 19 +++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index afdafe2..c7cd34d 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt @@ -117,7 +117,7 @@ OPTIONS Comma separated list of fields to print. Options are: comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline, period, iregs, uregs, brstack, brstacksym, flags, bpf-output, brstackinsn, - brstackoff, callindent, insn, insnlen, synth, phys_addr, metric, misc. + brstackoff, callindent, insn, insnlen, synth, phys_addr, metric, misc, page_size. Field list can be prepended with the type, trace, sw or hw, to indicate to which event type the field list applies. e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 568ddfa..fa8e487 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -27,6 +27,7 @@ #include "util/thread-stack.h" #include "util/time-utils.h" #include "util/path.h" +#include "util/event.h" #include "print_binary.h" #include #include @@ -95,6 +96,7 @@ enum perf_output_field { PERF_OUTPUT_UREGS = 1U << 27, PERF_OUTPUT_METRIC = 1U << 28, PERF_OUTPUT_MISC = 1U << 29, + PERF_OUTPUT_PAGE_SIZE = 1U << 30, }; struct output_option { @@ -131,6 +133,7 @@ struct output_option { {.str = "phys_addr", .field = PERF_OUTPUT_PHYS_ADDR}, {.str = "metric", .field = PERF_OUTPUT_METRIC}, {.str = "misc", .field = PERF_OUTPUT_MISC}, + {.str = "page_size", .field = PERF_OUTPUT_PAGE_SIZE}, }; enum { @@ -201,7 +204,8 @@ static struct { PERF_OUTPUT_SYM | PERF_OUTPUT_SYMOFFSET | PERF_OUTPUT_DSO | PERF_OUTPUT_PERIOD | PERF_OUTPUT_ADDR | PERF_OUTPUT_DATA_SRC | - PERF_OUTPUT_WEIGHT | PERF_OUTPUT_PHYS_ADDR, + PERF_OUTPUT_WEIGHT | PERF_OUTPUT_PHYS_ADDR | + PERF_OUTPUT_PAGE_SIZE, .invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT, }, @@ -465,6 +469,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, PERF_OUTPUT_PHYS_ADDR)) return -EINVAL; + if (PRINT_FIELD(PAGE_SIZE) && + perf_evsel__check_stype(evsel, PERF_SAMPLE_PAGE_SIZE, "PAGE_SIZE", + PERF_OUTPUT_PAGE_SIZE)) + return -EINVAL; + return 0; } @@ -1706,6 +1715,10 @@ static void process_event(struct perf_script *script, if (PRINT_FIELD(PHYS_ADDR)) fprintf(fp, "%16" PRIx64, sample->phys_addr); + + if (PRINT_FIELD(PAGE_SIZE)) + fprintf(fp, " %s", get_page_size_name(sample->page_size)); + fprintf(fp, "\n"); if (PRINT_FIELD(METRIC)) @@ -3150,7 +3163,8 @@ int cmd_script(int argc, const char **argv) "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," "addr,symoff,srcline,period,iregs,uregs,brstack," "brstacksym,flags,bpf-output,brstackinsn,brstackoff," - "callindent,insn,insnlen,synth,phys_addr,metric,misc", + "callindent,insn,insnlen,synth,phys_addr,metric,misc," + "page_size", parse_output_fields), OPT_BOOLEAN('a', "all-cpus", &system_wide, "system-wide collection from all CPUs"), diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 51456b8..7e7a820 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -831,4 +831,6 @@ int perf_event_paranoid(void); extern int sysctl_perf_event_max_stack; extern int sysctl_perf_event_max_contexts_per_stack; +const char *get_page_size_name(u64 level); + #endif /* __PERF_RECORD_H */ diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 8b93693..5c61820 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1080,6 +1080,22 @@ static void dump_event(struct perf_evlist *evlist, union perf_event *event, event->header.size, perf_event__name(event->header.type)); } +const char *get_page_size_name(u64 level) +{ + switch (level) { + case PERF_MEM_PAGE_SIZE_4K: + return "4K"; + case PERF_MEM_PAGE_SIZE_2M: + return "2M"; + case PERF_MEM_PAGE_SIZE_1G: + return "1G"; + case PERF_MEM_PAGE_SIZE_512G: + return "512G"; + default: + return "N/A"; + } +} + static void dump_sample(struct perf_evsel *evsel, union perf_event *event, struct perf_sample *sample) { @@ -1118,6 +1134,9 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event, if (sample_type & PERF_SAMPLE_PHYS_ADDR) printf(" .. phys_addr: 0x%"PRIx64"\n", sample->phys_addr); + if (sample_type & PERF_SAMPLE_PAGE_SIZE) + printf(" .. page size: %s\n", get_page_size_name(sample->page_size)); + if (sample_type & PERF_SAMPLE_TRANSACTION) printf("... transaction: %" PRIx64 "\n", sample->transaction); -- 2.7.4