gem5 v24.0.0.0
Loading...
Searching...
No Matches
gem5::FlashDevice Class Reference

Flash Device model The Flash Device model is a timing model for a NAND flash device. More...

#include <flash_device.hh>

Inheritance diagram for gem5::FlashDevice:
gem5::AbstractNVM gem5::SimObject gem5::EventManager gem5::Serializable gem5::Drainable gem5::statistics::Group gem5::Named

Classes

struct  CallBackEntry
 
struct  FlashDeviceStats
 
struct  PageMapEntry
 Every logical address maps to a physical block and a physical page. More...
 

Public Member Functions

 FlashDevice (const FlashDeviceParams &)
 Initialize functions.
 
 ~FlashDevice ()
 
DrainState drain () override
 Checkpoint functions.
 
void checkDrain ()
 Checkdrain; needed to enable checkpoints.
 
void serialize (CheckpointOut &cp) const override
 Serialize; needed to create checkpoints.
 
void unserialize (CheckpointIn &cp) override
 Unserialize; needed to restore from checkpoints.
 
- Public Member Functions inherited from gem5::AbstractNVM
 AbstractNVM (const AbstractNVMParams &p)
 
virtual ~AbstractNVM ()
 
- Public Member Functions inherited from gem5::SimObject
const Paramsparams () const
 
 SimObject (const Params &p)
 
virtual ~SimObject ()
 
virtual void init ()
 init() is called after all C++ SimObjects have been created and all ports are connected.
 
virtual void loadState (CheckpointIn &cp)
 loadState() is called on each SimObject when restoring from a checkpoint.
 
virtual void initState ()
 initState() is called on each SimObject when not restoring from a checkpoint.
 
virtual void regProbePoints ()
 Register probe points for this object.
 
virtual void regProbeListeners ()
 Register probe listeners for this object.
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object.
 
virtual PortgetPort (const std::string &if_name, PortID idx=InvalidPortID)
 Get a port with a given name and index.
 
virtual void startup ()
 startup() is the final initialization call before simulation.
 
DrainState drain () override
 Provide a default implementation of the drain interface for objects that don't need draining.
 
virtual void memWriteback ()
 Write back dirty buffers to memory using functional writes.
 
virtual void memInvalidate ()
 Invalidate the contents of memory buffers.
 
void serialize (CheckpointOut &cp) const override
 Serialize an object.
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object.
 
- Public Member Functions inherited from gem5::EventManager
EventQueueeventQueue () const
 
void schedule (Event &event, Tick when)
 
void deschedule (Event &event)
 
void reschedule (Event &event, Tick when, bool always=false)
 
void schedule (Event *event, Tick when)
 
void deschedule (Event *event)
 
void reschedule (Event *event, Tick when, bool always=false)
 
void wakeupEventQueue (Tick when=(Tick) -1)
 This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers.
 
void setCurTick (Tick newVal)
 
 EventManager (EventManager &em)
 Event manger manages events in the event queue.
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
- Public Member Functions inherited from gem5::Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section.
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object.
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 
- Public Member Functions inherited from gem5::Drainable
DrainState drainState () const
 Return the current drain state of an object.
 
virtual void notifyFork ()
 Notify a child process of a fork.
 
- Public Member Functions inherited from gem5::statistics::Group
 Group (Group *parent, const char *name=nullptr)
 Construct a new statistics group.
 
virtual ~Group ()
 
virtual void regStats ()
 Callback to set stat parameters.
 
virtual void resetStats ()
 Callback to reset stats.
 
virtual void preDumpStats ()
 Callback before stats are dumped.
 
void addStat (statistics::Info *info)
 Register a stat with this group.
 
const std::map< std::string, Group * > & getStatGroups () const
 Get all child groups associated with this object.
 
const std::vector< Info * > & getStats () const
 Get all stats associated with this object.
 
void addStatGroup (const char *name, Group *block)
 Add a stat block as a child of this block.
 
const InforesolveStat (std::string name) const
 Resolve a stat by its name within this group.
 
void mergeStatGroup (Group *block)
 Merge the contents (stats & children) of a block to this block.
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (const Group &)=delete
 
- Public Member Functions inherited from gem5::Named
 Named (const std::string &name_)
 
virtual ~Named ()=default
 
virtual std::string name () const
 

Private Types

enum  Actions { ActionRead , ActionWrite , ActionErase , ActionCopy }
 Defines the possible actions to the flash. More...
 

