6 #ifndef MSRIOIMP_HPP_INCLUDE
7 #define MSRIOIMP_HPP_INCLUDE
23 MSRIOImp(std::shared_ptr<MSRPath> path);
24 MSRIOImp(
int num_cpu, std::shared_ptr<MSRPath> path,
25 std::shared_ptr<IOUring> batch_reader,
26 std::shared_ptr<IOUring> batch_writer);
31 uint64_t offset)
override;
35 uint64_t write_mask)
override;
37 int add_read(
int cpu_idx, uint64_t offset)
override;
38 int add_read(
int cpu_idx, uint64_t offset,
int batch_ctx)
override;
41 uint64_t
sample(
int batch_idx)
const override;
42 uint64_t
sample(
int batch_idx,
int batch_ctx)
const override;
45 int add_write(
int cpu_idx, uint64_t offset)
override;
46 int add_write(
int cpu_idx, uint64_t offset,
int batch_ctx)
override;
47 void adjust(
int batch_idx, uint64_t value, uint64_t write_mask)
override;
48 void adjust(
int batch_idx, uint64_t value, uint64_t write_mask,
int batch_ctx)
override;
51 struct m_msr_batch_op_s {
60 struct m_msr_batch_array_s {
62 struct m_msr_batch_op_s *ops;
65 struct m_batch_context_s {
66 m_batch_context_s(
int num_cpu)
67 : m_is_batch_read(false)
68 , m_read_batch({0,
nullptr})
69 , m_write_batch({0,
nullptr})
72 , m_read_batch_idx_map(num_cpu)
73 , m_write_batch_idx_map(num_cpu)
77 struct m_msr_batch_array_s m_read_batch;
78 struct m_msr_batch_array_s m_write_batch;
79 std::vector<struct m_msr_batch_op_s> m_read_batch_op;
80 std::vector<struct m_msr_batch_op_s> m_write_batch_op;
81 std::vector<std::map<uint64_t, int> > m_read_batch_idx_map;
82 std::vector<std::map<uint64_t, int> > m_write_batch_idx_map;
83 std::vector<uint64_t> m_write_val;
84 std::vector<uint64_t> m_write_mask;
88 void open_msr(
int cpu_idx);
89 void open_msr_batch(
void);
91 void close_msr(
int cpu_idx);
92 void close_msr_batch(
void);
93 int msr_desc(
int cpu_idx);
94 int msr_batch_desc(
void);
95 void msr_ioctl(
struct m_msr_batch_array_s &batch);
96 void msr_ioctl_read(
struct m_batch_context_s &ctx);
97 void msr_ioctl_write(
struct m_batch_context_s &ctx);
98 void msr_batch_io(IOUring &batcher,
struct m_msr_batch_array_s &batch);
99 void msr_read_files(
int batch_ctx);
100 void msr_rmw_files(
int batch_ctx);
103 std::vector<int> m_file_desc;
104 std::vector<struct m_batch_context_s> m_batch_context;
105 bool m_is_batch_enabled;
106 std::map<uint64_t, uint64_t> m_offset_mask_map;
108 std::shared_ptr<MSRPath> m_path;
109 std::shared_ptr<IOUring> m_batch_reader;
110 std::shared_ptr<IOUring> m_batch_writer;
Definition: MSRIOImp.hpp:20
MSRIOImp & operator=(const MSRIOImp &other)=delete
void write_batch() override
Write all adjusted values. Note: uses the default batch context.
Definition: MSRIO.cpp:448
uint64_t sample(int batch_idx) const override
Read the full 64-bit value of the MSR that was previously added to the MSRIO with add_read()....
Definition: MSRIO.cpp:248
void adjust(int batch_idx, uint64_t value, uint64_t write_mask) override
Adjust a value that was previously added with the add_write() method. Note: uses the default batch co...
Definition: MSRIO.cpp:194
MSRIOImp(const MSRIOImp &other)=delete
int add_write(int cpu_idx, uint64_t offset) override
Add another offset to the list of MSRs to be written in batch. Note: uses the default batch context.
Definition: MSRIO.cpp:162
void read_batch() override
Batch read a set of MSRs configured by a previous call to the batch_config() method....
Definition: MSRIO.cpp:426
void write_msr(int cpu_idx, uint64_t offset, uint64_t raw_value, uint64_t write_mask) override
Write to a single MSR on a CPU.
Definition: MSRIO.cpp:97
int create_batch_context(void) override
Add a new batch context to the set of managed contexts.
Definition: MSRIO.cpp:155
uint64_t read_msr(int cpu_idx, uint64_t offset) override
Read from a single MSR on a CPU.
Definition: MSRIO.cpp:83
int add_read(int cpu_idx, uint64_t offset) override
Extend the set of MSRs for batch read with a single offset. Note: uses the default batch context.
Definition: MSRIO.cpp:226
uint64_t system_write_mask(uint64_t offset) override
Return the system write mask for a given offset.
Definition: MSRIO.cpp:121
virtual ~MSRIOImp()
Definition: MSRIO.cpp:56