提交 0adecae3 编写于 作者: A Adrian Hunter 提交者: Zheng Zengkai

perf intel-pt: Fix state setting when receiving overflow (OVF) packet

stable inclusion
from stable-v5.10.87
commit 02681dd1780a3aeb31381f5f01b9f9b14909eb57
bugzilla: 186049 https://gitee.com/openeuler/kernel/issues/I4QVYL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=02681dd1780a3aeb31381f5f01b9f9b14909eb57

--------------------------------

commit c79ee2b2 upstream.

An overflow (OVF packet) is treated as an error because it represents a
loss of trace data, but there is no loss of synchronization, so the packet
state should be INTEL_PT_STATE_IN_SYNC not INTEL_PT_STATE_ERR_RESYNC.

To support that, some additional variables must be reset, and the FUP
packet that may follow OVF is treated as an FUP event.

Fixes: f4aa0819 ("perf tools: Add Intel PT decoder")
Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@vger.kernel.org # v5.15+
Link: https://lore.kernel.org/r/20211210162303.2288710-5-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
[Adrian: Backport to v5.10]
Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 116ba62c
...@@ -1158,6 +1158,20 @@ static bool intel_pt_fup_event(struct intel_pt_decoder *decoder) ...@@ -1158,6 +1158,20 @@ static bool intel_pt_fup_event(struct intel_pt_decoder *decoder)
decoder->state.type |= INTEL_PT_BLK_ITEMS; decoder->state.type |= INTEL_PT_BLK_ITEMS;
ret = true; ret = true;
} }
if (decoder->overflow) {
decoder->overflow = false;
if (!ret && !decoder->pge) {
if (decoder->hop) {
decoder->state.type = 0;
decoder->pkt_state = INTEL_PT_STATE_RESAMPLE;
}
decoder->pge = true;
decoder->state.type |= INTEL_PT_BRANCH | INTEL_PT_TRACE_BEGIN;
decoder->state.from_ip = 0;
decoder->state.to_ip = decoder->ip;
return true;
}
}
if (ret) { if (ret) {
decoder->state.from_ip = decoder->ip; decoder->state.from_ip = decoder->ip;
decoder->state.to_ip = 0; decoder->state.to_ip = 0;
...@@ -1480,7 +1494,16 @@ static int intel_pt_overflow(struct intel_pt_decoder *decoder) ...@@ -1480,7 +1494,16 @@ static int intel_pt_overflow(struct intel_pt_decoder *decoder)
intel_pt_log("ERROR: Buffer overflow\n"); intel_pt_log("ERROR: Buffer overflow\n");
intel_pt_clear_tx_flags(decoder); intel_pt_clear_tx_flags(decoder);
decoder->timestamp_insn_cnt = 0; decoder->timestamp_insn_cnt = 0;
decoder->pkt_state = INTEL_PT_STATE_ERR_RESYNC; decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
decoder->state.from_ip = decoder->ip;
decoder->ip = 0;
decoder->pge = false;
decoder->set_fup_tx_flags = false;
decoder->set_fup_ptw = false;
decoder->set_fup_mwait = false;
decoder->set_fup_pwre = false;
decoder->set_fup_exstop = false;
decoder->set_fup_bep = false;
decoder->overflow = true; decoder->overflow = true;
return -EOVERFLOW; return -EOVERFLOW;
} }
...@@ -2083,6 +2106,7 @@ static int intel_pt_walk_trace(struct intel_pt_decoder *decoder) ...@@ -2083,6 +2106,7 @@ static int intel_pt_walk_trace(struct intel_pt_decoder *decoder)
case INTEL_PT_TIP_PGE: { case INTEL_PT_TIP_PGE: {
decoder->pge = true; decoder->pge = true;
decoder->overflow = false;
intel_pt_mtc_cyc_cnt_pge(decoder); intel_pt_mtc_cyc_cnt_pge(decoder);
if (decoder->packet.count == 0) { if (decoder->packet.count == 0) {
intel_pt_log_at("Skipping zero TIP.PGE", intel_pt_log_at("Skipping zero TIP.PGE",
...@@ -2596,10 +2620,10 @@ static int intel_pt_sync_ip(struct intel_pt_decoder *decoder) ...@@ -2596,10 +2620,10 @@ static int intel_pt_sync_ip(struct intel_pt_decoder *decoder)
decoder->set_fup_pwre = false; decoder->set_fup_pwre = false;
decoder->set_fup_exstop = false; decoder->set_fup_exstop = false;
decoder->set_fup_bep = false; decoder->set_fup_bep = false;
decoder->overflow = false;
if (!decoder->branch_enable) { if (!decoder->branch_enable) {
decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
decoder->overflow = false;
decoder->state.type = 0; /* Do not have a sample */ decoder->state.type = 0; /* Do not have a sample */
return 0; return 0;
} }
...@@ -2614,7 +2638,6 @@ static int intel_pt_sync_ip(struct intel_pt_decoder *decoder) ...@@ -2614,7 +2638,6 @@ static int intel_pt_sync_ip(struct intel_pt_decoder *decoder)
decoder->pkt_state = INTEL_PT_STATE_RESAMPLE; decoder->pkt_state = INTEL_PT_STATE_RESAMPLE;
else else
decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
decoder->overflow = false;
decoder->state.from_ip = 0; decoder->state.from_ip = 0;
decoder->state.to_ip = decoder->ip; decoder->state.to_ip = decoder->ip;
...@@ -2823,7 +2846,8 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder) ...@@ -2823,7 +2846,8 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder)
if (err) { if (err) {
decoder->state.err = intel_pt_ext_err(err); decoder->state.err = intel_pt_ext_err(err);
decoder->state.from_ip = decoder->ip; if (err != -EOVERFLOW)
decoder->state.from_ip = decoder->ip;
intel_pt_update_sample_time(decoder); intel_pt_update_sample_time(decoder);
decoder->sample_tot_cyc_cnt = decoder->tot_cyc_cnt; decoder->sample_tot_cyc_cnt = decoder->tot_cyc_cnt;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册