Hi guys!
I am trying to expand some functions to flush all dirty blk form Cache to 
memory.My plan is below :
 In BaseCache::recvTimingReq function.I use wb_pkts to store all writeback 
pkt.The my_memWriteback will traverse all cacheblk and return the number of 
dirty.For each blk it will call my_writebackVisitor to make new paket and put 
it into wb_pkts.But I meet bug and don't know what's going on. The bug says 
that "panic: Tried to read unmapped address 0x8.PC: 0x400ffa, Instr:  
 MOV_R_M : ld   rax, DS:[rax + 0x8]PacketList wb_pkts". And I 
run with --debug-flags=DRAM,Cache will see that cache never sends paket to 
memory controller.


My expanding code shows below
wb_pkts.clear();
dirty_blk_count = my_memWriteback(wb_pkts);
bool satisfied = false;
    {
        PacketList writebacks;
        satisfied = access(pkt, blk, lat, writebacks);
.....

int
BaseCache::my_memWriteback(PacketList &wb_pkts)
{
    int count = 0;
    tags->forEachBlk([this,&count,&wb_pkts](CacheBlk 
&blk) mutable{
                      
  if(blk.isDirty()){
                      
          if(blk.isValid()){
                      
                  count++;
                      
          }
                      
  }
                      
  my_writebackVisitor(blk,wb_pkts);
                    });
    //printf("NmemWriteback count:%d\n",count);
    return count;
}

BaseCache::my_writebackVisitor(CacheBlk &blk,PacketList &writebacks)
{
    if (blk.isDirty()) {
        assert(blk.isValid());
&nbsp; &nbsp; &nbsp; &nbsp; RequestPtr request = std::make_shared<Request&gt;(
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; regenerateBlkAddr(&amp;blk), blkSize, 
0, Request::funcMasterId);
&nbsp; &nbsp; &nbsp; &nbsp; request-&gt;taskId(blk.task_id);
&nbsp; &nbsp; &nbsp; &nbsp; if (blk.isSecure()) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request-&gt;setFlags(Request::SECURE);
&nbsp; &nbsp; &nbsp; &nbsp; }

&nbsp; &nbsp; &nbsp; &nbsp; PacketPtr packet = new Packet(request, 
MemCmd::WriteReq);
&nbsp; &nbsp; &nbsp; &nbsp; packet-&gt;allocate();
&nbsp; &nbsp; &nbsp; &nbsp; std::memcpy(packet-&gt;getPtr<uint8_t&gt;(), 
blk.data, blkSize);
&nbsp; &nbsp; &nbsp; &nbsp; // packet-&gt;dataStatic(blk.data);
&nbsp; &nbsp; &nbsp; &nbsp; writebacks.push_back(packet);
&nbsp; &nbsp; &nbsp; &nbsp; //memSidePort.sendTimingReq(&amp;packet);

&nbsp; &nbsp; &nbsp; &nbsp; blk.status &amp;= ~BlkDirty;
&nbsp; &nbsp; }
}
_______________________________________________
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to