Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1722620 > unrolled thread

[PATCH V2 1/5] perf tools: support new sample type for physical address

Started bykan.liang@intel.com
First post2017-08-29 19:20 +0200
Last post2017-09-05 07:30 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH V2 1/5] perf tools: support new sample type for physical address kan.liang@intel.com - 2017-08-29 19:20 +0200
    Re: [PATCH V2 1/5] perf tools: support new sample type for physical  address Jiri Olsa <jolsa@redhat.com> - 2017-09-01 17:30 +0200
      Re: [PATCH V2 1/5] perf tools: support new sample type for physical  address Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-09-01 17:40 +0200
    [tip:perf/urgent] perf tools: Support new sample type for physical  address tip-bot for Kan Liang <tipbot@zytor.com> - 2017-09-05 07:30 +0200

#1722620 — [PATCH V2 1/5] perf tools: support new sample type for physical address

Fromkan.liang@intel.com
Date2017-08-29 19:20 +0200
Subject[PATCH V2 1/5] perf tools: support new sample type for physical address
Message-ID<ujSlb-5rP-1@gated-at.bofh.it>
From: Kan Liang <kan.liang@intel.com>

Support new sample type PERF_SAMPLE_PHYS_ADDR for physical address.

Add new option --phys-data to record sample physical address.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/include/uapi/linux/perf_event.h    |  4 +++-
 tools/perf/Documentation/perf-record.txt |  5 ++++-
 tools/perf/builtin-record.c              |  2 ++
 tools/perf/perf.h                        |  1 +
 tools/perf/util/event.h                  |  1 +
 tools/perf/util/evsel.c                  | 17 +++++++++++++++++
 6 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index 2a37ae9..140ae63 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -139,8 +139,9 @@ enum perf_event_sample_format {
 	PERF_SAMPLE_IDENTIFIER			= 1U << 16,
 	PERF_SAMPLE_TRANSACTION			= 1U << 17,
 	PERF_SAMPLE_REGS_INTR			= 1U << 18,
+	PERF_SAMPLE_PHYS_ADDR			= 1U << 19,
 
-	PERF_SAMPLE_MAX = 1U << 19,		/* non-ABI */
+	PERF_SAMPLE_MAX = 1U << 20,		/* non-ABI */
 };
 
 /*
@@ -814,6 +815,7 @@ enum perf_event_type {
 	 *	{ u64			transaction; } && PERF_SAMPLE_TRANSACTION
 	 *	{ u64			abi; # enum perf_sample_regs_abi
 	 *	  u64			regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR
+	 *	{ u64			phys_addr;} && PERF_SAMPLE_PHYS_ADDR
 	 * };
 	 */
 	PERF_RECORD_SAMPLE			= 9,
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 9bdea04..e397453 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -249,7 +249,10 @@ OPTIONS
 
 -d::
 --data::
-	Record the sample addresses.
+	Record the sample virtual addresses.
+
+--phys-data::
+	Record the sample physical addresses.
 
 -T::
 --timestamp::
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 36d7117..56f8142 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1604,6 +1604,8 @@ static struct option __record_options[] = {
 	OPT_BOOLEAN('s', "stat", &record.opts.inherit_stat,
 		    "per thread counts"),
 	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, "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 2c010dd..dc442ba 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -43,6 +43,7 @@ struct record_opts {
 	bool	     no_samples;
 	bool	     raw_samples;
 	bool	     sample_address;
+	bool	     sample_phys_addr;
 	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 423ac82..ee7bcc8 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -200,6 +200,7 @@ struct perf_sample {
 	u32 cpu;
 	u32 raw_size;
 	u64 data_src;
+	u64 phys_addr;
 	u32 flags;
 	u16 insn_len;
 	u8  cpumode;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a5888c7..228a78d 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -950,6 +950,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 	if (opts->sample_address)
 		perf_evsel__set_sample_bit(evsel, DATA_SRC);
 
+	if (opts->sample_phys_addr)
+		perf_evsel__set_sample_bit(evsel, PHYS_ADDR);
+
 	if (opts->no_buffering) {
 		attr->watermark = 0;
 		attr->wakeup_events = 1;
@@ -2201,6 +2204,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
 		}
 	}
 
+	data->phys_addr = 0;
+	if (type & PERF_SAMPLE_PHYS_ADDR) {
+		data->phys_addr = *array;
+		array++;
+	}
+
 	return 0;
 }
 
@@ -2306,6 +2315,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
 		}
 	}
 
+	if (type & PERF_SAMPLE_PHYS_ADDR)
+		result += sizeof(u64);
+
 	return result;
 }
 
