mem: dump out port trace when address decode error

1. Add findPort(PacketPtr pkt) for getting the port trace from the Packet.
   Keep the findPort(AddrRange addr_range) for recvMemBackdoorReq(...)
2. With the debug flag `PortTrace` enabled, user can see the full path of
   the packet with the corresponding address when address error in xbar.

Change-Id: Iaf43ee2d7f8c46b9b84b2bc421a6bc3b02e01b3e
This commit is contained in:
Yan Lee
2023-08-15 00:25:38 -07:00
parent b01590fdf4
commit 96d80a41d2
4 changed files with 32 additions and 15 deletions

View File

@@ -159,7 +159,7 @@ CoherentXBar::recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
assert(is_express_snoop == cache_responding);
// determine the destination based on the destination address range
PortID mem_side_port_id = findPort(pkt->getAddrRange());
PortID mem_side_port_id = findPort(pkt);
// test if the crossbar should be considered occupied for the current
// port, and exclude express snoops from the check
@@ -563,7 +563,7 @@ CoherentXBar::recvTimingSnoopReq(PacketPtr pkt, PortID mem_side_port_id)
// device responsible for the address range something is
// wrong, hence there is nothing further to do as the packet
// would be going back to where it came from
assert(findPort(pkt->getAddrRange()) == mem_side_port_id);
assert(findPort(pkt) == mem_side_port_id);
}
bool
@@ -799,7 +799,7 @@ CoherentXBar::recvAtomicBackdoor(PacketPtr pkt, PortID cpu_side_port_id,
// even if we had a snoop response, we must continue and also
// perform the actual request at the destination
PortID mem_side_port_id = findPort(pkt->getAddrRange());
PortID mem_side_port_id = findPort(pkt);
if (sink_packet) {
DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__,
@@ -1035,7 +1035,7 @@ CoherentXBar::recvFunctional(PacketPtr pkt, PortID cpu_side_port_id)
}
}
PortID dest_id = findPort(pkt->getAddrRange());
PortID dest_id = findPort(pkt);
memSidePorts[dest_id]->sendFunctional(pkt);
}

View File

@@ -107,8 +107,8 @@ NoncoherentXBar::recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
// we should never see express snoops on a non-coherent crossbar
assert(!pkt->isExpressSnoop());
// determine the destination based on the address
PortID mem_side_port_id = findPort(pkt->getAddrRange());
// determine the destination port
PortID mem_side_port_id = findPort(pkt);
// test if the layer should be considered occupied for the current
// port
@@ -255,7 +255,7 @@ NoncoherentXBar::recvAtomicBackdoor(PacketPtr pkt, PortID cpu_side_port_id,
unsigned int pkt_cmd = pkt->cmdToIndex();
// determine the destination port
PortID mem_side_port_id = findPort(pkt->getAddrRange());
PortID mem_side_port_id = findPort(pkt);
// stats updates for the request
pktCount[cpu_side_port_id][mem_side_port_id]++;
@@ -316,7 +316,7 @@ NoncoherentXBar::recvFunctional(PacketPtr pkt, PortID cpu_side_port_id)
}
// determine the destination port
PortID dest_id = findPort(pkt->getAddrRange());
PortID dest_id = findPort(pkt);
// forward the request to the appropriate destination
memSidePorts[dest_id]->sendFunctional(pkt);

View File

@@ -45,6 +45,9 @@
#include "mem/xbar.hh"
#include <memory>
#include <string>
#include "base/logging.hh"
#include "base/trace.hh"
#include "debug/AddrRanges.hh"
@@ -328,7 +331,7 @@ BaseXBar::Layer<SrcType, DstType>::recvRetry()
}
PortID
BaseXBar::findPort(AddrRange addr_range)
BaseXBar::findPort(AddrRange addr_range, PacketPtr pkt)
{
// we should never see any address lookups before we've got the
// ranges of all connected CPU-side-port modules
@@ -353,10 +356,17 @@ BaseXBar::findPort(AddrRange addr_range)
return defaultPortID;
}
// we should use the range for the default port and it did not
// match, or the default port is not set
fatal("Unable to find destination for %s on %s\n", addr_range.to_string(),
name());
// We should use the range for the default port and it did not match,
// or the default port is not set. Dump out the port trace if possible.
std::string port_trace = "";
if (pkt) {
std::shared_ptr<TracingExtension> ext =
pkt->getExtension<TracingExtension>();
port_trace = ext ? ext->getTraceInString() :
"Use --debug-flags=PortTrace to see the port trace of the packet.";
}
fatal("Unable to find destination for %s on %s\n%s\n",
addr_range.to_string(), name(), port_trace);
}
/** Function called by the port when the crossbar is receiving a range change.*/

View File

@@ -344,9 +344,16 @@ class BaseXBar : public ClockedObject
* given a packet with this address range.
*
* @param addr_range Address range to find port for.
* @return id of port that the packet should be sent out of.
* @param pkt Packet that containing the address range.
* @return id of port that the packet should be sent ou of.
*/
PortID findPort(AddrRange addr_range);
PortID findPort(AddrRange addr_range, PacketPtr pkt=nullptr);
PortID
findPort(PacketPtr pkt)
{
return findPort(pkt->getAddrRange(), pkt);
}
/**
* Return the address ranges the crossbar is responsible for.