Merge tag 'amd-drm-fixes-5.13-2021-06-02' of https://gitlab.freedesktop.org/agd5f...
[linux-2.6-microblaze.git] / block / blk-iocost.c
index e0c4baa..c2d6bc8 100644 (file)
@@ -1069,7 +1069,17 @@ static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
 
        lockdep_assert_held(&ioc->lock);
 
-       inuse = clamp_t(u32, inuse, 1, active);
+       /*
+        * For an active leaf node, its inuse shouldn't be zero or exceed
+        * @active. An active internal node's inuse is solely determined by the
+        * inuse to active ratio of its children regardless of @inuse.
+        */
+       if (list_empty(&iocg->active_list) && iocg->child_active_sum) {
+               inuse = DIV64_U64_ROUND_UP(active * iocg->child_inuse_sum,
+                                          iocg->child_active_sum);
+       } else {
+               inuse = clamp_t(u32, inuse, 1, active);
+       }
 
        iocg->last_inuse = iocg->inuse;
        if (save)
@@ -1086,7 +1096,7 @@ static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
                /* update the level sums */
                parent->child_active_sum += (s32)(active - child->active);
                parent->child_inuse_sum += (s32)(inuse - child->inuse);
-               /* apply the udpates */
+               /* apply the updates */
                child->active = active;
                child->inuse = inuse;