@@ -2495,6 +2507,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
 		}
 	}
 
+	if (type & PERF_SAMPLE_PHYS_ADDR) {
+		*array = sample->phys_addr;
+		array++;
+	}
+
 	return 0;
 }
 
-- 
2.4.3

[toc] | [next] | [standalone]


#1725141 — Re: [PATCH V2 1/5] perf tools: support new sample type for physical address

FromJiri Olsa <jolsa@redhat.com>
Date2017-09-01 17:30 +0200
SubjectRe: [PATCH V2 1/5] perf tools: support new sample type for physical address
Message-ID<ukW3n-6TV-5@gated-at.bofh.it>
In reply to#1722620
On Tue, Aug 29, 2017 at 01:11:08PM -0400, kan.liang@intel.com wrote:

SNIP

> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index a5888c7..228a78d 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -950,6 +950,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
>  	if (opts->sample_address)
>  		perf_evsel__set_sample_bit(evsel, DATA_SRC);
>  
> +	if (opts->sample_phys_addr)
> +		perf_evsel__set_sample_bit(evsel, PHYS_ADDR);
> +
>  	if (opts->no_buffering) {
>  		attr->watermark = 0;
>  		attr->wakeup_events = 1;
> @@ -2201,6 +2204,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
>  		}
>  	}
>  
> +	data->phys_addr = 0;
> +	if (type & PERF_SAMPLE_PHYS_ADDR) {
> +		data->phys_addr = *array;
> +		array++;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -2306,6 +2315,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
>  		}
>  	}
>  
> +	if (type & PERF_SAMPLE_PHYS_ADDR)
> +		result += sizeof(u64);
> +
>  	return result;
>  }
>  
> @@ -2495,6 +2507,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
>  		}
>  	}
>  
> +	if (type & PERF_SAMPLE_PHYS_ADDR) {
> +		*array = sample->phys_addr;
> +		array++;
> +	}
> +
>  	return 0;
>  }
>  

missing the printing bits

jirka


diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index e705c0d59a69..4bb89373eb52 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1467,7 +1467,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(WEIGHT), bit_name(PHYS_ADDR),
 		{ .name = NULL, }
 	};
 #undef bit_name

[toc] | [prev] | [next] | [standalone]


#1725147 — Re: [PATCH V2 1/5] perf tools: support new sample type for physical address

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2017-09-01 17:40 +0200
SubjectRe: [PATCH V2 1/5] perf tools: support new sample type for physical address
Message-ID<ukWd4-6Xx-23@gated-at.bofh.it>
In reply to#1725141
Em Fri, Sep 01, 2017 at 05:28:27PM +0200, Jiri Olsa escreveu:
> On Tue, Aug 29, 2017 at 01:11:08PM -0400, kan.liang@intel.com wrote:
> 
> SNIP
> 
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index a5888c7..228a78d 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -950,6 +950,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
> >  	if (opts->sample_address)
> >  		perf_evsel__set_sample_bit(evsel, DATA_SRC);
> >  
> > +	if (opts->sample_phys_addr)
> > +		perf_evsel__set_sample_bit(evsel, PHYS_ADDR);
> > +
> >  	if (opts->no_buffering) {
> >  		attr->watermark = 0;
> >  		attr->wakeup_events = 1;
> > @@ -2201,6 +2204,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
> >  		}
> >  	}
> >  
> > +	data->phys_addr = 0;
> > +	if (type & PERF_SAMPLE_PHYS_ADDR) {
> > +		data->phys_addr = *array;
> > +		array++;
> > +	}
> > +
> >  	return 0;
> >  }
> >  
> > @@ -2306,6 +2315,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
> >  		}
> >  	}
> >  
> > +	if (type & PERF_SAMPLE_PHYS_ADDR)
> > +		result += sizeof(u64);
> > +
> >  	return result;
> >  }
> >  
> > @@ -2495,6 +2507,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
> >  		}
> >  	}
> >  
> > +	if (type & PERF_SAMPLE_PHYS_ADDR) {
> > +		*array = sample->phys_addr;
> > +		array++;
> > +	}
> > +
> >  	return 0;
> >  }
> >  
> 
> missing the printing bits

I'm folding this one there then,

- Arnaldo
 
> jirka
> 
> 
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index e705c0d59a69..4bb89373eb52 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1467,7 +1467,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(WEIGHT), bit_name(PHYS_ADDR),
>  		{ .name = NULL, }
>  	};
>  #undef bit_name

[toc] | [prev] | [next] | [standalone]


#1726346 — [tip:perf/urgent] perf tools: Support new sample type for physical address

