ARM/ARM64: tizen_bcm2711: enable CONFIG_RTL8192CU_VENDOR
[platform/kernel/linux-rpi.git] / block / blk-iocost.c
index b3880e4..069193d 100644 (file)
@@ -2311,11 +2311,28 @@ static void ioc_timer_fn(struct timer_list *timer)
                        hwm = current_hweight_max(iocg);
                        new_hwi = hweight_after_donation(iocg, old_hwi, hwm,
                                                         usage, &now);
-                       if (new_hwi < hwm) {
+                       /*
+                        * Donation calculation assumes hweight_after_donation
+                        * to be positive, a condition that a donor w/ hwa < 2
+                        * can't meet. Don't bother with donation if hwa is
+                        * below 2. It's not gonna make a meaningful difference
+                        * anyway.
+                        */
+                       if (new_hwi < hwm && hwa >= 2) {
                                iocg->hweight_donating = hwa;
                                iocg->hweight_after_donation = new_hwi;
                                list_add(&iocg->surplus_list, &surpluses);
-                       } else {
+                       } else if (!iocg->abs_vdebt) {
+                               /*
+                                * @iocg doesn't have enough to donate. Reset
+                                * its inuse to active.
+                                *
+                                * Don't reset debtors as their inuse's are
+                                * owned by debt handling. This shouldn't affect
+                                * donation calculuation in any meaningful way
+                                * as @iocg doesn't have a meaningful amount of
+                                * share anyway.
+                                */
                                TRACE_IOCG_PATH(inuse_shortage, iocg, &now,
                                                iocg->inuse, iocg->active,
                                                iocg->hweight_inuse, new_hwi);
@@ -2876,15 +2893,21 @@ static int blk_iocost_init(struct request_queue *q)
         * called before policy activation completion, can't assume that the
         * target bio has an iocg associated and need to test for NULL iocg.
         */
-       rq_qos_add(q, rqos);
+       ret = rq_qos_add(q, rqos);
+       if (ret)
+               goto err_free_ioc;
+
        ret = blkcg_activate_policy(q, &blkcg_policy_iocost);
-       if (ret) {
-               rq_qos_del(q, rqos);
-               free_percpu(ioc->pcpu_stat);
-               kfree(ioc);
-               return ret;
-       }
+       if (ret)
+               goto err_del_qos;
        return 0;
+
+err_del_qos:
+       rq_qos_del(q, rqos);
+err_free_ioc:
+       free_percpu(ioc->pcpu_stat);
+       kfree(ioc);
+       return ret;
 }
 
 static struct blkcg_policy_data *ioc_cpd_alloc(gfp_t gfp)