diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 1acd96c9d5c0..642b16e59dd0 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -916,7 +916,14 @@ static void __propagate_active_weight(struct ioc_gq *iocg, u32 active, u32 inuse inuse = DIV64_U64_ROUND_UP(active * iocg->child_inuse_sum, iocg->child_active_sum); } else { - inuse = clamp_t(u32, inuse, 1, active); + /* + * It may be tempting to turn this into a clamp expression with + * a lower limit of 1 but active may be 0, which cannot be used + * as an upper limit in that situation. This expression allows + * active to clamp inuse unless it is 0, in which case inuse + * becomes 1. + */ + inuse = min(inuse, active) ?: 1; } if (active == iocg->active && inuse == iocg->inuse)