From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@gmail.com>,
Paul Mackerras <paulus@samba.org>,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 39/41] perf tools: Allow TSC conversion on any arch
Date: Tue, 15 Jul 2014 20:48:45 +0300 [thread overview]
Message-ID: <53C5697D.20004@intel.com> (raw)
In-Reply-To: <20140715152003.GB6312@kernel.org>
On 15/07/2014 6:20 p.m., Arnaldo Carvalho de Melo wrote:
> Em Mon, Jul 14, 2014 at 01:03:03PM +0300, Adrian Hunter escreveu:
>> It is possible to record a perf.data file on
>> one architecture and process it on another.
>> Consequently, TSC conversion functions need
>> to be moved out of the arch directory.
>
> Can you state where a TSC is stored in perf.data, and how in the !x86
> arch this will be detected so that those functions will be used?
Intel PT has packets that contain 7-bytes of TSC. 'perf record' adds a
reference TSC to the ITRACE event so that the full TSC is known.
So this is the possibility that you record a perf.data file on x86
recording Intel PT and then take that file to another machine with a
different architecture. It should still be possible to read the file there.
>
> - Arnaldo
>
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>> ---
>> tools/perf/Makefile.perf | 2 ++
>> tools/perf/arch/x86/util/tsc.c | 22 +---------------------
>> tools/perf/arch/x86/util/tsc.h | 3 ---
>> tools/perf/tests/perf-time-to-tsc.c | 3 +--
>> tools/perf/util/tsc.c | 25 +++++++++++++++++++++++++
>> tools/perf/util/tsc.h | 11 +++++++++++
>> 6 files changed, 40 insertions(+), 26 deletions(-)
>> create mode 100644 tools/perf/util/tsc.c
>> create mode 100644 tools/perf/util/tsc.h
>>
>> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
>> index 9670a16..abca577 100644
>> --- a/tools/perf/Makefile.perf
>> +++ b/tools/perf/Makefile.perf
>> @@ -295,6 +295,7 @@ LIB_H += util/intlist.h
>> LIB_H += util/perf_regs.h
>> LIB_H += util/unwind.h
>> LIB_H += util/vdso.h
>> +LIB_H += util/tsc.h
>> LIB_H += ui/helpline.h
>> LIB_H += ui/progress.h
>> LIB_H += ui/util.h
>> @@ -373,6 +374,7 @@ LIB_OBJS += $(OUTPUT)util/stat.o
>> LIB_OBJS += $(OUTPUT)util/record.o
>> LIB_OBJS += $(OUTPUT)util/srcline.o
>> LIB_OBJS += $(OUTPUT)util/data.o
>> +LIB_OBJS += $(OUTPUT)util/tsc.o
>>
>> LIB_OBJS += $(OUTPUT)ui/setup.o
>> LIB_OBJS += $(OUTPUT)ui/helpline.o
>> diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c
>> index 40021fa..3655f24 100644
>> --- a/tools/perf/arch/x86/util/tsc.c
>> +++ b/tools/perf/arch/x86/util/tsc.c
>> @@ -6,29 +6,9 @@
>> #include "../../perf.h"
>> #include <linux/types.h>
>> #include "../../util/debug.h"
>> +#include "../../util/tsc.h"
>> #include "tsc.h"
>>
>> -u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
>> -{
>> - u64 t, quot, rem;
>> -
>> - t = ns - tc->time_zero;
>> - quot = t / tc->time_mult;
>> - rem = t % tc->time_mult;
>> - return (quot << tc->time_shift) +
>> - (rem << tc->time_shift) / tc->time_mult;
>> -}
>> -
>> -u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
>> -{
>> - u64 quot, rem;
>> -
>> - quot = cyc >> tc->time_shift;
>> - rem = cyc & ((1 << tc->time_shift) - 1);
>> - return tc->time_zero + quot * tc->time_mult +
>> - ((rem * tc->time_mult) >> tc->time_shift);
>> -}
>> -
>> int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc,
>> struct perf_tsc_conversion *tc)
>> {
>> diff --git a/tools/perf/arch/x86/util/tsc.h b/tools/perf/arch/x86/util/tsc.h
>> index 2affe03..2edc4d3 100644
>> --- a/tools/perf/arch/x86/util/tsc.h
>> +++ b/tools/perf/arch/x86/util/tsc.h
>> @@ -14,7 +14,4 @@ struct perf_event_mmap_page;
>> int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc,
>> struct perf_tsc_conversion *tc);
>>
>> -u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc);
>> -u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc);
>> -
>> #endif /* TOOLS_PERF_ARCH_X86_UTIL_TSC_H__ */
>> diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
>> index 3b7cd4d..0372f6e 100644
>> --- a/tools/perf/tests/perf-time-to-tsc.c
>> +++ b/tools/perf/tests/perf-time-to-tsc.c
>> @@ -8,10 +8,9 @@
>> #include "evsel.h"
>> #include "thread_map.h"
>> #include "cpumap.h"
>> +#include "tsc.h"
>> #include "tests.h"
>>
>> -#include "../arch/x86/util/tsc.h"
>> -
>> #define CHECK__(x) { \
>> while ((x) < 0) { \
>> pr_debug(#x " failed!\n"); \
>> diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c
>> new file mode 100644
>> index 0000000..ef4749836
>> --- /dev/null
>> +++ b/tools/perf/util/tsc.c
>> @@ -0,0 +1,25 @@
>> +#include <linux/compiler.h>
>> +#include <linux/types.h>
>> +
>> +#include "tsc.h"
>> +
>> +u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
>> +{
>> + u64 t, quot, rem;
>> +
>> + t = ns - tc->time_zero;
>> + quot = t / tc->time_mult;
>> + rem = t % tc->time_mult;
>> + return (quot << tc->time_shift) +
>> + (rem << tc->time_shift) / tc->time_mult;
>> +}
>> +
>> +u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
>> +{
>> + u64 quot, rem;
>> +
>> + quot = cyc >> tc->time_shift;
>> + rem = cyc & ((1 << tc->time_shift) - 1);
>> + return tc->time_zero + quot * tc->time_mult +
>> + ((rem * tc->time_mult) >> tc->time_shift);
>> +}
>> diff --git a/tools/perf/util/tsc.h b/tools/perf/util/tsc.h
>> new file mode 100644
>> index 0000000..4eca848
>> --- /dev/null
>> +++ b/tools/perf/util/tsc.h
>> @@ -0,0 +1,11 @@
>> +#ifndef __PERF_TSC_H
>> +#define __PERF_TSC_H
>> +
>> +#include <linux/types.h>
>> +
>> +#include "../arch/x86/util/tsc.h"
>> +
>> +u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc);
>> +u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc);
>> +
>> +#endif
>> --
>> 1.8.3.2
next prev parent reply other threads:[~2014-07-15 17:48 UTC|newest]
Thread overview: 122+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 10:02 [PATCH 00/41] perf tools: Preparation for call graph from Intel BTS Adrian Hunter
2014-07-14 10:02 ` [PATCH 01/41] perf tools: Fix the value used for unknown pids Adrian Hunter
2014-07-18 4:23 ` [tip:perf/core] perf machine: " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 02/41] perf tools: Fix map groups of threads with " Adrian Hunter
2014-07-14 20:18 ` Arnaldo Carvalho de Melo
2014-07-15 11:33 ` Adrian Hunter
2014-07-15 19:33 ` Arnaldo Carvalho de Melo
2014-07-16 8:07 ` [PATCH V2 " Adrian Hunter
2014-07-18 4:26 ` [tip:perf/core] perf machine: " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 03/41] perf script: Display PERF_RECORD_MISC_COMM_EXEC flag Adrian Hunter
2014-07-18 4:23 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 04/41] perf record: Select comm_exec flag if supported Adrian Hunter
2014-07-18 4:23 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 05/41] perf tools: Identify which comms are from exec Adrian Hunter
2014-07-14 20:32 ` Arnaldo Carvalho de Melo
2014-07-15 11:43 ` Adrian Hunter
2014-07-23 14:07 ` Arnaldo Carvalho de Melo
2014-07-23 14:09 ` Arnaldo Carvalho de Melo
2014-07-23 16:46 ` Adrian Hunter
2014-07-23 16:53 ` Arnaldo Carvalho de Melo
2014-07-14 10:02 ` [PATCH 06/41] perf tools: Add machine__thread_exec_comm() Adrian Hunter
2014-07-14 10:02 ` [PATCH 07/41] perf tools: Fix missing kernel map load Adrian Hunter
2014-07-18 4:23 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 08/41] perf tools: Fix missing label symbols Adrian Hunter
2014-07-14 20:38 ` Arnaldo Carvalho de Melo
2014-07-15 12:11 ` Adrian Hunter
2014-07-14 10:02 ` [PATCH 09/41] perf tools: Fix missing GNU IFUNC symbols Adrian Hunter
2014-07-18 4:24 ` [tip:perf/core] perf symbols: " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 10/41] perf inject: Fix build id injection Adrian Hunter
2014-07-18 4:24 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 11/41] perf tools: Fix appending a callchain from a previous sample Adrian Hunter
2014-07-18 4:24 ` [tip:perf/core] perf callchain: " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 12/41] perf tools: Fix leak of 'struct thread' on error path Adrian Hunter
2014-07-14 20:43 ` Arnaldo Carvalho de Melo
2014-07-16 7:19 ` [PATCH V2 0/2] perf tools: Allow deletion of a thread with no map groups Adrian Hunter
2014-07-16 7:19 ` [PATCH 1/2] " Adrian Hunter
2014-07-18 4:27 ` [tip:perf/core] perf thread: " tip-bot for Adrian Hunter
2014-07-16 7:19 ` [PATCH V2 2/2] perf tools: Fix leak of 'struct thread' on error path Adrian Hunter
2014-07-18 4:27 ` [tip:perf/core] perf machine: " tip-bot for Adrian Hunter
2014-07-16 14:02 ` [PATCH 12/41] perf tools: " Jiri Olsa
2014-07-16 14:26 ` Adrian Hunter
2014-07-14 10:02 ` [PATCH 13/41] perf tools: Add machine__kernel_ip() Adrian Hunter
2014-07-16 14:15 ` Jiri Olsa
2014-07-16 14:22 ` Adrian Hunter
2014-08-11 12:23 ` Jiri Olsa
2014-08-11 12:36 ` Adrian Hunter
2014-08-11 12:43 ` Jiri Olsa
2014-08-11 12:46 ` Adrian Hunter
2014-08-11 12:55 ` Jiri Olsa
2014-07-14 10:02 ` [PATCH 14/41] perf buildid-cache: Apply force option to copying kcore Adrian Hunter
2014-07-18 4:24 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 15/41] perf script: Improve srcline display for BTS Adrian Hunter
2014-07-15 14:16 ` Arnaldo Carvalho de Melo
2014-07-15 17:51 ` Adrian Hunter
2014-07-16 2:08 ` David Ahern
2014-07-14 10:02 ` [PATCH 16/41] perf script: Do not print dangling '=>' " Adrian Hunter
2014-07-14 10:02 ` [PATCH 17/41] perf tools: Record whether a dso is 64-bit Adrian Hunter
2014-07-18 4:24 ` [tip:perf/core] perf symbols: " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 18/41] perf tools: Record whether a dso has data Adrian Hunter
2014-07-16 14:20 ` Jiri Olsa
2014-07-17 8:43 ` [PATCH 0/2] perf tools: Fix incorrect fd error comparison Adrian Hunter
2014-07-17 8:43 ` [PATCH 1/2] " Adrian Hunter
2014-07-22 7:51 ` Jiri Olsa
2014-07-28 8:21 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-17 8:43 ` [PATCH V2 2/2] perf tools: Record whether a dso has data Adrian Hunter
2014-07-17 8:58 ` [PATCH V3] " Adrian Hunter
2014-07-22 7:55 ` Jiri Olsa
2014-07-22 13:24 ` Adrian Hunter
2014-07-14 10:02 ` [PATCH 19/41] perf tools: Do not attempt to read data from kallsyms Adrian Hunter
2014-07-18 4:25 ` [tip:perf/core] perf symbols: " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 20/41] perf tools: Let a user specify a PMU event without any config terms Adrian Hunter
2014-07-16 14:25 ` Jiri Olsa
2014-07-16 15:04 ` Adrian Hunter
2014-07-16 18:22 ` Jiri Olsa
2014-08-29 18:48 ` Adrian Hunter
2014-08-30 8:53 ` Jiri Olsa
2014-09-01 6:27 ` Adrian Hunter
2014-09-01 19:11 ` Jiri Olsa
2014-09-02 5:39 ` Adrian Hunter
2014-09-02 9:17 ` Jiri Olsa
2014-09-01 15:51 ` Arnaldo Carvalho de Melo
2014-09-01 19:15 ` Jiri Olsa
2014-07-14 10:02 ` [PATCH 21/41] perf tools: Let default config be defined for a PMU Adrian Hunter
2014-07-14 10:02 ` [PATCH 22/41] perf tools: Add perf_pmu__scan_file() Adrian Hunter
2014-07-14 10:02 ` [PATCH 23/41] perf tools: Add dsos__hit_all() Adrian Hunter
2014-07-14 10:02 ` [PATCH 24/41] perf tools: Add cpu to struct thread Adrian Hunter
2014-07-15 14:24 ` Arnaldo Carvalho de Melo
2014-07-15 17:58 ` Adrian Hunter
2014-07-14 10:02 ` [PATCH 25/41] perf tools: Add ability to record the current tid for each cpu Adrian Hunter
2014-07-14 10:02 ` [PATCH 26/41] perf tools: Add ability to iterate over a dso's symbols Adrian Hunter
2014-07-18 4:25 ` [tip:perf/core] perf symbols: Add ability to iterate over a dso' s symbols tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 27/41] perf session: Flag if the event stream is entirely in memory Adrian Hunter
2014-07-18 4:25 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 28/41] perf evlist: Pass mmap parameters in a struct Adrian Hunter
2014-07-18 4:25 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 29/41] perf tools: Add feature test for __sync_val_compare_and_swap Adrian Hunter
2014-07-18 4:26 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 30/41] perf tools: Add option macro OPT_CALLBACK_OPTARG Adrian Hunter
2014-07-18 4:26 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 31/41] perf evlist: Add perf_evlist__set_tracking_event() Adrian Hunter
2014-07-14 10:02 ` [PATCH 32/41] perf evsel: Add 'no_aux_samples' option Adrian Hunter
2014-07-18 4:26 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 33/41] perf evsel: Add 'immediate' option Adrian Hunter
2014-07-18 4:26 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:02 ` [PATCH 34/41] perf evlist: Add 'system_wide' option Adrian Hunter
2014-07-15 15:03 ` Arnaldo Carvalho de Melo
2014-07-15 18:05 ` Adrian Hunter
2014-08-11 13:12 ` Jiri Olsa
2014-08-12 5:52 ` Adrian Hunter
2014-07-14 10:02 ` [PATCH 35/41] perf tools: Add id index Adrian Hunter
2014-07-14 10:03 ` [PATCH 36/41] perf pmu: Let pmu's with no events show up on perf list Adrian Hunter
2014-07-14 10:03 ` [PATCH 37/41] perf session: Add ability to skip 4GiB or more Adrian Hunter
2014-07-14 10:03 ` [PATCH 38/41] perf session: Add perf_session__deliver_synth_event() Adrian Hunter
2014-07-15 15:17 ` Arnaldo Carvalho de Melo
2014-07-15 18:32 ` Adrian Hunter
2014-07-14 10:03 ` [PATCH 39/41] perf tools: Allow TSC conversion on any arch Adrian Hunter
2014-07-15 15:20 ` Arnaldo Carvalho de Melo
2014-07-15 16:17 ` Peter Zijlstra
2014-07-15 17:48 ` Adrian Hunter [this message]
2014-07-18 4:28 ` [tip:perf/core] " tip-bot for Adrian Hunter
2014-07-14 10:03 ` [PATCH 40/41] perf tools: Move rdtsc() function Adrian Hunter
2014-07-14 10:03 ` [PATCH 41/41] perf evlist: Add perf_evlist__enable_event_idx() Adrian Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53C5697D.20004@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).