From 2f23140d5c1396fd0b247bd7f9c249f6e24096b7 Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Mon, 31 Jan 2022 09:04:08 -0500 Subject: [PATCH] LU-15393 lod: skip qos for qos_threshold_rr=100 Current implementation of qos allocation is called for every statfs update. It takes lq_rw_sem for write and recalculate penalties, even whith setting qos_threshold_rr=100. Which means always use rr allocation. Let's skip unnecessary locking and calculation for 100% round robin allocation. HPE-bug-id: LUS-10388 Signed-off-by: Alexander Boyko Change-Id: I2fcc272d00a988ca4ba0f745b1d5809d65b28654 Reviewed-on: https://review.whamcloud.com/46388 Reviewed-by: Andrew Perepechko Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alexey Lyashkov Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/lu_object.h | 2 ++ lustre/lmv/lproc_lmv.c | 5 +++-- lustre/lod/lod_qos.c | 8 ++++++++ lustre/lod/lproc_lod.c | 5 +++-- lustre/obdclass/lu_tgt_descs.c | 12 ++++++++---- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 03be5c4..14c9547 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -1634,7 +1634,9 @@ struct lu_tgt_desc_idx { struct lu_tgt_desc *ldi_tgt[TGT_PTRS_PER_BLOCK]; }; + /* QoS data for LOD/LMV */ +#define QOS_THRESHOLD_MAX 256 /* should be power of two */ struct lu_qos { struct list_head lq_svr_list; /* lu_svr_qos list */ struct rw_semaphore lq_rw_sem; diff --git a/lustre/lmv/lproc_lmv.c b/lustre/lmv/lproc_lmv.c index b095aa2..1f118f1 100644 --- a/lustre/lmv/lproc_lmv.c +++ b/lustre/lmv/lproc_lmv.c @@ -157,7 +157,8 @@ static ssize_t qos_threshold_rr_show(struct kobject *kobj, obd_kset.kobj); return scnprintf(buf, PAGE_SIZE, "%u%%\n", - (obd->u.lmv.lmv_qos.lq_threshold_rr * 100 + 255) >> 8); + (obd->u.lmv.lmv_qos.lq_threshold_rr * 100 + + (QOS_THRESHOLD_MAX - 1)) / QOS_THRESHOLD_MAX); } static ssize_t qos_threshold_rr_store(struct kobject *kobj, @@ -189,7 +190,7 @@ static ssize_t qos_threshold_rr_store(struct kobject *kobj, if (val > 100) return -EINVAL; - lmv->lmv_qos.lq_threshold_rr = (val << 8) / 100; + lmv->lmv_qos.lq_threshold_rr = (val * QOS_THRESHOLD_MAX) / 100; set_bit(LQ_DIRTY, &lmv->lmv_qos.lq_flags); return count; diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index d07f631..7f9b156 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -1537,6 +1537,10 @@ static int lod_ost_alloc_qos(const struct lu_env *env, struct lod_object *lo, int rc = 0; ENTRY; + /* Totally skip qos part when qos_threshold_rr=100% */ + if (lod->lod_ost_descs.ltd_qos.lq_threshold_rr == QOS_THRESHOLD_MAX) + return -EAGAIN; + LASSERT(lo->ldo_comp_cnt > comp_idx && lo->ldo_comp_entries != NULL); lod_comp = &lo->ldo_comp_entries[comp_idx]; stripe_count = lod_comp->llc_stripe_count; @@ -1824,6 +1828,10 @@ int lod_mdt_alloc_qos(const struct lu_env *env, struct lod_object *lo, ENTRY; + /* Totally skip qos part when qos_threshold_rr=100% */ + if (ltd->ltd_qos.lq_threshold_rr == QOS_THRESHOLD_MAX) + return -EAGAIN; + LASSERT(stripe_idx <= stripe_count); if (stripe_idx == stripe_count) RETURN(stripe_count); diff --git a/lustre/lod/lproc_lod.c b/lustre/lod/lproc_lod.c index 7949106..018c551 100644 --- a/lustre/lod/lproc_lod.c +++ b/lustre/lod/lproc_lod.c @@ -678,7 +678,8 @@ static ssize_t __qos_threshold_rr_show(struct kobject *kobj, &lod->lod_ost_descs; return scnprintf(buf, PAGE_SIZE, "%d%%\n", - (ltd->ltd_qos.lq_threshold_rr * 100 + 255) >> 8); + (ltd->ltd_qos.lq_threshold_rr * 100 + + (QOS_THRESHOLD_MAX - 1)) / QOS_THRESHOLD_MAX); } static ssize_t mdt_qos_threshold_rr_show(struct kobject *kobj, @@ -732,7 +733,7 @@ static ssize_t __qos_threshold_rr_store(struct kobject *kobj, if (val > 100) return -EINVAL; - ltd->ltd_qos.lq_threshold_rr = (val << 8) / 100; + ltd->ltd_qos.lq_threshold_rr = (val * QOS_THRESHOLD_MAX) / 100; set_bit(LQ_DIRTY, <d->ltd_qos.lq_flags); return count; diff --git a/lustre/obdclass/lu_tgt_descs.c b/lustre/obdclass/lu_tgt_descs.c index d872db4..1effd99 100644 --- a/lustre/obdclass/lu_tgt_descs.c +++ b/lustre/obdclass/lu_tgt_descs.c @@ -283,11 +283,13 @@ int lu_tgt_descs_init(struct lu_tgt_descs *ltd, bool is_mdt) ltd->ltd_lmv_desc.ld_pattern = LMV_HASH_TYPE_DEFAULT; ltd->ltd_qos.lq_prio_free = LMV_QOS_DEF_PRIO_FREE * 256 / 100; ltd->ltd_qos.lq_threshold_rr = - LMV_QOS_DEF_THRESHOLD_RR_PCT * 256 / 100; + LMV_QOS_DEF_THRESHOLD_RR_PCT * + QOS_THRESHOLD_MAX / 100; } else { ltd->ltd_qos.lq_prio_free = LOV_QOS_DEF_PRIO_FREE * 256 / 100; ltd->ltd_qos.lq_threshold_rr = - LOV_QOS_DEF_THRESHOLD_RR_PCT * 256 / 100; + LOV_QOS_DEF_THRESHOLD_RR_PCT * + QOS_THRESHOLD_MAX / 100; } return 0; @@ -577,8 +579,10 @@ int ltd_qos_penalties_calc(struct lu_tgt_descs *ltd) * creation performance */ clear_bit(LQ_SAME_SPACE, &qos->lq_flags); - if ((ba_max * (256 - qos->lq_threshold_rr)) >> 8 < ba_min && - (ia_max * (256 - qos->lq_threshold_rr)) >> 8 < ia_min) { + if (((ba_max * (QOS_THRESHOLD_MAX - qos->lq_threshold_rr)) / + QOS_THRESHOLD_MAX) < ba_min && + ((ia_max * (QOS_THRESHOLD_MAX - qos->lq_threshold_rr)) / + QOS_THRESHOLD_MAX) < ia_min) { set_bit(LQ_SAME_SPACE, &qos->lq_flags); /* Reset weights for the next time we enter qos mode */ set_bit(LQ_RESET, &qos->lq_flags); -- 1.8.3.1