Fio uses the struct io_sample to log attributes of each IO. When the
log_offset option is set, fio uses the struct io_sample_offset instead
which has the additional field dedicated to the offset data. Fio chooses
one of these two structs by the log_offset option to minimize memory
usage for IO sampling. However, the dedicated struct io_sample_offset is
not flexible and makes it difficult to add new sampling items.
To allow adding new sampling items, drop the struct io_sample_offset.
Instead, introduce the variable length array "uint64_t aux[]" at the
end of the struct io_sample which holds any auxiliary sampling data.
At this moment, it holds only one item "offset" as the first array
element. The following patch will add a new item.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20240829085826.999859-5-shinichiro.kawasaki@wdc.com
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
s->bs = le64_to_cpu(s->bs);
s->priority = le16_to_cpu(s->priority);
- if (ret->log_offset) {
- struct io_sample_offset *so = (void *) s;
-
- so->offset = le64_to_cpu(so->offset);
- }
+ if (ret->log_offset)
+ s->aux[IOS_AUX_OFFSET_INDEX] =
+ le64_to_cpu(s->aux[IOS_AUX_OFFSET_INDEX]);
if (ret->log_type == IO_LOG_TYPE_HIST) {
s->data.plat_entry = (struct io_u_plat_entry *)(((char *)s) + sizeof(*s));
void flush_samples(FILE *f, void *samples, uint64_t sample_size)
{
struct io_sample *s;
- struct io_sample_offset *sa;
bool log_offset, log_prio, log_avg_max;
uint64_t i, nr_samples;
char buf[256];
for (i = 0; i < nr_samples; i++) {
s = __get_sample(samples, log_offset, i);
- sa = (void *) s;
p = buf;
left = sizeof(buf);
if (log_offset) {
ret = print_sample_fields(&p, &left, ", %llu",
- (unsigned long long) sa->offset);
+ (unsigned long long) s->aux[IOS_AUX_OFFSET_INDEX]);
if (ret)
return;
}
uint32_t __ddir;
uint16_t priority;
uint64_t bs;
+ uint64_t aux[];
};
-struct io_sample_offset {
- struct io_sample s;
- uint64_t offset;
+/*
+ * Enumerate indexes of auxiliary log data in struct io_sample aux[] array
+ */
+enum {
+ IOS_AUX_OFFSET_INDEX,
};
enum {
io->__ddir = ddir | log->log_ddir_mask;
}
-static inline size_t __log_entry_sz(int log_offset)
+static inline size_t __log_entry_sz(bool log_offset)
{
+ size_t ret = sizeof(struct io_sample);
+
if (log_offset)
- return sizeof(struct io_sample_offset);
- else
- return sizeof(struct io_sample);
+ ret += sizeof(uint64_t);
+
+ return ret;
}
static inline size_t log_entry_sz(struct io_log *log)
s->__ddir = __cpu_to_le32(s->__ddir);
s->bs = cpu_to_le64(s->bs);
- if (log->log_offset) {
- struct io_sample_offset *so = (void *) s;
-
- so->offset = cpu_to_le64(so->offset);
- }
+ if (log->log_offset)
+ s->aux[IOS_AUX_OFFSET_INDEX] =
+ cpu_to_le64(s->aux[IOS_AUX_OFFSET_INDEX]);
}
}
s->bs = sample->bs;
s->priority = sample->priority;
- if (iolog->log_offset) {
- struct io_sample_offset *so = (void *) s;
-
- so->offset = sample->offset;
- }
+ if (iolog->log_offset)
+ s->aux[IOS_AUX_OFFSET_INDEX] = sample->offset;
cur_log->nr_samples++;
return;