From: Niklas Cassel <niklas.cassel@xxxxxxx> All cmdprio options only support data directions read and write. However, each cmdprio option allocates memory for ddir trim as well, even though nothing is ever written to this memory. Change this so that we don't allocate memory for something which is never used. Signed-off-by: Niklas Cassel <niklas.cassel@xxxxxxx> --- engines/cmdprio.c | 4 ++-- engines/cmdprio.h | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/engines/cmdprio.c b/engines/cmdprio.c index f5b7342f..2c764e49 100644 --- a/engines/cmdprio.c +++ b/engines/cmdprio.c @@ -56,7 +56,7 @@ int fio_cmdprio_bssplit_parse(struct thread_data *td, const char *input, ret = str_split_parse(td, str, fio_cmdprio_bssplit_ddir, cmdprio, false); if (parse_dryrun()) { - for (i = 0; i < DDIR_RWDIR_CNT; i++) { + for (i = 0; i < CMDPRIO_RWDIR_CNT; i++) { free(cmdprio->bssplit[i]); cmdprio->bssplit[i] = NULL; cmdprio->bssplit_nr[i] = 0; @@ -101,7 +101,7 @@ int fio_cmdprio_init(struct thread_data *td, struct cmdprio *cmdprio, * If cmdprio_percentage/cmdprio_bssplit is set and cmdprio_class * is not set, default to RT priority class. */ - for (i = 0; i < DDIR_RWDIR_CNT; i++) { + for (i = 0; i < CMDPRIO_RWDIR_CNT; i++) { if (cmdprio->percentage[i]) { if (!cmdprio->class[i]) cmdprio->class[i] = IOPRIO_CLASS_RT; diff --git a/engines/cmdprio.h b/engines/cmdprio.h index 33a8f5b9..d3265741 100644 --- a/engines/cmdprio.h +++ b/engines/cmdprio.h @@ -8,12 +8,15 @@ #include "../fio.h" +/* read and writes only, no trim */ +#define CMDPRIO_RWDIR_CNT 2 + struct cmdprio { - unsigned int percentage[DDIR_RWDIR_CNT]; - unsigned int class[DDIR_RWDIR_CNT]; - unsigned int level[DDIR_RWDIR_CNT]; - unsigned int bssplit_nr[DDIR_RWDIR_CNT]; - struct bssplit *bssplit[DDIR_RWDIR_CNT]; + unsigned int percentage[CMDPRIO_RWDIR_CNT]; + unsigned int class[CMDPRIO_RWDIR_CNT]; + unsigned int level[CMDPRIO_RWDIR_CNT]; + unsigned int bssplit_nr[CMDPRIO_RWDIR_CNT]; + struct bssplit *bssplit[CMDPRIO_RWDIR_CNT]; }; int fio_cmdprio_bssplit_parse(struct thread_data *td, const char *input, -- 2.33.1