56#include "debug/Drain.hh"
68 blockSize(
p.blk_size),
69 pageSize(
p.page_size),
70 GCActivePercentage(
p.GC_active),
71 readLatency(
p.read_lat),
72 writeLatency(
p.write_lat),
73 eraseLatency(
p.erase_lat),
74 dataDistribution(
p.data_distribution),
75 numPlanes(
p.num_planes),
80 planeMask(numPlanes - 1),
81 planeEventQueue(numPlanes),
93 if (numPlanes & planeMask)
94 fatal(
"Number of planes is not a power of 2 in flash device.\n");
163 uint64_t logic_page_addr = address /
pageSize;
164 uint32_t plane_address = 0;
178 " logic address 0x%8x\n",
index,
205 time[plane_address] +=
remap(logic_page_addr);
234 plane_address = (time[plane_address] > time[
count]) ? plane_address
240 if (time[
count] != 0) {
284 uint8_t plane_address = 0;
286 uint8_t next_event = 0;
289 for (plane_address = 0; plane_address <
numPlanes; plane_address++) {
316 for (plane_address = 0; plane_address <
numPlanes; plane_address++) {
321 next_event = plane_address;
462 : statistics::
Group(parent,
"FlashDevice"),
463 ADD_STAT(totalGCActivations, statistics::units::Count::get(),
464 "Number of Garbage collector activations"),
465 ADD_STAT(writeAccess, statistics::units::Count::get(),
466 "Histogram of write addresses"),
467 ADD_STAT(readAccess, statistics::units::Count::get(),
468 "Histogram of read addresses"),
469 ADD_STAT(fileSystemAccess, statistics::units::Count::get(),
470 "Histogram of file system accesses"),
472 "Histogram of write latency"),
474 "Histogram of read latency")
476 using namespace statistics;
538 int location_table_size;
557 DPRINTF(Drain,
"Flash device is draining...\n");
560 DPRINTF(Drain,
"Flash device in drained state\n");
576 DPRINTF(Drain,
"Flash device is still draining\n");
578 DPRINTF(Drain,
"Flash device is done draining\n");
This is an interface between the disk interface (which will handle the disk data transactions) and th...
Flash Device model The Flash Device model is a timing model for a NAND flash device.
void checkDrain()
Checkdrain; needed to enable checkpoints.
EventFunctionWrapper planeEvent
Completion event.
const enums::DataDistribution dataDistribution
Flash organization.
void initializeFlash(uint64_t disk_size, uint32_t sector_size)
Initialization function; called when all disk specifics are known.
void actionComplete()
Event rescheduler.
void serialize(CheckpointOut &cp) const override
Serialize; needed to create checkpoints.
Tick accessTimes(uint64_t address, Actions accesstype)
Access time calculator.
std::vector< struct PageMapEntry > locationTable
address to logic place has a block and a page field
void accessDevice(uint64_t address, uint32_t amount, const std::function< void()> &event, Actions action)
Flash action function.
FlashDevice(const FlashDeviceParams &)
Initialize functions.
uint32_t pagesPerBlock
Disk dimensions in pages and blocks.
uint64_t diskSize
Disk sizes in bytes.
Tick remap(uint64_t logic_page_addr)
FTL functionality.
std::vector< uint32_t > blockEmptyEntries
number of empty entries
void unserialize(CheckpointIn &cp) override
Unserialize; needed to restore from checkpoints.
std::vector< std::deque< struct CallBackEntry > > planeEventQueue
This vector of queues keeps track of all the callbacks per plane.
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...
DrainState drain() override
Checkpoint functions.
void clearUnknownPages(uint32_t index)
Function to indicate that a page is known.
Actions
Defines the possible actions to the flash.
@ ActionCopy
A copy involves taking all the used pages from a block and store it in another.
const uint32_t GCActivePercentage
Garbage collection algorithm emulator.
std::vector< uint32_t > blockValidEntries
number of valid entries per block
struct FlashDeviceStats stats
RequestHandler stats.
bool getUnknownPages(uint32_t index)
Function to test if a page is known.
const Tick readLatency
Access latencies.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Histogram & init(size_type size)
Set the parameters of this histogram.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
void signalDrainDone() const
Signal that an object is drained.
DrainState drainState() const
Return the current drain state of an object.
DrainState
Object drain/handover states.
@ Draining
Draining buffers pending serialization/handover.
@ Drained
Buffers drained, ready for serialization/handover.
bool scheduled() const
Determine if the current event is scheduled.
void schedule(Event &event, Tick when)
void reschedule(Event &event, Tick when, bool always=false)
Tick when() const
Get the time that the event is scheduled.
#define fatal(...)
This implements a cprintf based fatal() function.
#define UNSERIALIZE_CONTAINER(member)
#define SERIALIZE_CONTAINER(member)
const FlagsType pdf
Print the percent of the total that this entry represents.
const FlagsType none
Nothing extra to print.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
uint64_t Tick
Tick count type.
std::string csprintf(const char *format, const Args &...args)
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)
statistics::Scalar totalGCActivations
Amount of GC activations.
FlashDeviceStats(statistics::Group *parent)
statistics::Histogram fileSystemAccess
statistics::Histogram readAccess
statistics::Histogram readLatency
statistics::Histogram writeAccess
Histogram of address accesses.
statistics::Histogram writeLatency
Histogram of access latencies.
const std::string & name()