Private Member Functions

void initializeMemory (uint64_t disk_size, uint32_t sector_size) override
 Device access functions Inherrited from AbstractNVM.
 
void readMemory (uint64_t address, uint32_t amount, const std::function< void()> &event) override
 Access functions Access function to simulate a read/write access to the memory.
 
void writeMemory (uint64_t address, uint32_t amount, const std::function< void()> &event) override
 
void initializeFlash (uint64_t disk_size, uint32_t sector_size)
 Initialization function; called when all disk specifics are known.
 
void accessDevice (uint64_t address, uint32_t amount, const std::function< void()> &event, Actions action)
 Flash action function.
 
void actionComplete ()
 Event rescheduler.
 
Tick remap (uint64_t logic_page_addr)
 FTL functionality.
 
Tick accessTimes (uint64_t address, Actions accesstype)
 Access time calculator.
 
void clearUnknownPages (uint32_t index)
 Function to indicate that a page is known.
 
bool getUnknownPages (uint32_t index)
 Function to test if a page is known.
 

Private Attributes

uint64_t diskSize
 Disk sizes in bytes.
 
const uint32_t blockSize
 
const uint32_t pageSize
 
const uint32_t GCActivePercentage
 Garbage collection algorithm emulator.
 
const Tick readLatency
 Access latencies.
 
const Tick writeLatency
 
const Tick eraseLatency
 
const enums::DataDistribution dataDistribution
 Flash organization.
 
const uint32_t numPlanes
 
struct FlashDeviceStats stats
 RequestHandler stats.
 
uint32_t pagesPerBlock
 Disk dimensions in pages and blocks.
 
uint32_t pagesPerDisk
 
uint32_t blocksPerDisk
 
uint32_t planeMask
 
std::vector< uint32_t > unknownPages
 when the disk is first started we are unsure of the number of used pages, this variable will help determining what we do know.
 
std::vector< struct PageMapEntrylocationTable
 address to logic place has a block and a page field
 
std::vector< uint32_t > blockValidEntries
 number of valid entries per block
 
std::vector< uint32_t > blockEmptyEntries
 number of empty entries
 
std::vector< std::deque< struct CallBackEntry > > planeEventQueue
 This vector of queues keeps track of all the callbacks per plane.
 
EventFunctionWrapper planeEvent
 Completion event.
 

Additional Inherited Members

- Public Types inherited from gem5::SimObject
typedef SimObjectParams Params
 
- Static Public Member Functions inherited from gem5::SimObject
static void serializeAll (const std::string &cpt_dir)
 Create a checkpoint by serializing all SimObjects in the system.
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it.
 
static void setSimObjectResolver (SimObjectResolver *resolver)
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints.
 
static SimObjectResolvergetSimObjectResolver ()
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints.
 
- Static Public Member Functions inherited from gem5::Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section.
 
static void generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream)
 Generate a checkpoint file so that the serialization can be routed to it.
 
- Protected Member Functions inherited from gem5::Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain.
 
void signalDrainDone () const
 Signal that an object is drained.
 
- Protected Attributes inherited from gem5::SimObject
const SimObjectParams & _params
 Cached copy of the object parameters.
 
- Protected Attributes inherited from gem5::EventManager
EventQueueeventq
 A pointer to this object's event queue.
 

Detailed Description

Flash Device model The Flash Device model is a timing model for a NAND flash device.

It doesn't tranfer any data

Definition at line 57 of file flash_device.hh.

Member Enumeration Documentation

◆ Actions

Defines the possible actions to the flash.

Enumerator
ActionRead 
ActionWrite 
ActionErase 
ActionCopy 

A copy involves taking all the used pages from a block and store it in another.

Definition at line 74 of file flash_device.hh.

Constructor & Destructor Documentation

◆ FlashDevice()

gem5::FlashDevice::FlashDevice ( const FlashDeviceParams & p)

Initialize functions.

Flash Device constructor and destructor.

Definition at line 65 of file flash_device.cc.

References actionComplete().

◆ ~FlashDevice()

gem5::FlashDevice::~FlashDevice ( )

Definition at line 145 of file flash_device.cc.

References DPRINTF.

Member Function Documentation

◆ accessDevice()

void gem5::FlashDevice::accessDevice ( uint64_t address,
uint32_t amount,
const std::function< void()> & event,
Actions action )
private

Flash action function.

Handles the accesses to the device.

