Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3270547imm; Fri, 10 Aug 2018 06:40:04 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwNURUolz30DV2ZNKXtYolHcOk56fkWdplOOs0BzGcsVLYyh74qumTn7dMvkLt7bhC/7vr5 X-Received: by 2002:a62:f50b:: with SMTP id n11-v6mr7144146pfh.120.1533908403940; Fri, 10 Aug 2018 06:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533908403; cv=none; d=google.com; s=arc-20160816; b=bEmpJnAHljGzWHn6wG0cgQNcYDCkG4P3Cq1ChrgwzyhdIo3OP4Jvd3qQlqlUhSaGiu 2oupvY6xXUXGkTEUdbptZbKmecQ3YJpPhNsKSUiGS7DZ63QWNDNFlQC9bwYrFZjl03Nn OwV/2OPO7FWbgzmtD7pMyZbExacFT1yJIQNOHoJuxZFRJzRDUI8W2pCkbZXBRm1rMan7 QOfjef6ISMslI2ZVs0C+EtxeEZTWgHXZNyZUr6173H4Mb+/Uxyt6zOTov+P9W7FEIsBi hEePtEtUxdLp7GW/i1XqomKCbF3qGtZ04IYiP6vYPi2q/JoJfQ0p9uJM/sWfa+r649PL x7Ow== 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=Dy38oZ/f7THEwVvh8v6bIyVCH9uWZZXvPZ1EsCku+IY=; b=nS6tlLjtUme2GkFAj1hAWWyqBbH2HgpBa3vJCHApzmy3W1SW8P8xznXBJ76BPyeTf3 K0iqT65MvmCAuYlogzm93zaQH4+2va3IURawzJIT1Bk/JNAL9jjUxt+O99yo2yrlwxvK uj49tyDF//VJ9L4vAm+CQXSRSrNOwly9b+3SmSON8qC5fYXYQj88/eXcwSZZDAl70PEB LXr2jcDvF+X2tHqfdn03ZcudfBclzKJtyz5m4VM2R4+ASnThkUiwGtK5zvXEdpmY6/WJ puu8SeQPELf/1Ui492Ij7VTbj2cF/FOBKM3VssZSkNNGj5f6ZLXbJFvkhX+BptlMmtlT TU0A== 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 g12-v6si8625690pgq.637.2018.08.10.06.39.49; Fri, 10 Aug 2018 06:40:03 -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 S1728861AbeHJQHx (ORCPT + 99 others); Fri, 10 Aug 2018 12:07:53 -0400 Received: from mga12.intel.com ([192.55.52.136]:31349 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728097AbeHJQHw (ORCPT ); Fri, 10 Aug 2018 12:07:52 -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:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,219,1531810800"; d="scan'208";a="80633125" Received: from otc-lr-04.jf.intel.com ([10.54.39.114]) by orsmga001.jf.intel.com with ESMTP; 10 Aug 2018 06:37:53 -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 2/7] perf tools: Support new sample type for page size Date: Fri, 10 Aug 2018 06:36:22 -0700 Message-Id: <1533908187-25204-2-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 Support new sample type PERF_SAMPLE_PAGE_SIZE for page size. Add new option --page-size to record sample page size. Signed-off-by: Kan Liang --- tools/include/uapi/linux/perf_event.h | 13 ++++++++++++- tools/perf/Documentation/perf-record.txt | 3 +++ tools/perf/builtin-record.c | 2 ++ tools/perf/perf.h | 1 + tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 19 ++++++++++++++++++- 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index eeb787b..5473443 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -141,8 +141,9 @@ enum perf_event_sample_format { PERF_SAMPLE_TRANSACTION = 1U << 17, PERF_SAMPLE_REGS_INTR = 1U << 18, PERF_SAMPLE_PHYS_ADDR = 1U << 19, + PERF_SAMPLE_PAGE_SIZE = 1U << 20, - PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */ + PERF_SAMPLE_MAX = 1U << 21, /* non-ABI */ __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63, }; @@ -861,6 +862,7 @@ enum perf_event_type { * { u64 abi; # enum perf_sample_regs_abi * u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR * { u64 phys_addr;} && PERF_SAMPLE_PHYS_ADDR + * { u64 page_size;} && PERF_SAMPLE_PAGE_SIZE * }; */ PERF_RECORD_SAMPLE = 9, @@ -1099,6 +1101,15 @@ union perf_mem_data_src { #define PERF_MEM_S(a, s) \ (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT) + +enum perf_mem_page_size { + PERF_MEM_PAGE_SIZE_NONE, + PERF_MEM_PAGE_SIZE_4K, + PERF_MEM_PAGE_SIZE_2M, + PERF_MEM_PAGE_SIZE_1G, + PERF_MEM_PAGE_SIZE_512G, +}; + /* * single taken branch record layout: * diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 246dee0..ddfe4be 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -264,6 +264,9 @@ OPTIONS --phys-data:: Record the sample physical addresses. +--page-size:: + Record the sample page size + -T:: --timestamp:: Record the sample timestamps. Use it with 'perf report -D' to see the diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 22ebeb92..7f27dbe 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1600,6 +1600,8 @@ static struct option __record_options[] = { OPT_BOOLEAN('d', "data", &record.opts.sample_address, "Record the sample addresses"), OPT_BOOLEAN(0, "phys-data", &record.opts.sample_phys_addr, "Record the sample physical addresses"), + OPT_BOOLEAN(0, "page-size", &record.opts.sample_page_size, + "Record the sample page size"), OPT_BOOLEAN(0, "sample-cpu", &record.opts.sample_cpu, "Record the sample cpu"), OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time, &record.opts.sample_time_set, diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 21bf7f5..db06458 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -48,6 +48,7 @@ struct record_opts { bool raw_samples; bool sample_address; bool sample_phys_addr; + bool sample_page_size; bool sample_weight; bool sample_time; bool sample_time_set; diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index bfa60bc..51456b8 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -202,6 +202,7 @@ struct perf_sample { u32 raw_size; u64 data_src; u64 phys_addr; + u64 page_size; u32 flags; u16 insn_len; u8 cpumode; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index ddf84b9..8cf7ec3 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1015,6 +1015,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts, if (opts->sample_phys_addr) perf_evsel__set_sample_bit(evsel, PHYS_ADDR); + if (opts->sample_page_size) + perf_evsel__set_sample_bit(evsel, PAGE_SIZE); + if (opts->no_buffering) { attr->watermark = 0; attr->wakeup_events = 1; @@ -1540,7 +1543,7 @@ static void __p_sample_type(char *buf, size_t size, u64 value) bit_name(PERIOD), bit_name(STREAM_ID), bit_name(RAW), bit_name(BRANCH_STACK), bit_name(REGS_USER), bit_name(STACK_USER), bit_name(IDENTIFIER), bit_name(REGS_INTR), bit_name(DATA_SRC), - bit_name(WEIGHT), bit_name(PHYS_ADDR), + bit_name(WEIGHT), bit_name(PHYS_ADDR), bit_name(PAGE_SIZE), { .name = NULL, } }; #undef bit_name @@ -2357,6 +2360,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, array++; } + data->page_size = 0; + if (type & PERF_SAMPLE_PAGE_SIZE) { + data->page_size = *array; + array++; + } + return 0; } @@ -2509,6 +2518,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, if (type & PERF_SAMPLE_PHYS_ADDR) result += sizeof(u64); + if (type & PERF_SAMPLE_PAGE_SIZE) + result += sizeof(u64); + return result; } @@ -2678,6 +2690,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, array++; } + if (type & PERF_SAMPLE_PAGE_SIZE) { + *array = sample->page_size; + array++; + } + return 0; } -- 2.7.4