58 #include "debug/Drain.hh"
65 FlashDeviceParams::create()
78 blockSize(p->blk_size),
79 pageSize(p->page_size),
80 GCActivePercentage(p->GC_active),
81 readLatency(p->read_lat),
82 writeLatency(p->write_lat),
83 eraseLatency(p->erase_lat),
84 dataDistribution(p->data_distribution),
85 numPlanes(p->num_planes),
89 planeMask(numPlanes - 1),
90 planeEventQueue(numPlanes),
103 fatal(
"Number of planes is not a power of 2 in flash device.\n");
172 uint64_t logic_page_addr = address /
pageSize;
173 uint32_t plane_address = 0;
187 " logic address 0x%8x\n", index,
214 time[plane_address] +=
remap(logic_page_addr);
243 plane_address = (time[plane_address] > time[
count]) ? plane_address
249 if (time[count] != 0) {
294 uint8_t plane_address = 0;
296 uint8_t next_event = 0;
299 for (plane_address = 0; plane_address <
numPlanes; plane_address++) {
327 for (plane_address = 0; plane_address <
numPlanes; plane_address++) {
332 next_event = plane_address;
469 return unknownPages[index >> 5] & (0x01 << (index % 32));
477 using namespace Stats;
479 std::string fd_name =
name() +
".FlashDevice";
484 .
name(fd_name +
".totalGCActivations")
485 .
desc(
"Number of Garbage collector activations")
491 .
name(fd_name +
".writeAccessHist")
492 .
desc(
"Histogram of write addresses")
496 .
name(fd_name +
".readAccessHist")
497 .
desc(
"Histogram of read addresses")
501 .
name(fd_name +
".fileSystemAccessHist")
502 .
desc(
"Histogram of file system accesses")
508 .
name(fd_name +
".writeLatencyHist")
509 .
desc(
"Histogram of write latency")
513 .
name(fd_name +
".readLatencyHist")
514 .
desc(
"Histogram of read latency")
554 int location_table_size;
573 DPRINTF(Drain,
"Flash device is draining...\n");
576 DPRINTF(Drain,
"Flash device in drained state\n");
592 DPRINTF(Drain,
"Flash device is still draining\n");
594 DPRINTF(Drain,
"Flash device is done draining\n");
uint32_t pagesPerBlock
Disk dimensions in pages and blocks.
void serialize(CheckpointOut &cp) const override
Serialize; needed to create checkpoints.
const FlagsType pdf
Print the percent of the total that this entry represents.
void actionComplete()
Event rescheduler.
virtual void process()=0
virtual process function that is invoked when the callback queue is executed.
void regStats() override
Stats register function.
std::vector< uint32_t > blockEmptyEntries
number of empty entries
Stats::Scalar totalGCActivations
Amount of GC activations.
DrainState
Object drain/handover states.
Stats::Histogram writeAccess
Histogram of address accesses.
std::vector< struct PageMapEntry > locationTable
address to logic place has a block and a page field
std::vector< uint32_t > unknownPages
when the disk is first started we are unsure of the number of used pages, this variable will help det...
Stats::Histogram fileSystemAccess
Stats::Histogram writeLatency
Histogram of access latencies.
bool scheduled() const
Determine if the current event is scheduled.
void unserialize(CheckpointIn &cp) override
Unserialize; needed to restore from checkpoints.
Tick accessTimes(uint64_t address, Actions accesstype)
Access time calculator.
Histogram & init(size_type size)
Set the parameters of this histogram.
const Enums::DataDistribution dataDistribution
Flash organization.
virtual void regStats()
Register statistics for this object.
void clearUnknownPages(uint32_t index)
Function to indicate that a page is known.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Stats::Histogram readAccess
DrainState drain() override
Checkpoint functions.
EventWrapper< FlashDevice,&FlashDevice::actionComplete > planeEvent
Completion event.
void checkDrain()
Checkdrain; needed to enable checkpoints.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_CONTAINER(member)
void accessDevice(uint64_t address, uint32_t amount, Callback *event, Actions action)
Flash action function.
Tick curTick()
The current simulated tick.
FlashDevice(const FlashDeviceParams *)
Initialize functions.
std::string csprintf(const char *format, const Args &...args)
struct FlashDeviceStats stats
RequestHandler stats.
Tick when() const
Get the time that the event is scheduled.
uint64_t Tick
Tick count type.
A copy involves taking all the used pages from a block and store it in another.
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
const Tick readLatency
Access latencies.
#define UNSERIALIZE_CONTAINER(member)
Stats::Histogram readLatency
const FlagsType none
Nothing extra to print.
std::vector< uint32_t > blockValidEntries
number of valid entries per block
Draining buffers pending serialization/handover.
Flash Device model The Flash Device model is a timing model for a NAND flash device.
#define SERIALIZE_SCALAR(scalar)
std::vector< std::deque< struct CallBackEntry > > planeEventQueue
This vector of queues keeps track of all the callbacks per plane.
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
void reschedule(Event &event, Tick when, bool always=false)
virtual const std::string name() const
std::ostream CheckpointOut
Actions
Defines the possible actions to the flash.
void signalDrainDone() const
Signal that an object is drained.
Tick remap(uint64_t logic_page_addr)
FTL functionality.
void schedule(Event &event, Tick when)
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
DrainState drainState() const
Return the current drain state of an object.
This is an interface between the disk interface (which will handle the disk data transactions) and th...
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
bool getUnknownPages(uint32_t index)
Function to test if a page is known.
uint64_t diskSize
Disk sizes in bytes.
const uint32_t GCActivePercentage
Garbage collection algorithm emulator.
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
void initializeFlash(uint64_t disk_size, uint32_t sector_size)
Initialization function; called when all disk specifics are known.