The function determines when certain actions are scheduled and schedules an event that uses the callback function on completion of the action.

The access will be broken up in a number of page accesses. The number of page accesses depends on the amount that needs to be transfered. The assumption here is that the interface is completely ignorant of the page size and that this model has to figure out all of the transaction characteristics.

Check if the page is known and used. unknownPages is a bitmap of all the pages. It tracks wether we can be sure that the information of this page is taken into acount in the model (is it considered in blockValidEntries and blockEmptyEntries?). If it has been used in the past, then it is known.

previous part of the function found the times spend in different planes, now lets find the maximum to know when to callback the disk

If there are no events for this plane, then add the current time to the occupation time; otherwise, plan it after the last event. If by chance that event is handled in this tick, then we would still end up with the same result.

Definition at line 156 of file flash_device.cc.

References accessTimes(), ActionRead, ActionWrite, gem5::QARMA::amount, blockEmptyEntries, blockValidEntries, clearUnknownPages(), gem5::X86ISA::count, gem5::curTick(), DPRINTF, gem5::MipsISA::event, gem5::FlashDevice::FlashDeviceStats::fileSystemAccess, getUnknownPages(), gem5::MipsISA::index, locationTable, numPlanes, pageSize, pagesPerBlock, planeEvent, planeEventQueue, planeMask, gem5::FlashDevice::FlashDeviceStats::readAccess, gem5::FlashDevice::FlashDeviceStats::readLatency, remap(), gem5::EventManager::reschedule(), gem5::statistics::DistBase< Derived, Stor >::sample(), gem5::EventManager::schedule(), gem5::Event::scheduled(), stats, gem5::FlashDevice::CallBackEntry::time, gem5::Event::when(), gem5::FlashDevice::FlashDeviceStats::writeAccess, and gem5::FlashDevice::FlashDeviceStats::writeLatency.

Referenced by readMemory(), and writeMemory().

◆ accessTimes()

Tick gem5::FlashDevice::accessTimes ( uint64_t address,
Actions accesstype )
private

Access time calculator.

Calculates the accesstime per operation needed.

Just read the page

Write the page, and read the result

Erase and check wether it was successfull

Copy every valid page

Definition at line 395 of file flash_device.cc.

References ActionCopy, ActionErase, ActionRead, ActionWrite, blockValidEntries, DPRINTF, eraseLatency, readLatency, and writeLatency.

Referenced by accessDevice(), and remap().

◆ actionComplete()

void gem5::FlashDevice::actionComplete ( )
private

Event rescheduler.

When a plane completes its action, this event is triggered.

When a callback function was associated with that event, it will be called.

Search for a callback that is supposed to happen in this Tick

Invariant: All queued events are scheduled in the present or future.

To ensure that the follow-up action is executed correctly, the callback entry first need to be cleared before it can be called.

Found a callback, lets make it happen

Find when to schedule the planeEvent next

Schedule the next plane that will be ready (if any)

Definition at line 281 of file flash_device.cc.

References checkDrain(), gem5::curTick(), DPRINTF, numPlanes, planeEvent, planeEventQueue, gem5::EventManager::reschedule(), and gem5::Event::when().

Referenced by FlashDevice().

◆ checkDrain()

void gem5::FlashDevice::checkDrain ( )

Checkdrain; needed to enable checkpoints.

Definition at line 570 of file flash_device.cc.

References gem5::curTick(), DPRINTF, gem5::Draining, gem5::Drainable::drainState(), planeEvent, gem5::Drainable::signalDrainDone(), and gem5::Event::when().

Referenced by actionComplete().

◆ clearUnknownPages()

void gem5::FlashDevice::clearUnknownPages ( uint32_t index)
inlineprivate

Function to indicate that a page is known.

clearUnknownPages.

defines that a page is known and used unknownPages is a bitmap of all the pages. It tracks wether we can be sure that the information of this page is taken into acount in the model (is it considered in blockValidEntries and blockEmptyEntries?). If it has been used in the past, then it is known. But it needs to be tracked to make decisions about write accesses, and indirectly about copy actions. one unknownPage entry is a 32 bit integer. So if we have a page index, then that means that we need entry floor(index/32) (index >> 5) and we need to select the bit which number is equal to the remainder of index/32 (index%32). The bit is cleared to make sure that we see it as considered in the future.

Definition at line 445 of file flash_device.cc.

References gem5::MipsISA::index, and unknownPages.

