analysisOfTheCausesOfTheFluctuation.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * Interface for controlling IO bandwidth on a request queue
  3. *
  4. * Copyright (C) 2010 Vivek Goyal <vgoyal@redhat.com>
  5. */
  6. #include <linux/module.h>
  7. #include <linux/slab.h>
  8. #include <linux/blkdev.h>
  9. #include <linux/bio.h>
  10. #include <linux/blktrace_api.h>
  11. #include "blk-cgroup.h"
  12. #include "blk.h"
  13. /* Max dispatch from a group in 1 round */
  14. static int throtl_grp_quantum = 8;
  15. /* Total max dispatch from all groups in one round */
  16. static int throtl_quantum = 32;
  17. /* Throttling is performed over 100ms slice and after that slice is renewed */
  18. static unsigned long throtl_slice = HZ/10; /* 100 ms */
  19. static struct blkcg_policy blkcg_policy_throtl;
  20. /* A workqueue to queue throttle related work */
  21. static struct workqueue_struct *kthrotld_workqueue;
  22. static void throtl_schedule_delayed_work(struct throtl_data *td,
  23. unsigned long delay);
  24. struct throtl_rb_root {
  25. struct rb_root rb;
  26. struct rb_node *left;
  27. unsigned int count;
  28. unsigned long min_disptime;
  29. };
  30. #define THROTL_RB_ROOT (struct throtl_rb_root) { .rb = RB_ROOT, .left = NULL, \
  31. .count = 0, .min_disptime = 0}
  32. #define rb_entry_tg(node) rb_entry((node), struct throtl_grp, rb_node)
  33. /* Per-cpu group stats */
  34. struct tg_stats_cpu {
  35. /* total bytes transferred */
  36. struct blkg_rwstat service_bytes;
  37. /* total IOs serviced, post merge */
  38. struct blkg_rwstat serviced;
  39. };
  40. struct throtl_grp {
  41. /* must be the first member */
  42. struct blkg_policy_data pd;
  43. /* active throtl group service_tree member */
  44. struct rb_node rb_node;
  45. /*
  46. * Dispatch time in jiffies. This is the estimated time when group
  47. * will unthrottle and is ready to dispatch more bio. It is used as
  48. * key to sort active groups in service tree.
  49. */
  50. unsigned long disptime;
  51. unsigned int flags;
  52. /* Two lists for READ and WRITE */
  53. struct bio_list bio_lists[2];
  54. /* Number of queued bios on READ and WRITE lists */
  55. unsigned int nr_queued[2];
  56. /* bytes per second rate limits */
  57. uint64_t bps[2];
  58. /* IOPS limits */
  59. unsigned int iops[2];
  60. /* Number of bytes disptached in current slice */
  61. uint64_t bytes_disp[2];
  62. /* Number of bio's dispatched in current slice */
  63. unsigned int io_disp[2];
  64. /* When did we start a new slice */
  65. unsigned long slice_start[2];
  66. unsigned long slice_end[2];
  67. /* Some throttle limits got updated for the group */
  68. int limits_changed;
  69. /* Per cpu stats pointer */
  70. struct tg_stats_cpu __percpu *stats_cpu;
  71. /* List of tgs waiting for per cpu stats memory to be allocated */
  72. struct list_head stats_alloc_node;
  73. };
  74. struct throtl_data
  75. {
  76. /* service tree for active throtl groups */
  77. struct throtl_rb_root tg_service_tree;
  78. struct request_queue *queue;
  79. /* Total Number of queued bios on READ and WRITE lists */
  80. unsigned int nr_queued[2];
  81. /*
  82. * number of total undestroyed groups
  83. */
  84. unsigned int nr_undestroyed_grps;
  85. /* Work for dispatching throttled bios */
  86. struct delayed_work throtl_work;
  87. int limits_changed;
  88. };
  89. /* list and work item to allocate percpu group stats */
  90. static DEFINE_SPINLOCK(tg_stats_alloc_lock);
  91. static LIST_HEAD(tg_stats_alloc_list);
  92. static void tg_stats_alloc_fn(struct work_struct *);
  93. static DECLARE_DELAYED_WORK(tg_stats_alloc_work, tg_stats_alloc_fn);
  94. static inline struct throtl_grp *pd_to_tg(struct blkg_policy_data *pd)
  95. {
  96. return pd ? container_of(pd, struct throtl_grp, pd) : NULL;
  97. }
  98. static inline struct throtl_grp *blkg_to_tg(struct blkcg_gq *blkg)
  99. {
  100. return pd_to_tg(blkg_to_pd(blkg, &blkcg_policy_throtl));
  101. }
  102. static inline struct blkcg_gq *tg_to_blkg(struct throtl_grp *tg)
  103. {
  104. return pd_to_blkg(&tg->pd);
  105. }
  106. static inline struct throtl_grp *td_root_tg(struct throtl_data *td)
  107. {
  108. return blkg_to_tg(td->queue->root_blkg);
  109. }
  110. enum tg_state_flags {
  111. THROTL_TG_FLAG_on_rr = 0, /* on round-robin busy list */
  112. };
  113. #define THROTL_TG_FNS(name) \
  114. static inline void throtl_mark_tg_##name(struct throtl_grp *tg) \
  115. { \
  116. (tg)->flags |= (1 << THROTL_TG_FLAG_##name); \
  117. } \
  118. static inline void throtl_clear_tg_##name(struct throtl_grp *tg) \
  119. { \
  120. (tg)->flags &= ~(1 << THROTL_TG_FLAG_##name); \
  121. } \
  122. static inline int throtl_tg_##name(const struct throtl_grp *tg) \
  123. { \
  124. return ((tg)->flags & (1 << THROTL_TG_FLAG_##name)) != 0; \
  125. }
  126. THROTL_TG_FNS(on_rr);
  127. #define throtl_log_tg(td, tg, fmt, args...) do { \
  128. char __pbuf[128]; \
  129. \
  130. blkg_path(tg_to_blkg(tg), __pbuf, sizeof(__pbuf)); \
  131. blk_add_trace_msg((td)->queue, "throtl %s " fmt, __pbuf, ##args); \
  132. } while (0)
  133. #define throtl_log(td, fmt, args...) \
  134. blk_add_trace_msg((td)->queue, "throtl " fmt, ##args)
  135. static inline unsigned int total_nr_queued(struct throtl_data *td)
  136. {
  137. return td->nr_queued[0] + td->nr_queued[1];
  138. }
  139. /*
  140. * Worker for allocating per cpu stat for tgs. This is scheduled on the
  141. * system_wq once there are some groups on the alloc_list waiting for
  142. * allocation.
  143. */
  144. static void tg_stats_alloc_fn(struct work_struct *work)
  145. {
  146. static struct tg_stats_cpu *stats_cpu; /* this fn is non-reentrant */
  147. struct delayed_work *dwork = to_delayed_work(work);
  148. bool empty = false;
  149. alloc_stats:
  150. if (!stats_cpu) {
  151. stats_cpu = alloc_percpu(struct tg_stats_cpu);
  152. if (!stats_cpu) {
  153. /* allocation failed, try again after some time */
  154. schedule_delayed_work(dwork, msecs_to_jiffies(10));
  155. return;
  156. }
  157. }
  158. spin_lock_irq(&tg_stats_alloc_lock);
  159. if (!list_empty(&tg_stats_alloc_list)) {
  160. struct throtl_grp *tg = list_first_entry(&tg_stats_alloc_list,
  161. struct throtl_grp,
  162. stats_alloc_node);
  163. swap(tg->stats_cpu, stats_cpu);
  164. list_del_init(&tg->stats_alloc_node);
  165. }
  166. empty = list_empty(&tg_stats_alloc_list);
  167. spin_unlock_irq(&tg_stats_alloc_lock);
  168. if (!empty)
  169. goto alloc_stats;
  170. }
  171. static void throtl_pd_init(struct blkcg_gq *blkg)
  172. {
  173. struct throtl_grp *tg = blkg_to_tg(blkg);
  174. unsigned long flags;
  175. RB_CLEAR_NODE(&tg->rb_node);
  176. bio_list_init(&tg->bio_lists[0]);
  177. bio_list_init(&tg->bio_lists[1]);
  178. tg->limits_changed = false;
  179. tg->bps[READ] = -1;
  180. tg->bps[WRITE] = -1;
  181. tg->iops[READ] = -1;
  182. tg->iops[WRITE] = -1;
  183. /*
  184. * Ugh... We need to perform per-cpu allocation for tg->stats_cpu
  185. * but percpu allocator can't be called from IO path. Queue tg on
  186. * tg_stats_alloc_list and allocate from work item.
  187. */
  188. spin_lock_irqsave(&tg_stats_alloc_lock, flags);
  189. list_add(&tg->stats_alloc_node, &tg_stats_alloc_list);
  190. schedule_delayed_work(&tg_stats_alloc_work, 0);
  191. spin_unlock_irqrestore(&tg_stats_alloc_lock, flags);
  192. }
  193. static void throtl_pd_exit(struct blkcg_gq *blkg)
  194. {
  195. struct throtl_grp *tg = blkg_to_tg(blkg);
  196. unsigned long flags;
  197. spin_lock_irqsave(&tg_stats_alloc_lock, flags);
  198. list_del_init(&tg->stats_alloc_node);
  199. spin_unlock_irqrestore(&tg_stats_alloc_lock, flags);
  200. free_percpu(tg->stats_cpu);
  201. }
  202. static void throtl_pd_reset_stats(struct blkcg_gq *blkg)
  203. {
  204. struct throtl_grp *tg = blkg_to_tg(blkg);
  205. int cpu;
  206. if (tg->stats_cpu == NULL)
  207. return;
  208. for_each_possible_cpu(cpu) {
  209. struct tg_stats_cpu *sc = per_cpu_ptr(tg->stats_cpu, cpu);
  210. blkg_rwstat_reset(&sc->service_bytes);
  211. blkg_rwstat_reset(&sc->serviced);
  212. }
  213. }
  214. static struct throtl_grp *throtl_lookup_tg(struct throtl_data *td,
  215. struct blkcg *blkcg)
  216. {
  217. /*
  218. * This is the common case when there are no blkcgs. Avoid lookup
  219. * in this case
  220. */
  221. if (blkcg == &blkcg_root)
  222. return td_root_tg(td);
  223. return blkg_to_tg(blkg_lookup(blkcg, td->queue));
  224. }
  225. static struct throtl_grp *throtl_lookup_create_tg(struct throtl_data *td,
  226. struct blkcg *blkcg)
  227. {
  228. struct request_queue *q = td->queue;
  229. struct throtl_grp *tg = NULL;
  230. /*
  231. * This is the common case when there are no blkcgs. Avoid lookup
  232. * in this case
  233. */
  234. if (blkcg == &blkcg_root) {
  235. tg = td_root_tg(td);
  236. } else {
  237. struct blkcg_gq *blkg;
  238. blkg = blkg_lookup_create(blkcg, q);
  239. /* if %NULL and @q is alive, fall back to root_tg */
  240. if (!IS_ERR(blkg))
  241. tg = blkg_to_tg(blkg);
  242. else if (!blk_queue_dying(q))
  243. tg = td_root_tg(td);
  244. }
  245. return tg;
  246. }
  247. static struct throtl_grp *throtl_rb_first(struct throtl_rb_root *root)
  248. {
  249. /* Service tree is empty */
  250. if (!root->count)
  251. return NULL;
  252. if (!root->left)
  253. root->left = rb_first(&root->rb);
  254. if (root->left)
  255. return rb_entry_tg(root->left);
  256. return NULL;
  257. }
  258. static void rb_erase_init(struct rb_node *n, struct rb_root *root)
  259. {
  260. rb_erase(n, root);
  261. RB_CLEAR_NODE(n);
  262. }
  263. static void throtl_rb_erase(struct rb_node *n, struct throtl_rb_root *root)
  264. {
  265. if (root->left == n)
  266. root->left = NULL;
  267. rb_erase_init(n, &root->rb);
  268. --root->count;
  269. }
  270. static void update_min_dispatch_time(struct throtl_rb_root *st)
  271. {
  272. struct throtl_grp *tg;
  273. tg = throtl_rb_first(st);
  274. if (!tg)
  275. return;
  276. st->min_disptime = tg->disptime;
  277. }
  278. static void
  279. tg_service_tree_add(struct throtl_rb_root *st, struct throtl_grp *tg)
  280. {
  281. struct rb_node **node = &st->rb.rb_node;
  282. struct rb_node *parent = NULL;
  283. struct throtl_grp *__tg;
  284. unsigned long key = tg->disptime;
  285. int left = 1;
  286. while (*node != NULL) {
  287. parent = *node;
  288. __tg = rb_entry_tg(parent);
  289. if (time_before(key, __tg->disptime))
  290. node = &parent->rb_left;
  291. else {
  292. node = &parent->rb_right;
  293. left = 0;
  294. }
  295. }
  296. if (left)
  297. st->left = &tg->rb_node;
  298. rb_link_node(&tg->rb_node, parent, node);
  299. rb_insert_color(&tg->rb_node, &st->rb);
  300. }
  301. static void __throtl_enqueue_tg(struct throtl_data *td, struct throtl_grp *tg)
  302. {
  303. struct throtl_rb_root *st = &td->tg_service_tree;
  304. tg_service_tree_add(st, tg);
  305. throtl_mark_tg_on_rr(tg);
  306. st->count++;
  307. }
  308. static void throtl_enqueue_tg(struct throtl_data *td, struct throtl_grp *tg)
  309. {
  310. if (!throtl_tg_on_rr(tg))
  311. __throtl_enqueue_tg(td, tg);
  312. }
  313. static void __throtl_dequeue_tg(struct throtl_data *td, struct throtl_grp *tg)
  314. {
  315. throtl_rb_erase(&tg->rb_node, &td->tg_service_tree);
  316. throtl_clear_tg_on_rr(tg);
  317. }
  318. static void throtl_dequeue_tg(struct throtl_data *td, struct throtl_grp *tg)
  319. {
  320. if (throtl_tg_on_rr(tg))
  321. __throtl_dequeue_tg(td, tg);
  322. }
  323. static void throtl_schedule_next_dispatch(struct throtl_data *td)
  324. {
  325. struct throtl_rb_root *st = &td->tg_service_tree;
  326. /*
  327. * If there are more bios pending, schedule more work.
  328. */
  329. if (!total_nr_queued(td))
  330. return;
  331. BUG_ON(!st->count);
  332. update_min_dispatch_time(st);
  333. if (time_before_eq(st->min_disptime, jiffies))
  334. throtl_schedule_delayed_work(td, 0);
  335. else
  336. throtl_schedule_delayed_work(td, (st->min_disptime - jiffies));
  337. }
  338. static inline void
  339. throtl_start_new_slice(struct throtl_data *td, struct throtl_grp *tg, bool rw)
  340. {
  341. tg->bytes_disp[rw] = 0;
  342. tg->io_disp[rw] = 0;
  343. tg->slice_start[rw] = jiffies;
  344. tg->slice_end[rw] = jiffies + throtl_slice;
  345. throtl_log_tg(td, tg, "[%c] new slice start=%lu end=%lu jiffies=%lu",
  346. rw == READ ? 'R' : 'W', tg->slice_start[rw],
  347. tg->slice_end[rw], jiffies);
  348. }
  349. static inline void throtl_set_slice_end(struct throtl_data *td,
  350. struct throtl_grp *tg, bool rw, unsigned long jiffy_end)
  351. {
  352. tg->slice_end[rw] = roundup(jiffy_end, throtl_slice);
  353. }
  354. static inline void throtl_extend_slice(struct throtl_data *td,
  355. struct throtl_grp *tg, bool rw, unsigned long jiffy_end)
  356. {
  357. tg->slice_end[rw] = roundup(jiffy_end, throtl_slice);
  358. throtl_log_tg(td, tg, "[%c] extend slice start=%lu end=%lu jiffies=%lu",
  359. rw == READ ? 'R' : 'W', tg->slice_start[rw],
  360. tg->slice_end[rw], jiffies);
  361. }
  362. /* Determine if previously allocated or extended slice is complete or not */
  363. static bool
  364. throtl_slice_used(struct throtl_data *td, struct throtl_grp *tg, bool rw)
  365. {
  366. if (time_in_range(jiffies, tg->slice_start[rw], tg->slice_end[rw]))
  367. return 0;
  368. return 1;
  369. }
  370. /* Trim the used slices and adjust slice start accordingly */
  371. static inline void
  372. throtl_trim_slice(struct throtl_data *td, struct throtl_grp *tg, bool rw)
  373. {
  374. unsigned long nr_slices, time_elapsed, io_trim;
  375. u64 bytes_trim, tmp;
  376. BUG_ON(time_before(tg->slice_end[rw], tg->slice_start[rw]));
  377. /*
  378. * If bps are unlimited (-1), then time slice don't get
  379. * renewed. Don't try to trim the slice if slice is used. A new
  380. * slice will start when appropriate.
  381. */
  382. if (throtl_slice_used(td, tg, rw))
  383. return;
  384. /*
  385. * A bio has been dispatched. Also adjust slice_end. It might happen
  386. * that initially cgroup limit was very low resulting in high
  387. * slice_end, but later limit was bumped up and bio was dispached
  388. * sooner, then we need to reduce slice_end. A high bogus slice_end
  389. * is bad because it does not allow new slice to start.
  390. */
  391. throtl_set_slice_end(td, tg, rw, jiffies + throtl_slice);
  392. time_elapsed = jiffies - tg->slice_start[rw];
  393. nr_slices = time_elapsed / throtl_slice;
  394. if (!nr_slices)
  395. return;
  396. tmp = tg->bps[rw] * throtl_slice * nr_slices;
  397. do_div(tmp, HZ);
  398. bytes_trim = tmp;
  399. io_trim = (tg->iops[rw] * throtl_slice * nr_slices)/HZ;
  400. if (!bytes_trim && !io_trim)
  401. return;
  402. if (tg->bytes_disp[rw] >= bytes_trim)
  403. tg->bytes_disp[rw] -= bytes_trim;
  404. else
  405. tg->bytes_disp[rw] = 0;
  406. if (tg->io_disp[rw] >= io_trim)
  407. tg->io_disp[rw] -= io_trim;
  408. else
  409. tg->io_disp[rw] = 0;
  410. tg->slice_start[rw] += nr_slices * throtl_slice;
  411. throtl_log_tg(td, tg, "[%c] trim slice nr=%lu bytes=%llu io=%lu"
  412. " start=%lu end=%lu jiffies=%lu",
  413. rw == READ ? 'R' : 'W', nr_slices, bytes_trim, io_trim,
  414. tg->slice_start[rw], tg->slice_end[rw], jiffies);
  415. }
  416. static bool tg_with_in_iops_limit(struct throtl_data *td, struct throtl_grp *tg,
  417. struct bio *bio, unsigned long *wait)
  418. {
  419. bool rw = bio_data_dir(bio);
  420. unsigned int io_allowed;
  421. unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
  422. u64 tmp;
  423. jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw];
  424. /* Slice has just started. Consider one slice interval */
  425. if (!jiffy_elapsed)
  426. jiffy_elapsed_rnd = throtl_slice;
  427. jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, throtl_slice);
  428. /*
  429. * jiffy_elapsed_rnd should not be a big value as minimum iops can be
  430. * 1 then at max jiffy elapsed should be equivalent of 1 second as we
  431. * will allow dispatch after 1 second and after that slice should
  432. * have been trimmed.
  433. */
  434. tmp = (u64)tg->iops[rw] * jiffy_elapsed_rnd;
  435. do_div(tmp, HZ);
  436. if (tmp > UINT_MAX)
  437. io_allowed = UINT_MAX;
  438. else
  439. io_allowed = tmp;
  440. if (tg->io_disp[rw] + 1 <= io_allowed) {
  441. if (wait)
  442. *wait = 0;
  443. return 1;
  444. }
  445. /* Calc approx time to dispatch */
  446. jiffy_wait = ((tg->io_disp[rw] + 1) * HZ)/tg->iops[rw] + 1;
  447. if (jiffy_wait > jiffy_elapsed)
  448. jiffy_wait = jiffy_wait - jiffy_elapsed;
  449. else
  450. jiffy_wait = 1;
  451. if (wait)
  452. *wait = jiffy_wait;
  453. return 0;
  454. }
  455. static bool tg_with_in_bps_limit(struct throtl_data *td, struct throtl_grp *tg,
  456. struct bio *bio, unsigned long *wait)
  457. {
  458. bool rw = bio_data_dir(bio);
  459. u64 bytes_allowed, extra_bytes, tmp;
  460. unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
  461. jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw];
  462. /* Slice has just started. Consider one slice interval */
  463. if (!jiffy_elapsed)
  464. jiffy_elapsed_rnd = throtl_slice;
  465. jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, throtl_slice);
  466. tmp = tg->bps[rw] * jiffy_elapsed_rnd;
  467. do_div(tmp, HZ);
  468. bytes_allowed = tmp;
  469. if (tg->bytes_disp[rw] + bio->bi_size <= bytes_allowed) {
  470. if (wait)
  471. *wait = 0;
  472. return 1;
  473. }
  474. /* Calc approx time to dispatch */
  475. extra_bytes = tg->bytes_disp[rw] + bio->bi_size - bytes_allowed;
  476. jiffy_wait = div64_u64(extra_bytes * HZ, tg->bps[rw]);
  477. if (!jiffy_wait)
  478. jiffy_wait = 1;
  479. /*
  480. * This wait time is without taking into consideration the rounding
  481. * up we did. Add that time also.
  482. */
  483. jiffy_wait = jiffy_wait + (jiffy_elapsed_rnd - jiffy_elapsed);
  484. if (wait)
  485. *wait = jiffy_wait;
  486. return 0;
  487. }
  488. static bool tg_no_rule_group(struct throtl_grp *tg, bool rw) {
  489. if (tg->bps[rw] == -1 && tg->iops[rw] == -1)
  490. return 1;
  491. return 0;
  492. }
  493. /*
  494. * Returns whether one can dispatch a bio or not. Also returns approx number
  495. * of jiffies to wait before this bio is with-in IO rate and can be dispatched
  496. */
  497. static bool tg_may_dispatch(struct throtl_data *td, struct throtl_grp *tg,
  498. struct bio *bio, unsigned long *wait)
  499. {
  500. bool rw = bio_data_dir(bio);
  501. unsigned long bps_wait = 0, iops_wait = 0, max_wait = 0;
  502. /*
  503. * Currently whole state machine of group depends on first bio
  504. * queued in the group bio list. So one should not be calling
  505. * this function with a different bio if there are other bios
  506. * queued.
  507. */
  508. BUG_ON(tg->nr_queued[rw] && bio != bio_list_peek(&tg->bio_lists[rw]));
  509. /* If tg->bps = -1, then BW is unlimited */
  510. if (tg->bps[rw] == -1 && tg->iops[rw] == -1) {
  511. if (wait)
  512. *wait = 0;
  513. return 1;
  514. }
  515. /*
  516. * If previous slice expired, start a new one otherwise renew/extend
  517. * existing slice to make sure it is at least throtl_slice interval
  518. * long since now.
  519. */