Fromtip-bot for Kan Liang <tipbot@zytor.com>
Date2017-09-05 07:30 +0200
Subject[tip:perf/urgent] perf tools: Support new sample type for physical address
Message-ID<umeAV-70c-17@gated-at.bofh.it>
In reply to#1722620
Commit-ID:  3b0a5daa061076b2b75ffc294e74483ad9bf241a
Gitweb:     http://git.kernel.org/tip/3b0a5daa061076b2b75ffc294e74483ad9bf241a
Author:     Kan Liang <kan.liang@intel.com>
AuthorDate: Tue, 29 Aug 2017 13:11:08 -0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 1 Sep 2017 14:46:00 -0300

perf tools: Support new sample type for physical address

Support new sample type PERF_SAMPLE_PHYS_ADDR for physical address.

Add new option --phys-data to record sample physical address.

Signed-off-by: Kan Liang <kan.liang@intel.com>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1504026672-7304-2-git-send-email-kan.liang@intel.com
[ Added missing printing in evsel.c patch sent by Jiri Olsa ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/include/uapi/linux/perf_event.h    |  4 +++-
 tools/perf/Documentation/perf-record.txt |  5 ++++-
 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, 29 insertions(+), 3 deletions(-)

diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index 2a37ae9..140ae63 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -139,8 +139,9 @@ enum perf_event_sample_format {
 	PERF_SAMPLE_IDENTIFIER			= 1U << 16,
 	PERF_SAMPLE_TRANSACTION			= 1U << 17,
 	PERF_SAMPLE_REGS_INTR			= 1U << 18,
+	PERF_SAMPLE_PHYS_ADDR			= 1U << 19,
 
-	PERF_SAMPLE_MAX = 1U << 19,		/* non-ABI */
+	PERF_SAMPLE_MAX = 1U << 20,		/* non-ABI */
 };
 
 /*
@@ -814,6 +815,7 @@ enum perf_event_type {
 	 *	{ u64			transaction; } && PERF_SAMPLE_TRANSACTION
 	 *	{ u64			abi; # enum perf_sample_regs_abi
 	 *	  u64			regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR
+	 *	{ u64			phys_addr;} && PERF_SAMPLE_PHYS_ADDR
 	 * };
 	 */
 	PERF_RECORD_SAMPLE			= 9,
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 9bdea04..e397453 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -249,7 +249,10 @@ OPTIONS
 
 -d::
 --data::
-	Record the sample addresses.
+	Record the sample virtual addresses.
+
+--phys-data::
+	Record the sample physical addresses.
 
 -T::
 --timestamp::
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 36d7117..56f8142 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1604,6 +1604,8 @@ static struct option __record_options[] = {
 	OPT_BOOLEAN('s', "stat", &record.opts.inherit_stat,
 		    "per thread counts"),
 	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, "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 2c010dd..dc442ba 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -43,6 +43,7 @@ struct record_opts {
 	bool	     no_samples;
 	bool	     raw_samples;
 	bool	     sample_address;
+	bool	     sample_phys_addr;
 	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 423ac82..ee7bcc8 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -200,6 +200,7 @@ struct perf_sample {
 	u32 cpu;
 	u32 raw_size;
 	u64 data_src;
+	u64 phys_addr;
 	u32 flags;
 	u16 insn_len;
 	u8  cpumode;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d9bd632..4bb8937 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -955,6 +955,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 	if (opts->sample_address)
 		perf_evsel__set_sample_bit(evsel, DATA_SRC);
 
+	if (opts->sample_phys_addr)
+		perf_evsel__set_sample_bit(evsel, PHYS_ADDR);
+
 	if (opts->no_buffering) {
 		attr->watermark = 0;
 		attr->wakeup_events = 1;
@@ -1464,7 +1467,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(WEIGHT), bit_name(PHYS_ADDR),
 		{ .name = NULL, }
 	};
 #undef bit_name
@@ -2206,6 +2209,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
 		}
 	}
 
+	data->phys_addr = 0;
+	if (type & PERF_SAMPLE_PHYS_ADDR) {
+		data->phys_addr = *array;
+		array++;
+	}
+
 	return 0;
 }
 
@@ -2311,6 +2320,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
 		}
 	}
 
+	if (type & PERF_SAMPLE_PHYS_ADDR)
+		result += sizeof(u64);
+
 	return result;
 }
 
@@ -2500,6 +2512,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
 		}
 	}
 
+	if (type & PERF_SAMPLE_PHYS_ADDR) {
+		*array = sample->phys_addr;
+		array++;
+	}
+
 	return 0;
 }
 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web