Referenced by accessDevice().

◆ drain()

DrainState gem5::FlashDevice::drain ( )
overridevirtual

Checkpoint functions.

Drain; needed to enable checkpoints.

Implements gem5::Drainable.

Definition at line 554 of file flash_device.cc.

References DPRINTF, gem5::Drained, gem5::Draining, planeEvent, and gem5::Event::scheduled().

◆ getUnknownPages()

bool gem5::FlashDevice::getUnknownPages ( uint32_t index)
inlineprivate

Function to test if a page is known.

getUnknownPages.

Verify wether a page is known

Definition at line 456 of file flash_device.cc.

References gem5::MipsISA::index, and unknownPages.

Referenced by accessDevice().

◆ initializeFlash()

void gem5::FlashDevice::initializeFlash ( uint64_t disk_size,
uint32_t sector_size )
private

Initialization function; called when all disk specifics are known.

Initiates all the flash functions: initializes the lookup tables, age of the device, etc.

This can only be done once the disk image is known. Thats why it can't be done in the constructor.

Sanity information: check flash configuration

Garbage collection related

This is a bitmap. Every bit is a page unknownPages is a vector of 32 bit integers. If every page was an integer, the total size would be pagesPerDisk; since we can map one page per bit we need ceil(pagesPerDisk/32) entries. 32 = 1 << 5 hence it will do to just shift pagesPerDisk five positions and add one. This will allocate one integer to many for this data structure in the worst case.

Definition at line 103 of file flash_device.cc.

References blockEmptyEntries, blockSize, blocksPerDisk, blockValidEntries, gem5::X86ISA::count, dataDistribution, diskSize, DPRINTF, locationTable, pageSize, pagesPerBlock, pagesPerDisk, and unknownPages.

Referenced by initializeMemory().

◆ initializeMemory()

void gem5::FlashDevice::initializeMemory ( uint64_t disk_size,
uint32_t sector_size )
inlineoverrideprivatevirtual

Device access functions Inherrited from AbstractNVM.

Implements gem5::AbstractNVM.

Definition at line 118 of file flash_device.hh.

References initializeFlash().

◆ readMemory()

void gem5::FlashDevice::readMemory ( uint64_t address,
uint32_t amount,
const std::function< void()> & event )
inlineoverrideprivatevirtual

Access functions Access function to simulate a read/write access to the memory.

Once the action has completed, the Callback event should be called. Putting a NULL pointer as callback is valid syntax, and should result in the simulation of the access, but with no callback to the higher layer. This may be used to occupy the device, such that next actions will be delayed. The read/write function will schedule the incoming requests on a first come first serve basis.

Parameters
addressThe logical address to a location in the Non-volatile memory.
amountThe amount of data transfered from the NVM in bytes
eventA pointer to a callback function that will perform the actions taken by the disk controller on successfull completion of the data transfer between the disk and the disk controller.

Implements gem5::AbstractNVM.

Definition at line 124 of file flash_device.hh.

References accessDevice(), ActionRead, gem5::QARMA::amount, and gem5::MipsISA::event.

◆ remap()

Tick gem5::FlashDevice::remap ( uint64_t logic_page_addr)
private

FTL functionality.

Handles the remapping of the pages.

It is a (I hope) sensible statistic approach. asumption: garbage collection happens when a clean is needed (may become stochastic function).

Are there any empty left in this Block, or do we need to do an erase

Definition at line 342 of file flash_device.cc.

References accessTimes(), ActionCopy, ActionErase, ActionWrite, blockEmptyEntries, gem5::X86ISA::count, DPRINTF, GCActivePercentage, locationTable, pagesPerBlock, pagesPerDisk, stats, and gem5::FlashDevice::FlashDeviceStats::totalGCActivations.

Referenced by accessDevice().

◆ serialize()

void gem5::FlashDevice::serialize ( CheckpointOut & cp) const
overridevirtual

◆ unserialize()

void gem5::FlashDevice::unserialize ( CheckpointIn & cp)
overridevirtual

◆ writeMemory()

void gem5::FlashDevice::writeMemory ( uint64_t address,
uint32_t amount,
const std::function< void()> & event )
inlineoverrideprivatevirtual

Implements gem5::AbstractNVM.

Definition at line 131 of file flash_device.hh.

References accessDevice(), ActionWrite, gem5::QARMA::amount, and gem5::MipsISA::event.

Member Data Documentation

◆ blockEmptyEntries

