hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/block/blk-iocost.c
....@@ -232,7 +232,9 @@
232232
233233 /* 1/64k is granular enough and can easily be handled w/ u32 */
234234 WEIGHT_ONE = 1 << 16,
235
+};
235236
237
+enum {
236238 /*
237239 * As vtime is used to calculate the cost of each IO, it needs to
238240 * be fairly high precision. For example, it should be able to
....@@ -256,6 +258,11 @@
256258 VRATE_MIN = VTIME_PER_USEC * VRATE_MIN_PPM / MILLION,
257259 VRATE_CLAMP_ADJ_PCT = 4,
258260
261
+ /* switch iff the conditions are met for longer than this */
262
+ AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC,
263
+};
264
+
265
+enum {
259266 /* if IOs end up waiting for requests, issue less */
260267 RQ_WAIT_BUSY_PCT = 5,
261268
....@@ -293,9 +300,6 @@
293300
294301 /* don't let cmds which take a very long time pin lagging for too long */
295302 MAX_LAGGING_PERIODS = 10,
296
-
297
- /* switch iff the conditions are met for longer than this */
298
- AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC,
299303
300304 /*
301305 * Count IO size in 4k pages. The 12bit shift helps keeping
....@@ -872,9 +876,14 @@
872876
873877 *page = *seqio = *randio = 0;
874878
875
- if (bps)
876
- *page = DIV64_U64_ROUND_UP(VTIME_PER_SEC,
877
- DIV_ROUND_UP_ULL(bps, IOC_PAGE_SIZE));
879
+ if (bps) {
880
+ u64 bps_pages = DIV_ROUND_UP_ULL(bps, IOC_PAGE_SIZE);
881
+
882
+ if (bps_pages)
883
+ *page = DIV64_U64_ROUND_UP(VTIME_PER_SEC, bps_pages);
884
+ else
885
+ *page = 1;
886
+ }
878887
879888 if (seqiops) {
880889 v = DIV64_U64_ROUND_UP(VTIME_PER_SEC, seqiops);
....@@ -2417,6 +2426,7 @@
24172426 u32 hwi, adj_step;
24182427 s64 margin;
24192428 u64 cost, new_inuse;
2429
+ unsigned long flags;
24202430
24212431 current_hweight(iocg, NULL, &hwi);
24222432 old_hwi = hwi;
....@@ -2435,11 +2445,11 @@
24352445 iocg->inuse == iocg->active)
24362446 return cost;
24372447
2438
- spin_lock_irq(&ioc->lock);
2448
+ spin_lock_irqsave(&ioc->lock, flags);
24392449
24402450 /* we own inuse only when @iocg is in the normal active state */
24412451 if (iocg->abs_vdebt || list_empty(&iocg->active_list)) {
2442
- spin_unlock_irq(&ioc->lock);
2452
+ spin_unlock_irqrestore(&ioc->lock, flags);
24432453 return cost;
24442454 }
24452455
....@@ -2460,7 +2470,7 @@
24602470 } while (time_after64(vtime + cost, now->vnow) &&
24612471 iocg->inuse != iocg->active);
24622472
2463
- spin_unlock_irq(&ioc->lock);
2473
+ spin_unlock_irqrestore(&ioc->lock, flags);
24642474
24652475 TRACE_IOCG_PATH(inuse_adjust, iocg, now,
24662476 old_inuse, iocg->inuse, old_hwi, hwi);