Lines Matching +full:duration +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0
32 return -EINVAL; \
55 return -EINVAL; \
64 return -EINVAL; \
66 while (u--) { \
69 return -EINVAL; \
71 (i < 0 && -ANYSINT_MAX(type) / 1024 > i)) \
72 return -EINVAL; \
86 * bch_hprint - formats @v to human readable string for sysfs. in STRTO_H()
100 q = -v; in STRTO_H()
116 /* '-', up to 3 digits, '.', 1 digit, 1 character, null; in STRTO_H()
119 return sprintf(buf, "-%llu.%i%c", q, t * 10 / 1024, units[u]); in STRTO_H()
141 i < strspn(s, "-0123456789:ABCDEFabcdef") && j < 32; in bch_parse_uuid()
147 x -= '0'; in bch_parse_uuid()
150 x -= 'a' - 10; in bch_parse_uuid()
165 uint64_t now, duration, last; in bch_time_stats_update() local
167 spin_lock(&stats->lock); in bch_time_stats_update()
170 duration = time_after64(now, start_time) in bch_time_stats_update()
171 ? now - start_time : 0; in bch_time_stats_update()
172 last = time_after64(now, stats->last) in bch_time_stats_update()
173 ? now - stats->last : 0; in bch_time_stats_update()
175 stats->max_duration = max(stats->max_duration, duration); in bch_time_stats_update()
177 if (stats->last) { in bch_time_stats_update()
178 ewma_add(stats->average_duration, duration, 8, 8); in bch_time_stats_update()
180 if (stats->average_frequency) in bch_time_stats_update()
181 ewma_add(stats->average_frequency, last, 8, 8); in bch_time_stats_update()
183 stats->average_frequency = last << 8; in bch_time_stats_update()
185 stats->average_duration = duration << 8; in bch_time_stats_update()
188 stats->last = now ?: 1; in bch_time_stats_update()
190 spin_unlock(&stats->lock); in bch_time_stats_update()
194 * bch_next_delay() - update ratelimiting statistics and calculate next delay
205 d->next += div_u64(done * NSEC_PER_SEC, atomic_long_read(&d->rate)); in bch_next_delay()
207 /* Bound the time. Don't let us fall further than 2 seconds behind in bch_next_delay()
210 * don't let us sleep more than 2.5 seconds (so we can notice/respond in bch_next_delay()
211 * if the control system tells us to speed up!). in bch_next_delay()
213 if (time_before64(now + NSEC_PER_SEC * 5LLU / 2LLU, d->next)) in bch_next_delay()
214 d->next = now + NSEC_PER_SEC * 5LLU / 2LLU; in bch_next_delay()
216 if (time_after64(now - NSEC_PER_SEC * 2, d->next)) in bch_next_delay()
217 d->next = now - NSEC_PER_SEC * 2; in bch_next_delay()
219 return time_after64(d->next, now) in bch_next_delay()
220 ? div_u64(d->next - now, NSEC_PER_SEC / HZ) in bch_next_delay()
233 size_t size = bio->bi_iter.bi_size; in bch_bio_map()
234 struct bio_vec *bv = bio->bi_io_vec; in bch_bio_map()
236 BUG_ON(!bio->bi_iter.bi_size); in bch_bio_map()
237 BUG_ON(bio->bi_vcnt); in bch_bio_map()
239 bv->bv_offset = base ? offset_in_page(base) : 0; in bch_bio_map()
242 for (; size; bio->bi_vcnt++, bv++) { in bch_bio_map()
243 bv->bv_offset = 0; in bch_bio_map()
244 start: bv->bv_len = min_t(size_t, PAGE_SIZE - bv->bv_offset, in bch_bio_map()
247 bv->bv_page = is_vmalloc_addr(base) in bch_bio_map()
251 base += bv->bv_len; in bch_bio_map()
254 size -= bv->bv_len; in bch_bio_map()
259 * bch_bio_alloc_pages - allocates a single page for each bvec in a bio
263 * Allocates pages up to @bio->bi_vcnt.
265 * Returns 0 on success, -ENOMEM on failure. On failure, any allocated pages are
277 for (i = 0, bv = bio->bi_io_vec; i < bio->bi_vcnt; bv++, i++) { in bch_bio_alloc_pages()
278 bv->bv_page = alloc_page(gfp_mask); in bch_bio_alloc_pages()
279 if (!bv->bv_page) { in bch_bio_alloc_pages()
280 while (--bv >= bio->bi_io_vec) in bch_bio_alloc_pages()
281 __free_page(bv->bv_page); in bch_bio_alloc_pages()
282 return -ENOMEM; in bch_bio_alloc_pages()