std::vector<uint32_t> gem5::FlashDevice::blockEmptyEntries
private

number of empty entries

Definition at line 196 of file flash_device.hh.

Referenced by accessDevice(), initializeFlash(), remap(), serialize(), and unserialize().

◆ blockSize

const uint32_t gem5::FlashDevice::blockSize
private

Definition at line 161 of file flash_device.hh.

Referenced by initializeFlash().

◆ blocksPerDisk

uint32_t gem5::FlashDevice::blocksPerDisk
private

Definition at line 182 of file flash_device.hh.

Referenced by initializeFlash().

◆ blockValidEntries

std::vector<uint32_t> gem5::FlashDevice::blockValidEntries
private

number of valid entries per block

Definition at line 194 of file flash_device.hh.

Referenced by accessDevice(), accessTimes(), initializeFlash(), serialize(), and unserialize().

◆ dataDistribution

const enums::DataDistribution gem5::FlashDevice::dataDistribution
private

Flash organization.

Definition at line 173 of file flash_device.hh.

Referenced by initializeFlash().

◆ diskSize

uint64_t gem5::FlashDevice::diskSize
private

Disk sizes in bytes.

Definition at line 160 of file flash_device.hh.

Referenced by initializeFlash().

◆ eraseLatency

const Tick gem5::FlashDevice::eraseLatency
private

Definition at line 170 of file flash_device.hh.

Referenced by accessTimes().

◆ GCActivePercentage

const uint32_t gem5::FlashDevice::GCActivePercentage
private

Garbage collection algorithm emulator.

Definition at line 165 of file flash_device.hh.

Referenced by remap().

◆ locationTable

std::vector<struct PageMapEntry> gem5::FlashDevice::locationTable
private

address to logic place has a block and a page field

Definition at line 192 of file flash_device.hh.

Referenced by accessDevice(), initializeFlash(), remap(), serialize(), and unserialize().

◆ numPlanes

const uint32_t gem5::FlashDevice::numPlanes
private

Definition at line 174 of file flash_device.hh.

Referenced by accessDevice(), and actionComplete().

◆ pageSize

const uint32_t gem5::FlashDevice::pageSize
private

Definition at line 162 of file flash_device.hh.

Referenced by accessDevice(), and initializeFlash().

◆ pagesPerBlock

uint32_t gem5::FlashDevice::pagesPerBlock
private

Disk dimensions in pages and blocks.

Definition at line 180 of file flash_device.hh.

Referenced by accessDevice(), initializeFlash(), and remap().

◆ pagesPerDisk

uint32_t gem5::FlashDevice::pagesPerDisk
private

Definition at line 181 of file flash_device.hh.

Referenced by initializeFlash(), and remap().

◆ planeEvent

EventFunctionWrapper gem5::FlashDevice::planeEvent
private

Completion event.

Definition at line 202 of file flash_device.hh.

Referenced by accessDevice(), actionComplete(), checkDrain(), and drain().

◆ planeEventQueue

std::vector<std::deque<struct CallBackEntry> > gem5::FlashDevice::planeEventQueue
private

This vector of queues keeps track of all the callbacks per plane.

Definition at line 199 of file flash_device.hh.

Referenced by accessDevice(), and actionComplete().

◆ planeMask

uint32_t gem5::FlashDevice::planeMask
private

Definition at line 184 of file flash_device.hh.

Referenced by accessDevice(), serialize(), and unserialize().

◆ readLatency

const Tick gem5::FlashDevice::readLatency
private

Access latencies.

Definition at line 168 of file flash_device.hh.

Referenced by accessTimes().

◆ stats

struct FlashDeviceStats gem5::FlashDevice::stats
private

RequestHandler stats.

Definition at line 177 of file flash_device.hh.

Referenced by accessDevice(), and remap().

◆ unknownPages

std::vector<uint32_t> gem5::FlashDevice::unknownPages
private

when the disk is first started we are unsure of the number of used pages, this variable will help determining what we do know.

Definition at line 190 of file flash_device.hh.

Referenced by clearUnknownPages(), getUnknownPages(), initializeFlash(), serialize(), and unserialize().

◆ writeLatency

const Tick gem5::FlashDevice::writeLatency
private

Definition at line 169 of file flash_device.hh.

Referenced by accessTimes().


The documentation for this class was generated from the following files:

Generated on Tue Jun 18 2024 16:24:11 for gem5 by doxygen 1.11.0