perf intel-pt: Some fixes and preparation for AUX area sampling
Adrian Hunter
reviewercover perf intel-pt: Some fixes and preparation for AUX area sampling
Hi
Here are 4 fixes for Intel PT plus 5 more patches in preparation for supporting AUX area sampling.
Adrian Hunter (9):
perf intel-pt: Fix overlap detection to identify consecutive buffers correctly perf intel-pt: Fix sync_switch
perf intel-pt: Fix error recovery from missing TIP packet
perf intel-pt: Fix timestamp following overflow
perf intel-pt/bts: In auxtrace_record__init_intel() evlist is never NULL perf intel-pt: Get rid of intel_pt_use_buffer_pid_tid()
perf intel-pt: Tidy old_buffer handling in intel_pt_get_trace() perf intel-pt: Remove a check for sampling mode
perf intel-pt: Adjust overlap-checking to support sampling mode
tools/perf/arch/x86/util/auxtrace.c | 14 +-- .../perf/util/intel-pt-decoder/intel-pt-decoder.c | 64 ++++++------ .../perf/util/intel-pt-decoder/intel-pt-decoder.h | 2 +- tools/perf/util/intel-pt.c | 110 +++++++++------------ 4 files changed, 84 insertions(+), 106 deletions(-)
Regards
Adrian
Adrian Hunter
reviewerPATCH 1/9 perf intel-pt: Fix overlap detection to identify consecutive buffers correctly
Overlap detection was not not updating the buffer's 'consecutive' flag. Marking buffers consecutive has the advantage that decoding begins from the start of the buffer instead of the first PSB. Fix overlap detection to identify consecutive buffers correctly.
--- .../perf/util/intel-pt-decoder/intel-pt-decoder.c | 62 ++++++++++------------ .../perf/util/intel-pt-decoder/intel-pt-decoder.h | 2 +- tools/perf/util/intel-pt.c | 5 +- 3 files changed, 34 insertions(+), 35 deletions(-)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +29 -33
@@ -2390,14 +2390,6 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder)return &decoder->state; } -static bool intel_pt_at_psb (unsigned char *buf,size_t len) -{ -if (len <INTEL_PT_PSB_LEN ) -return false; -return memmem (buf,INTEL_PT_PSB_LEN ,INTEL_PT_PSB_STR , -INTEL_PT_PSB_LEN ); -} -/** * intel_pt_next_psb - move buffer pointer to the start of the next PSB packet. * @buf: pointer to buffer pointer
@@ -2486,6 +2478,7 @@ static unsigned char *intel_pt_last_psb(unsigned char *buf, size_t len)* @buf: buffer * @len: size of buffer * @tsc: TSC value returned +* @rem: returns remaining size when TSC is found * * Find a TSC packet in @buf and return the TSC value. This function assumes * that @buf starts at a PSB and that PSB+ will contain TSC and so stops if a
@@ -2493,7 +2486,8 @@ static unsigned char *intel_pt_last_psb(unsigned char *buf, size_t len)* * Return: %true if TSC is found, false otherwise. */ -static bool intel_pt_next_tsc (unsigned char *buf,size_t len,uint64_t *tsc) +static bool intel_pt_next_tsc (unsigned char *buf,size_t len,uint64_t *tsc, +size_t *rem) {struct intel_pt_pkt packet;int ret;
@@ -2504,6 +2498,7 @@ static bool intel_pt_next_tsc(unsigned char *buf, size_t len, uint64_t *tsc)return false;if (packet.type ==INTEL_PT_TSC ) { *tsc = packet.payload; + *rem = len;return true; }if (packet.type ==INTEL_PT_PSBEND )
@@ -2554,6 +2549,8 @@ static int intel_pt_tsc_cmp(uint64_t tsc1, uint64_t tsc2)* @len_a: size of first buffer * @buf_b: second buffer * @len_b: size of second buffer +* @consecutive: returns true if there is data in buf_b that is consecutive +* to buf_a * * If the trace contains TSC we can look at the last TSC of @buf_a and the * first TSC of @buf_b in order to determine if the buffers overlap, and then
@@ -2566,33 +2563,41 @@ static int intel_pt_tsc_cmp(uint64_t tsc1, uint64_t tsc2)static unsigned char *intel_pt_find_overlap_tsc (unsigned char *buf_a,size_t len_a,unsigned char *buf_b, -size_t len_b) +size_t len_b,bool *consecutive) {uint64_t tsc_a, tsc_b;unsigned char *p; -size_t len; +size_t len, rem_a, rem_b; p =intel_pt_last_psb (buf_a, len_a);if (!p)return buf_b;/* No PSB in buf_a => no overlap */ len = len_a - (p - buf_a); -if (!intel_pt_next_tsc (p, len, &tsc_a)) { +if (!intel_pt_next_tsc (p, len, &tsc_a, &rem_a)) {/* The last PSB+ in buf_a is incomplete, so go back one more */ len_a -= len; p =intel_pt_last_psb (buf_a, len_a);if (!p)return buf_b;/* No full PSB+ => assume no overlap */ len = len_a - (p - buf_a); -if (!intel_pt_next_tsc (p, len, &tsc_a)) +if (!intel_pt_next_tsc (p, len, &tsc_a, &rem_a))return buf_b;/* No TSC in buf_a => assume no overlap */ }while (1 ) {/* Ignore PSB+ with no TSC */ -if (intel_pt_next_tsc (buf_b, len_b, &tsc_b) && -intel_pt_tsc_cmp (tsc_a, tsc_b) <0 ) -return buf_b;/* tsc_a < tsc_b => no overlap */ +if (intel_pt_next_tsc (buf_b, len_b, &tsc_b, &rem_b)) { +int cmp =intel_pt_tsc_cmp (tsc_a, tsc_b); + +/* Same TSC, so buffers are consecutive */ +if (!cmp && rem_b >= rem_a) { + *consecutive = true; +return buf_b + len_b - (rem_b - rem_a); + } +if (cmp <0 ) +return buf_b;/* tsc_a < tsc_b => no overlap */ + }if (!intel_pt_step_psb (&buf_b, &len_b))return buf_b + len_b;/* No PSB in buf_b => no data */
@@ -2606,6 +2611,8 @@ static unsigned char *intel_pt_find_overlap_tsc(unsigned char *buf_a,* @buf_b: second buffer * @len_b: size of second buffer * @have_tsc: can use TSC packets to detect overlap +* @consecutive: returns true if there is data in buf_b that is consecutive +* to buf_a * * When trace samples or snapshots are recorded there is the possibility that * the data overlaps. Note that, for the purposes of decoding, data is only
@@ -2616,7 +2623,7 @@ static unsigned char *intel_pt_find_overlap_tsc(unsigned char *buf_a,*/ unsigned char *intel_pt_find_overlap (unsigned char *buf_a,size_t len_a,unsigned char *buf_b,size_t len_b, -bool have_tsc) +bool have_tsc,bool *consecutive) {unsigned char *found;
@@ -2628,7 +2635,8 @@ unsigned char *intel_pt_find_overlap(unsigned char *buf_a, size_t len_a,return buf_b;/* No overlap */ if (have_tsc) { - found =intel_pt_find_overlap_tsc (buf_a, len_a, buf_b, len_b); + found =intel_pt_find_overlap_tsc (buf_a, len_a, buf_b, len_b, + consecutive);if (found)return found; }
@@ -2643,28 +2651,16 @@ unsigned char *intel_pt_find_overlap(unsigned char *buf_a, size_t len_a, }/* Now len_b >= len_a */ -if (len_b > len_a) { -/* The leftover buffer 'b' must start at a PSB */ -while (!intel_pt_at_psb (buf_b + len_a, len_b - len_a)) { -if (!intel_pt_step_psb (&buf_a, &len_a)) -return buf_b;/* No overlap */ - } - } -while (1 ) {/* Potential overlap so check the bytes */ found =memmem (buf_a, len_a, buf_b, len_a); -if (found) +if (found) { + *consecutive = true;return buf_b + len_a; + }/* Try again at next PSB in buffer 'a' */ if (!intel_pt_step_psb (&buf_a, &len_a))return buf_b;/* No overlap */ - -/* The leftover buffer 'b' must start at a PSB */ -while (!intel_pt_at_psb (buf_b + len_a, len_b - len_a)) { -if (!intel_pt_step_psb (&buf_a, &len_a)) -return buf_b;/* No overlap */ - } } }
tools/perf/util/intel-pt-decoder/intel-pt-decoder.h +1 -1
@@ -117,7 +117,7 @@ struct intel_pt_params {unsigned char *intel_pt_find_overlap (unsigned char *buf_a,size_t len_a,unsigned char *buf_b,size_t len_b, -bool have_tsc); +bool have_tsc,bool *consecutive);int intel_pt__strerror (int code,char *buf,size_t buflen);
tools/perf/util/intel-pt.c +4 -1
@@ -207,14 +207,17 @@ static void intel_pt_dump_event(struct intel_pt *pt, unsigned char *buf,static int intel_pt_do_fix_overlap (struct intel_pt *pt,struct auxtrace_buffer *a,struct auxtrace_buffer *b) { +bool consecutive = false;void *start; start =intel_pt_find_overlap (a->data, a->size, b->data, b->size, - pt->have_tsc); + pt->have_tsc, &consecutive);if (!start)return -EINVAL ; b->use_size = b->data + b->size - start; b->use_data = start; +if (b->use_size && consecutive) + b->consecutive = true;return 0 ; }
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Fix overlap detection to identify consecutive buffers correctly
perf intel-pt: Fix overlap detection to identify consecutive buffers correctly
Commit-ID: 117db4b27bf08dba412faf3924ba55fe970c57b8 Gitweb: https://git.kernel.org/tip/117db4b27bf08dba412faf3924ba55fe970c57b8 Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:21 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:54 -0300
perf intel-pt: Fix overlap detection to identify consecutive buffers correctly
Overlap detection was not not updating the buffer's 'consecutive' flag. Marking buffers consecutive has the advantage that decoding begins from the start of the buffer instead of the first PSB. Fix overlap detection to identify consecutive buffers correctly.
--- .../perf/util/intel-pt-decoder/intel-pt-decoder.c | 62 ++++++++++------------ .../perf/util/intel-pt-decoder/intel-pt-decoder.h | 2 +- tools/perf/util/intel-pt.c | 5 +- 3 files changed, 34 insertions(+), 35 deletions(-)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +29 -33
@@ -2390,14 +2390,6 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder)return &decoder->state; } -static bool intel_pt_at_psb (unsigned char *buf,size_t len) -{ -if (len <INTEL_PT_PSB_LEN ) -return false; -return memmem (buf,INTEL_PT_PSB_LEN ,INTEL_PT_PSB_STR , -INTEL_PT_PSB_LEN ); -} -/** * intel_pt_next_psb - move buffer pointer to the start of the next PSB packet. * @buf: pointer to buffer pointer
@@ -2486,6 +2478,7 @@ static unsigned char *intel_pt_last_psb(unsigned char *buf, size_t len)* @buf: buffer * @len: size of buffer * @tsc: TSC value returned +* @rem: returns remaining size when TSC is found * * Find a TSC packet in @buf and return the TSC value. This function assumes * that @buf starts at a PSB and that PSB+ will contain TSC and so stops if a
@@ -2493,7 +2486,8 @@ static unsigned char *intel_pt_last_psb(unsigned char *buf, size_t len)* * Return: %true if TSC is found, false otherwise. */ -static bool intel_pt_next_tsc (unsigned char *buf,size_t len,uint64_t *tsc) +static bool intel_pt_next_tsc (unsigned char *buf,size_t len,uint64_t *tsc, +size_t *rem) {struct intel_pt_pkt packet;int ret;
@@ -2504,6 +2498,7 @@ static bool intel_pt_next_tsc(unsigned char *buf, size_t len, uint64_t *tsc)return false;if (packet.type ==INTEL_PT_TSC ) { *tsc = packet.payload; + *rem = len;return true; }if (packet.type ==INTEL_PT_PSBEND )
@@ -2554,6 +2549,8 @@ static int intel_pt_tsc_cmp(uint64_t tsc1, uint64_t tsc2)* @len_a: size of first buffer * @buf_b: second buffer * @len_b: size of second buffer +* @consecutive: returns true if there is data in buf_b that is consecutive +* to buf_a * * If the trace contains TSC we can look at the last TSC of @buf_a and the * first TSC of @buf_b in order to determine if the buffers overlap, and then
@@ -2566,33 +2563,41 @@ static int intel_pt_tsc_cmp(uint64_t tsc1, uint64_t tsc2)static unsigned char *intel_pt_find_overlap_tsc (unsigned char *buf_a,size_t len_a,unsigned char *buf_b, -size_t len_b) +size_t len_b,bool *consecutive) {uint64_t tsc_a, tsc_b;unsigned char *p; -size_t len; +size_t len, rem_a, rem_b; p =intel_pt_last_psb (buf_a, len_a);if (!p)return buf_b;/* No PSB in buf_a => no overlap */ len = len_a - (p - buf_a); -if (!intel_pt_next_tsc (p, len, &tsc_a)) { +if (!intel_pt_next_tsc (p, len, &tsc_a, &rem_a)) {/* The last PSB+ in buf_a is incomplete, so go back one more */ len_a -= len; p =intel_pt_last_psb (buf_a, len_a);if (!p)return buf_b;/* No full PSB+ => assume no overlap */ len = len_a - (p - buf_a); -if (!intel_pt_next_tsc (p, len, &tsc_a)) +if (!intel_pt_next_tsc (p, len, &tsc_a, &rem_a))return buf_b;/* No TSC in buf_a => assume no overlap */ }while (1 ) {/* Ignore PSB+ with no TSC */ -if (intel_pt_next_tsc (buf_b, len_b, &tsc_b) && -intel_pt_tsc_cmp (tsc_a, tsc_b) <0 ) -return buf_b;/* tsc_a < tsc_b => no overlap */ +if (intel_pt_next_tsc (buf_b, len_b, &tsc_b, &rem_b)) { +int cmp =intel_pt_tsc_cmp (tsc_a, tsc_b); + +/* Same TSC, so buffers are consecutive */ +if (!cmp && rem_b >= rem_a) { + *consecutive = true; +return buf_b + len_b - (rem_b - rem_a); + } +if (cmp <0 ) +return buf_b;/* tsc_a < tsc_b => no overlap */ + }if (!intel_pt_step_psb (&buf_b, &len_b))return buf_b + len_b;/* No PSB in buf_b => no data */
@@ -2606,6 +2611,8 @@ static unsigned char *intel_pt_find_overlap_tsc(unsigned char *buf_a,* @buf_b: second buffer * @len_b: size of second buffer * @have_tsc: can use TSC packets to detect overlap +* @consecutive: returns true if there is data in buf_b that is consecutive +* to buf_a * * When trace samples or snapshots are recorded there is the possibility that * the data overlaps. Note that, for the purposes of decoding, data is only
@@ -2616,7 +2623,7 @@ static unsigned char *intel_pt_find_overlap_tsc(unsigned char *buf_a,*/ unsigned char *intel_pt_find_overlap (unsigned char *buf_a,size_t len_a,unsigned char *buf_b,size_t len_b, -bool have_tsc) +bool have_tsc,bool *consecutive) {unsigned char *found;
@@ -2628,7 +2635,8 @@ unsigned char *intel_pt_find_overlap(unsigned char *buf_a, size_t len_a,return buf_b;/* No overlap */ if (have_tsc) { - found =intel_pt_find_overlap_tsc (buf_a, len_a, buf_b, len_b); + found =intel_pt_find_overlap_tsc (buf_a, len_a, buf_b, len_b, + consecutive);if (found)return found; }
@@ -2643,28 +2651,16 @@ unsigned char *intel_pt_find_overlap(unsigned char *buf_a, size_t len_a, }/* Now len_b >= len_a */ -if (len_b > len_a) { -/* The leftover buffer 'b' must start at a PSB */ -while (!intel_pt_at_psb (buf_b + len_a, len_b - len_a)) { -if (!intel_pt_step_psb (&buf_a, &len_a)) -return buf_b;/* No overlap */ - } - } -while (1 ) {/* Potential overlap so check the bytes */ found =memmem (buf_a, len_a, buf_b, len_a); -if (found) +if (found) { + *consecutive = true;return buf_b + len_a; + }/* Try again at next PSB in buffer 'a' */ if (!intel_pt_step_psb (&buf_a, &len_a))return buf_b;/* No overlap */ - -/* The leftover buffer 'b' must start at a PSB */ -while (!intel_pt_at_psb (buf_b + len_a, len_b - len_a)) { -if (!intel_pt_step_psb (&buf_a, &len_a)) -return buf_b;/* No overlap */ - } } }
tools/perf/util/intel-pt-decoder/intel-pt-decoder.h +1 -1
@@ -117,7 +117,7 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder);unsigned char *intel_pt_find_overlap (unsigned char *buf_a,size_t len_a,unsigned char *buf_b,size_t len_b, -bool have_tsc); +bool have_tsc,bool *consecutive);int intel_pt__strerror (int code,char *buf,size_t buflen);
tools/perf/util/intel-pt.c +4 -1
@@ -207,14 +207,17 @@ static void intel_pt_dump_event(struct intel_pt *pt, unsigned char *buf,static int intel_pt_do_fix_overlap (struct intel_pt *pt,struct auxtrace_buffer *a,struct auxtrace_buffer *b) { +bool consecutive = false;void *start; start =intel_pt_find_overlap (a->data, a->size, b->data, b->size, - pt->have_tsc); + pt->have_tsc, &consecutive);if (!start)return -EINVAL ; b->use_size = b->data + b->size - start; b->use_data = start; +if (b->use_size && consecutive) + b->consecutive = true;return 0 ; }
Adrian Hunter
reviewerPATCH 2/9 perf intel-pt: Fix sync_switch
In reply to Adrian Huntersync_switch is a facility to synchronize decoding more closely with the point in the kernel when the context actually switched. The flag when sync_switch is enabled was global to the decoding, whereas it is really specific to the CPU. The trace data for different CPUs is put on different queues, so add sync_switch to the intel_pt_queue structure and use that in preference to the global setting in the intel_pt structure. That fixes problems decoding one CPU's trace because sync_switch was disabled on a different CPU's queue.
--- tools/perf/util/intel-pt.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
tools/perf/util/intel-pt.c +25 -7
@@ -143,6 +143,7 @@ struct intel_pt_queue {bool stop;bool step_through_buffers;bool use_buffer_pid_tid; +bool sync_switch;pid_t pid, tid;int cpu;int switch_state;
@@ -963,10 +964,12 @@ static int intel_pt_setup_queue(struct intel_pt *pt,if (pt->timeless_decoding || !pt->have_sched_switch) ptq->use_buffer_pid_tid = true; } + + ptq->sync_switch = pt->sync_switch; }if (!ptq->on_heap && - (!pt->sync_switch || + (!ptq->sync_switch || ptq->switch_state !=INTEL_PT_SS_EXPECTING_SWITCH_EVENT )) {const struct intel_pt_state *state;int ret;
@@ -1549,7 +1552,7 @@ static int intel_pt_sample(struct intel_pt_queue *ptq)if (pt->synth_opts.last_branch)intel_pt_update_last_branch_rb (ptq); -if (!pt->sync_switch) +if (!ptq->sync_switch)return 0 ;if (intel_pt_is_switch_ip (ptq, state->to_ip)) {
@@ -1630,6 +1633,21 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip)return switch_ip; } +static void intel_pt_enable_sync_switch (struct intel_pt *pt) +{ +unsigned int i; + + pt->sync_switch = true; + +for (i =0 ; i < pt->queues.nr_queues; i++) { +struct auxtrace_queue *queue = &pt->queues.queue_array[i]; +struct intel_pt_queue *ptq = queue->priv; + +if (ptq) + ptq->sync_switch = true; + } +} +static int intel_pt_run_decoder (struct intel_pt_queue *ptq,u64 *timestamp) {const struct intel_pt_state *state = ptq->state;
@@ -1646,7 +1664,7 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)if (pt->switch_ip) {intel_pt_log ("switch_ip: %" PRIx64" ptss_ip: %" PRIx64"\n" , pt->switch_ip, pt->ptss_ip); - pt->sync_switch = true; +intel_pt_enable_sync_switch (pt); } } }
@@ -1662,9 +1680,9 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)if (state->err) {if (state->err ==INTEL_PT_ERR_NODATA )return 1 ; -if (pt->sync_switch && +if (ptq->sync_switch && state->from_ip >= pt->kernel_start) { - pt->sync_switch = false; + ptq->sync_switch = false;intel_pt_next_tid (pt, ptq); }if (pt->synth_opts.errors) {
@@ -1690,7 +1708,7 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp) state->timestamp, state->est_timestamp); ptq->timestamp = state->est_timestamp;/* Use estimated TSC in unknown switch state */ - }else if (pt->sync_switch && + }else if (ptq->sync_switch && ptq->switch_state ==INTEL_PT_SS_UNKNOWN &&intel_pt_is_switch_ip (ptq, state->to_ip) && ptq->next_tid ==-1 ) {
@@ -1837,7 +1855,7 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid,return 1 ; ptq =intel_pt_cpu_to_ptq (pt, cpu); -if (!ptq) +if (!ptq || !ptq->sync_switch)return 1 ;switch (ptq->switch_state) {
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Fix sync_switch
perf intel-pt: Fix sync_switch
Commit-ID: 63d8e38f6ae6c36dd5b5ba0e8c112e8861532ea2 Gitweb: https://git.kernel.org/tip/63d8e38f6ae6c36dd5b5ba0e8c112e8861532ea2 Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:22 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:55 -0300
perf intel-pt: Fix sync_switch
sync_switch is a facility to synchronize decoding more closely with the point in the kernel when the context actually switched.
The flag when sync_switch is enabled was global to the decoding, whereas it is really specific to the CPU.
The trace data for different CPUs is put on different queues, so add sync_switch to the intel_pt_queue structure and use that in preference to the global setting in the intel_pt structure.
That fixes problems decoding one CPU's trace because sync_switch was disabled on a different CPU's queue.
--- tools/perf/util/intel-pt.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
tools/perf/util/intel-pt.c +25 -7
@@ -143,6 +143,7 @@ struct intel_pt_queue {bool stop;bool step_through_buffers;bool use_buffer_pid_tid; +bool sync_switch;pid_t pid, tid;int cpu;int switch_state;
@@ -963,10 +964,12 @@ static int intel_pt_setup_queue(struct intel_pt *pt,if (pt->timeless_decoding || !pt->have_sched_switch) ptq->use_buffer_pid_tid = true; } + + ptq->sync_switch = pt->sync_switch; }if (!ptq->on_heap && - (!pt->sync_switch || + (!ptq->sync_switch || ptq->switch_state !=INTEL_PT_SS_EXPECTING_SWITCH_EVENT )) {const struct intel_pt_state *state;int ret;
@@ -1549,7 +1552,7 @@ static int intel_pt_sample(struct intel_pt_queue *ptq)if (pt->synth_opts.last_branch)intel_pt_update_last_branch_rb (ptq); -if (!pt->sync_switch) +if (!ptq->sync_switch)return 0 ;if (intel_pt_is_switch_ip (ptq, state->to_ip)) {
@@ -1630,6 +1633,21 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip)return switch_ip; } +static void intel_pt_enable_sync_switch (struct intel_pt *pt) +{ +unsigned int i; + + pt->sync_switch = true; + +for (i =0 ; i < pt->queues.nr_queues; i++) { +struct auxtrace_queue *queue = &pt->queues.queue_array[i]; +struct intel_pt_queue *ptq = queue->priv; + +if (ptq) + ptq->sync_switch = true; + } +} +static int intel_pt_run_decoder (struct intel_pt_queue *ptq,u64 *timestamp) {const struct intel_pt_state *state = ptq->state;
@@ -1646,7 +1664,7 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)if (pt->switch_ip) {intel_pt_log ("switch_ip: %" PRIx64" ptss_ip: %" PRIx64"\n" , pt->switch_ip, pt->ptss_ip); - pt->sync_switch = true; +intel_pt_enable_sync_switch (pt); } } }
@@ -1662,9 +1680,9 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)if (state->err) {if (state->err ==INTEL_PT_ERR_NODATA )return 1 ; -if (pt->sync_switch && +if (ptq->sync_switch && state->from_ip >= pt->kernel_start) { - pt->sync_switch = false; + ptq->sync_switch = false;intel_pt_next_tid (pt, ptq); }if (pt->synth_opts.errors) {
@@ -1690,7 +1708,7 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp) state->timestamp, state->est_timestamp); ptq->timestamp = state->est_timestamp;/* Use estimated TSC in unknown switch state */ - }else if (pt->sync_switch && + }else if (ptq->sync_switch && ptq->switch_state ==INTEL_PT_SS_UNKNOWN &&intel_pt_is_switch_ip (ptq, state->to_ip) && ptq->next_tid ==-1 ) {
@@ -1837,7 +1855,7 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid,return 1 ; ptq =intel_pt_cpu_to_ptq (pt, cpu); -if (!ptq) +if (!ptq || !ptq->sync_switch)return 1 ;switch (ptq->switch_state) {
Adrian Hunter
reviewerPATCH 3/9 perf intel-pt: Fix error recovery from missing TIP packet
In reply to Adrian HunterWhen a TIP packet is expected but there is a different packet, it is an error. However the unexpected packet might be something important like a TSC packet, so after the error, it is necessary to continue from there, rather than the next packet. That is achieved by setting pkt_step to zero.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +1 -0
@@ -1616,6 +1616,7 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)case INTEL_PT_PWRX :intel_pt_log ("ERROR: Missing TIP after FUP\n" ); decoder->pkt_state =INTEL_PT_STATE_ERR3 ; + decoder->pkt_step =0 ;return -ENOENT ;case INTEL_PT_OVF :
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Fix error recovery from missing TIP packet
perf intel-pt: Fix error recovery from missing TIP packet
Commit-ID: 1c196a6c771c47a2faa63d38d913e03284f73a16 Gitweb: https://git.kernel.org/tip/1c196a6c771c47a2faa63d38d913e03284f73a16 Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:23 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:55 -0300
perf intel-pt: Fix error recovery from missing TIP packet
When a TIP packet is expected but there is a different packet, it is an error. However the unexpected packet might be something important like a TSC packet, so after the error, it is necessary to continue from there, rather than the next packet. That is achieved by setting pkt_step to zero.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +1 -0
@@ -1616,6 +1616,7 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)case INTEL_PT_PWRX :intel_pt_log ("ERROR: Missing TIP after FUP\n" ); decoder->pkt_state =INTEL_PT_STATE_ERR3 ; + decoder->pkt_step =0 ;return -ENOENT ;case INTEL_PT_OVF :
Adrian Hunter
reviewerPATCH 4/9 perf intel-pt: Fix timestamp following overflow
In reply to Adrian Huntertimestamp_insn_cnt is used to estimate the timestamp based on the number of instructions since the last known timestamp. If the estimate is not accurate enough decoding might not be correctly synchronized with side-band events causing more trace errors. However there are always timestamps following an overflow, so the estimate is not needed and can indeed result in more errors. Suppress the estimate by setting timestamp_insn_cnt to zero.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +1 -0
@@ -1378,6 +1378,7 @@ static int intel_pt_overflow(struct intel_pt_decoder *decoder)intel_pt_clear_tx_flags (decoder); decoder->have_tma = false; decoder->cbr =0 ; + decoder->timestamp_insn_cnt =0 ; decoder->pkt_state =INTEL_PT_STATE_ERR_RESYNC ; decoder->overflow = true;return -EOVERFLOW ;
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Fix timestamp following overflow
perf intel-pt: Fix timestamp following overflow
Commit-ID: 91d29b288aed3406caf7c454bf2b898c96cfd177 Gitweb: https://git.kernel.org/tip/91d29b288aed3406caf7c454bf2b898c96cfd177 Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:24 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:56 -0300
perf intel-pt: Fix timestamp following overflow
timestamp_insn_cnt is used to estimate the timestamp based on the number of instructions since the last known timestamp.
If the estimate is not accurate enough decoding might not be correctly synchronized with side-band events causing more trace errors.
However there are always timestamps following an overflow, so the estimate is not needed and can indeed result in more errors.
Suppress the estimate by setting timestamp_insn_cnt to zero.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +1 -0
@@ -1378,6 +1378,7 @@ static int intel_pt_overflow(struct intel_pt_decoder *decoder)intel_pt_clear_tx_flags (decoder); decoder->have_tma = false; decoder->cbr =0 ; + decoder->timestamp_insn_cnt =0 ; decoder->pkt_state =INTEL_PT_STATE_ERR_RESYNC ; decoder->overflow = true;return -EOVERFLOW ;
Adrian Hunter
reviewerPATCH 5/9 perf intel-pt/bts: In auxtrace_record__init_intel() evlist is never NULL
In reply to Adrian HunterTidy auxtrace_record__init_intel() slightly by recognizing that evlist is never NULL.
--- tools/perf/arch/x86/util/auxtrace.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
tools/perf/arch/x86/util/auxtrace.c +5 -9
@@ -37,15 +37,11 @@ struct auxtrace_record *auxtrace_record__init_intel(struct perf_evlist *evlist, intel_pt_pmu =perf_pmu__find (INTEL_PT_PMU_NAME ); intel_bts_pmu =perf_pmu__find (INTEL_BTS_PMU_NAME ); -if (evlist) { -evlist__for_each_entry (evlist, evsel) { -if (intel_pt_pmu && - evsel->attr.type == intel_pt_pmu->type) - found_pt = true; -if (intel_bts_pmu && - evsel->attr.type == intel_bts_pmu->type) - found_bts = true; - } +evlist__for_each_entry (evlist, evsel) { +if (intel_pt_pmu && evsel->attr.type == intel_pt_pmu->type) + found_pt = true; +if (intel_bts_pmu && evsel->attr.type == intel_bts_pmu->type) + found_bts = true; }if (found_pt && found_bts) {
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt/bts: In auxtrace_record__init_intel() evlist is never NULL
perf intel-pt/bts: In auxtrace_record__init_intel() evlist is never NULL
Commit-ID: 15d599a25c7649807a2b66f7100efcf030665068 Gitweb: https://git.kernel.org/tip/15d599a25c7649807a2b66f7100efcf030665068 Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:25 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:56 -0300
perf intel-pt/bts: In auxtrace_record__init_intel() evlist is never NULL
Tidy auxtrace_record__init_intel() slightly by recognizing that evlist is never NULL.
--- tools/perf/arch/x86/util/auxtrace.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
tools/perf/arch/x86/util/auxtrace.c +5 -9
@@ -37,15 +37,11 @@ struct auxtrace_record *auxtrace_record__init_intel(struct perf_evlist *evlist, intel_pt_pmu =perf_pmu__find (INTEL_PT_PMU_NAME ); intel_bts_pmu =perf_pmu__find (INTEL_BTS_PMU_NAME ); -if (evlist) { -evlist__for_each_entry (evlist, evsel) { -if (intel_pt_pmu && - evsel->attr.type == intel_pt_pmu->type) - found_pt = true; -if (intel_bts_pmu && - evsel->attr.type == intel_bts_pmu->type) - found_bts = true; - } +evlist__for_each_entry (evlist, evsel) { +if (intel_pt_pmu && evsel->attr.type == intel_pt_pmu->type) + found_pt = true; +if (intel_bts_pmu && evsel->attr.type == intel_bts_pmu->type) + found_bts = true; }if (found_pt && found_bts) {
Adrian Hunter
reviewerPATCH 6/9 perf intel-pt: Get rid of intel_pt_use_buffer_pid_tid()
In reply to Adrian HunterWith the new way sampling support will be implemented, intel_pt_use_buffer_pid_tid() will not be needed. Get rid of it.
--- tools/perf/util/intel-pt.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-)
tools/perf/util/intel-pt.c +3 -36
@@ -222,32 +222,6 @@ static int intel_pt_do_fix_overlap(struct intel_pt *pt, struct auxtrace_buffer *return 0 ; } -static void intel_pt_use_buffer_pid_tid (struct intel_pt_queue *ptq, -struct auxtrace_queue *queue, -struct auxtrace_buffer *buffer) -{ -if (queue->cpu ==-1 && buffer->cpu !=-1 ) - ptq->cpu = buffer->cpu; - - ptq->pid = buffer->pid; - ptq->tid = buffer->tid; - -intel_pt_log ("queue %u cpu %d pid %d tid %d\n" , - ptq->queue_nr, ptq->cpu, ptq->pid, ptq->tid); - -thread__zput (ptq->thread); - -if (ptq->tid !=-1 ) { -if (ptq->pid !=-1 ) - ptq->thread =machine__findnew_thread (ptq->pt->machine, - ptq->pid, - ptq->tid); -else - ptq->thread =machine__find_thread (ptq->pt->machine,-1 , - ptq->tid); - } -} -/* This function assumes data is processed sequentially only */ static int intel_pt_get_trace (struct intel_pt_buffer *b,void *data) {
@@ -311,10 +285,6 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) b->consecutive = true; } -if (ptq->use_buffer_pid_tid && (ptq->pid != buffer->pid || - ptq->tid != buffer->tid)) -intel_pt_use_buffer_pid_tid (ptq, queue, buffer); -if (ptq->step_through_buffers) ptq->stop = true;
@@ -958,12 +928,9 @@ static int intel_pt_setup_queue(struct intel_pt *pt, ptq->cpu = queue->cpu; ptq->tid = queue->tid; -if (pt->sampling_mode) { -if (pt->timeless_decoding) - ptq->step_through_buffers = true; -if (pt->timeless_decoding || !pt->have_sched_switch) - ptq->use_buffer_pid_tid = true; - } +if (pt->sampling_mode && !pt->snapshot_mode && + pt->timeless_decoding) + ptq->step_through_buffers = true; ptq->sync_switch = pt->sync_switch; }
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Get rid of intel_pt_use_buffer_pid_tid()
perf intel-pt: Get rid of intel_pt_use_buffer_pid_tid()
Commit-ID: 1c071c80d9661c263b043969fd92305037bf9773 Gitweb: https://git.kernel.org/tip/1c071c80d9661c263b043969fd92305037bf9773 Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:26 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:57 -0300
perf intel-pt: Get rid of intel_pt_use_buffer_pid_tid()
With the new way sampling support will be implemented, intel_pt_use_buffer_pid_tid() will not be needed. Get rid of it.
--- tools/perf/util/intel-pt.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-)
tools/perf/util/intel-pt.c +3 -36
@@ -222,32 +222,6 @@ static int intel_pt_do_fix_overlap(struct intel_pt *pt, struct auxtrace_buffer *return 0 ; } -static void intel_pt_use_buffer_pid_tid (struct intel_pt_queue *ptq, -struct auxtrace_queue *queue, -struct auxtrace_buffer *buffer) -{ -if (queue->cpu ==-1 && buffer->cpu !=-1 ) - ptq->cpu = buffer->cpu; - - ptq->pid = buffer->pid; - ptq->tid = buffer->tid; - -intel_pt_log ("queue %u cpu %d pid %d tid %d\n" , - ptq->queue_nr, ptq->cpu, ptq->pid, ptq->tid); - -thread__zput (ptq->thread); - -if (ptq->tid !=-1 ) { -if (ptq->pid !=-1 ) - ptq->thread =machine__findnew_thread (ptq->pt->machine, - ptq->pid, - ptq->tid); -else - ptq->thread =machine__find_thread (ptq->pt->machine,-1 , - ptq->tid); - } -} -/* This function assumes data is processed sequentially only */ static int intel_pt_get_trace (struct intel_pt_buffer *b,void *data) {
@@ -311,10 +285,6 @@ next: b->consecutive = true; } -if (ptq->use_buffer_pid_tid && (ptq->pid != buffer->pid || - ptq->tid != buffer->tid)) -intel_pt_use_buffer_pid_tid (ptq, queue, buffer); -if (ptq->step_through_buffers) ptq->stop = true;
@@ -958,12 +928,9 @@ static int intel_pt_setup_queue(struct intel_pt *pt, ptq->cpu = queue->cpu; ptq->tid = queue->tid; -if (pt->sampling_mode) { -if (pt->timeless_decoding) - ptq->step_through_buffers = true; -if (pt->timeless_decoding || !pt->have_sched_switch) - ptq->use_buffer_pid_tid = true; - } +if (pt->sampling_mode && !pt->snapshot_mode && + pt->timeless_decoding) + ptq->step_through_buffers = true; ptq->sync_switch = pt->sync_switch; }
Adrian Hunter
reviewerPATCH 7/9 perf intel-pt: Tidy old_buffer handling in intel_pt_get_trace()
In reply to Adrian Hunterintel_pt_get_trace() fixes overlaps between the current buffer and the previous buffer ('old_buffer'). However the previous buffer might not have had usable data (no PSB) so the comparison must be made against the previous buffer that had usable data. Tidy that by keeping a pointer for that purpose in struct intel_pt_queue.
--- tools/perf/util/intel-pt.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
tools/perf/util/intel-pt.c +11 -13
@@ -132,6 +132,7 @@ struct intel_pt_queue {struct intel_pt *pt;unsigned int queue_nr;struct auxtrace_buffer *buffer; +struct auxtrace_buffer *old_buffer;void *decoder;const struct intel_pt_state *state;struct ip_callchain *chain;
@@ -226,7 +227,8 @@ static int intel_pt_do_fix_overlap(struct intel_pt *pt, struct auxtrace_buffer *static int intel_pt_get_trace (struct intel_pt_buffer *b,void *data) {struct intel_pt_queue *ptq = data; -struct auxtrace_buffer *buffer = ptq->buffer, *old_buffer = buffer; +struct auxtrace_buffer *buffer = ptq->buffer; +struct auxtrace_buffer *old_buffer = ptq->old_buffer;struct auxtrace_queue *queue;if (ptq->stop) {
@@ -235,7 +237,7 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) } queue = &ptq->pt->queues.queue_array[ptq->queue_nr]; -next: + buffer =auxtrace_buffer__next (queue, buffer);if (!buffer) {if (old_buffer)
@@ -267,16 +269,6 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) } b->ref_timestamp = buffer->reference; -/* -* If in snapshot mode and the buffer has no usable data, get next -* buffer and again check overlap against old_buffer. -*/ -if (ptq->pt->snapshot_mode && !b->len) - goto next; - -if (old_buffer) -auxtrace_buffer__drop_data (old_buffer); -if (!old_buffer || ptq->pt->sampling_mode || (ptq->pt->snapshot_mode && !buffer->consecutive)) { b->consecutive = false;
@@ -288,8 +280,14 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data)if (ptq->step_through_buffers) ptq->stop = true; -if (!b->len) +if (b->len) { +if (old_buffer) +auxtrace_buffer__drop_data (old_buffer); + ptq->old_buffer = buffer; + }else { +auxtrace_buffer__drop_data (buffer);return intel_pt_get_trace (b, data); + }return 0 ; }
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Tidy old_buffer handling in intel_pt_get_trace()
perf intel-pt: Tidy old_buffer handling in intel_pt_get_trace()
Commit-ID: 9c6650647de430a6ad9707c51b3342f23af0d2ee Gitweb: https://git.kernel.org/tip/9c6650647de430a6ad9707c51b3342f23af0d2ee Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:27 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:57 -0300
perf intel-pt: Tidy old_buffer handling in intel_pt_get_trace()
intel_pt_get_trace() fixes overlaps between the current buffer and the previous buffer ('old_buffer').
However the previous buffer might not have had usable data (no PSB) so the comparison must be made against the previous buffer that had usable data.
Tidy that by keeping a pointer for that purpose in struct intel_pt_queue.
--- tools/perf/util/intel-pt.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
tools/perf/util/intel-pt.c +11 -13
@@ -132,6 +132,7 @@ struct intel_pt_queue {struct intel_pt *pt;unsigned int queue_nr;struct auxtrace_buffer *buffer; +struct auxtrace_buffer *old_buffer;void *decoder;const struct intel_pt_state *state;struct ip_callchain *chain;
@@ -226,7 +227,8 @@ static int intel_pt_do_fix_overlap(struct intel_pt *pt, struct auxtrace_buffer *static int intel_pt_get_trace (struct intel_pt_buffer *b,void *data) {struct intel_pt_queue *ptq = data; -struct auxtrace_buffer *buffer = ptq->buffer, *old_buffer = buffer; +struct auxtrace_buffer *buffer = ptq->buffer; +struct auxtrace_buffer *old_buffer = ptq->old_buffer;struct auxtrace_queue *queue;if (ptq->stop) {
@@ -235,7 +237,7 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) } queue = &ptq->pt->queues.queue_array[ptq->queue_nr]; -next: + buffer =auxtrace_buffer__next (queue, buffer);if (!buffer) {if (old_buffer)
@@ -267,16 +269,6 @@ next: } b->ref_timestamp = buffer->reference; -/* -* If in snapshot mode and the buffer has no usable data, get next -* buffer and again check overlap against old_buffer. -*/ -if (ptq->pt->snapshot_mode && !b->len) - goto next; - -if (old_buffer) -auxtrace_buffer__drop_data (old_buffer); -if (!old_buffer || ptq->pt->sampling_mode || (ptq->pt->snapshot_mode && !buffer->consecutive)) { b->consecutive = false;
@@ -288,8 +280,14 @@ next:if (ptq->step_through_buffers) ptq->stop = true; -if (!b->len) +if (b->len) { +if (old_buffer) +auxtrace_buffer__drop_data (old_buffer); + ptq->old_buffer = buffer; + }else { +auxtrace_buffer__drop_data (buffer);return intel_pt_get_trace (b, data); + }return 0 ; }
Adrian Hunter
reviewerPATCH 8/9 perf intel-pt: Remove a check for sampling mode
In reply to Adrian HunterIntel PT code already has some preparation for AUX area sampling mode. However the implementation has changed from the first proposal and one of the side-effects is that it will not be impossible to support snapshot mode and sampling mode at the same time. Although there are no plans to support it, let validation (not yet implemented) control whether it is allowed rather than low-level functions.
--- tools/perf/util/intel-pt.c | 3 --- 1 file changed, 3 deletions(-)
tools/perf/util/intel-pt.c +0 -3
@@ -2061,9 +2061,6 @@ static int intel_pt_process_auxtrace_event(struct perf_session *session, struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, auxtrace); -if (pt->sampling_mode) -return 0 ; -if (!pt->data_queued) {struct auxtrace_buffer *buffer;off_t data_offset;
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Remove a check for sampling mode
perf intel-pt: Remove a check for sampling mode
Commit-ID: 13f89dbafe73e56fd317c078bb1d3a45fd94ab7b Gitweb: https://git.kernel.org/tip/13f89dbafe73e56fd317c078bb1d3a45fd94ab7b Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:28 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:58 -0300
perf intel-pt: Remove a check for sampling mode
Intel PT code already has some preparation for AUX area sampling mode.
However the implementation has changed from the first proposal and one of the side-effects is that it will not be impossible to support snapshot mode and sampling mode at the same time.
Although there are no plans to support it, let validation (not yet implemented) control whether it is allowed rather than low-level functions.
--- tools/perf/util/intel-pt.c | 3 --- 1 file changed, 3 deletions(-)
tools/perf/util/intel-pt.c +0 -3
@@ -2061,9 +2061,6 @@ static int intel_pt_process_auxtrace_event(struct perf_session *session, struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, auxtrace); -if (pt->sampling_mode) -return 0 ; -if (!pt->data_queued) {struct auxtrace_buffer *buffer;off_t data_offset;
Adrian Hunter
reviewerPATCH 9/9 perf intel-pt: Adjust overlap-checking to support sampling mode
In reply to Adrian HunterAdjust overlap-checking to support sampling mode.
--- tools/perf/util/intel-pt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/perf/util/intel-pt.c +4 -3
@@ -230,6 +230,7 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data)struct auxtrace_buffer *buffer = ptq->buffer;struct auxtrace_buffer *old_buffer = ptq->old_buffer;struct auxtrace_queue *queue; +bool might_overlap;if (ptq->stop) { b->len =0 ;
@@ -256,7 +257,8 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data)return -ENOMEM ; } -if (ptq->pt->snapshot_mode && !buffer->consecutive && old_buffer && + might_overlap = ptq->pt->snapshot_mode || ptq->pt->sampling_mode; +if (might_overlap && !buffer->consecutive && old_buffer &&intel_pt_do_fix_overlap (ptq->pt, old_buffer, buffer))return -ENOMEM ;
@@ -269,8 +271,7 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) } b->ref_timestamp = buffer->reference; -if (!old_buffer || ptq->pt->sampling_mode || (ptq->pt->snapshot_mode && - !buffer->consecutive)) { +if (!old_buffer || (might_overlap && !buffer->consecutive)) { b->consecutive = false; b->trace_nr = buffer->buffer_nr +1 ; }else {
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Adjust overlap-checking to support sampling mode
perf intel-pt: Adjust overlap-checking to support sampling mode
Commit-ID: 599a5beb78ad95181677e7919f54dbd64b404cf7 Gitweb: https://git.kernel.org/tip/599a5beb78ad95181677e7919f54dbd64b404cf7 Author: Adrian Hunter <[email protected]> AuthorDate: Wed, 7 Mar 2018 16:02:29 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 8 Mar 2018 10:05:58 -0300
perf intel-pt: Adjust overlap-checking to support sampling mode
Adjust overlap-checking to support sampling mode.
--- tools/perf/util/intel-pt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/perf/util/intel-pt.c +4 -3
@@ -230,6 +230,7 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data)struct auxtrace_buffer *buffer = ptq->buffer;struct auxtrace_buffer *old_buffer = ptq->old_buffer;struct auxtrace_queue *queue; +bool might_overlap;if (ptq->stop) { b->len =0 ;
@@ -256,7 +257,8 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data)return -ENOMEM ; } -if (ptq->pt->snapshot_mode && !buffer->consecutive && old_buffer && + might_overlap = ptq->pt->snapshot_mode || ptq->pt->sampling_mode; +if (might_overlap && !buffer->consecutive && old_buffer &&intel_pt_do_fix_overlap (ptq->pt, old_buffer, buffer))return -ENOMEM ;
@@ -269,8 +271,7 @@ static int intel_pt_get_trace(struct intel_pt_buffer *b, void *data) } b->ref_timestamp = buffer->reference; -if (!old_buffer || ptq->pt->sampling_mode || (ptq->pt->snapshot_mode && - !buffer->consecutive)) { +if (!old_buffer || (might_overlap && !buffer->consecutive)) { b->consecutive = false; b->trace_nr = buffer->buffer_nr +1 ; }else {
Em Wed, Mar 07, 2018 at 04:02:20PM +0200, Adrian Hunter escreveu:
Quoted 4 lines
Hi
Here are 4 fixes for Intel PT plus 5 more patches in preparation for supporting AUX area sampling.
Thanks, applied to acme/perf/core.
- Arnaldo