gem5-users@gem5.org

The gem5 Users mailing list

View all threads

Forceful Write-Back of Dirty Blocks in LLC

Z
zahramoein25@yahoo.com
Thu, Sep 26, 2024 7:04 PM

Hello everyone,

I try to write back all dirty blocks from the last level cache to main memory without evicting any dirty blocks from the last level cache (cleaning dirty blocks in LLC). To accomplish this, I plan to use the memwriteback() function.

How can I ensure that only dirty blocks from the last level cache are written back and dirty blocks from other cache levels are not written back?

 

void Cache::memWriteback()

 {

  CacheBlkVisitorWrapper visitor(*this, &Cache::writebackVisitor);

  tags->forEachBlk(visitor);

 }

 

 ////

 

bool Cache::writebackVisitor(CacheBlk &blk)

 {

  if (blk.isDirty()) {

    assert(blk.isValid());

    Request request(tags->regenerateBlkAddr(blk.tag, blk.set),

    blkSize, 0, Request::funcMasterId);

    request.taskId(blk.task_id);

    if (blk.isSecure()) {

      request.setFlags(Request::SECURE);

    }

    Packet packet(&request, MemCmd::WriteReq);

    packet.dataStatic(blk.data);

    memSidePort->sendFunctional(&packet);

 

    blk.status &= ~BlkDirty;

   } 

  return true;

}

Hello everyone, I try to write back all dirty blocks from the last level cache to main memory without evicting any dirty blocks from the last level cache (cleaning dirty blocks in LLC). To accomplish this, I plan to use the memwriteback() function. How can I ensure that only dirty blocks from the last level cache are written back and dirty blocks from other cache levels are not written back?   void Cache::memWriteback()  {   CacheBlkVisitorWrapper visitor(\*this, &Cache::writebackVisitor);   tags->forEachBlk(visitor);  }    ////   bool Cache::writebackVisitor(CacheBlk &blk)  {   if (blk.isDirty()) {     assert(blk.isValid());     Request request(tags->regenerateBlkAddr(blk.tag, blk.set),     blkSize, 0, Request::funcMasterId);     request.taskId(blk.task_id);     if (blk.isSecure()) {       request.setFlags(Request::SECURE);     }     Packet packet(&request, MemCmd::WriteReq);     packet.dataStatic(blk.data);     memSidePort->sendFunctional(&packet);       blk.status &= \~BlkDirty;    }    return true; }