Lines Matching +full:current +full:- +full:limit

2  * Dirty page rate limit implementation code
10 * See the COPYING file in the top-level directory.
14 #include "qemu/main-loop.h"
15 #include "qapi/qapi-commands-migration.h"
95 vcpu_dirty_rate_stat->stat.rates[i].id = i; in vcpu_dirty_rate_stat_collect()
96 vcpu_dirty_rate_stat->stat.rates[i].dirty_rate = in vcpu_dirty_rate_stat_collect()
110 while (qatomic_read(&vcpu_dirty_rate_stat->running)) { in vcpu_dirty_rate_stat_thread()
126 DirtyRateVcpu *rates = vcpu_dirty_rate_stat->stat.rates; in vcpu_dirty_rate_get()
132 if (qatomic_read(&vcpu_dirty_rate_stat->running)) { in vcpu_dirty_rate_stat_start()
136 qatomic_set(&vcpu_dirty_rate_stat->running, 1); in vcpu_dirty_rate_stat_start()
137 qemu_thread_create(&vcpu_dirty_rate_stat->thread, in vcpu_dirty_rate_stat_start()
138 "dirtyrate-stat", in vcpu_dirty_rate_stat_start()
146 qatomic_set(&vcpu_dirty_rate_stat->running, 0); in vcpu_dirty_rate_stat_stop()
149 qemu_thread_join(&vcpu_dirty_rate_stat->thread); in vcpu_dirty_rate_stat_stop()
157 int max_cpus = ms->smp.max_cpus; in vcpu_dirty_rate_stat_initialize()
162 vcpu_dirty_rate_stat->stat.nvcpu = max_cpus; in vcpu_dirty_rate_stat_initialize()
163 vcpu_dirty_rate_stat->stat.rates = in vcpu_dirty_rate_stat_initialize()
166 vcpu_dirty_rate_stat->running = false; in vcpu_dirty_rate_stat_initialize()
171 g_free(vcpu_dirty_rate_stat->stat.rates); in vcpu_dirty_rate_stat_finalize()
172 vcpu_dirty_rate_stat->stat.rates = NULL; in vcpu_dirty_rate_stat_finalize()
196 return &dirtylimit_state->states[cpu_index]; in dirtylimit_vcpu_get_state()
202 int max_cpus = ms->smp.max_cpus; in dirtylimit_state_initialize()
207 dirtylimit_state->states = in dirtylimit_state_initialize()
211 dirtylimit_state->states[i].cpu_index = i; in dirtylimit_state_initialize()
214 dirtylimit_state->max_cpus = max_cpus; in dirtylimit_state_initialize()
220 g_free(dirtylimit_state->states); in dirtylimit_state_finalize()
221 dirtylimit_state->states = NULL; in dirtylimit_state_finalize()
239 cpu_index >= ms->smp.max_cpus); in dirtylimit_vcpu_index_valid()
257 uint64_t current) in dirtylimit_done() argument
261 min = MIN(quota, current); in dirtylimit_done()
262 max = MAX(quota, current); in dirtylimit_done()
264 return ((max - min) <= DIRTYLIMIT_TOLERANCE_RANGE) ? true : false; in dirtylimit_done()
269 uint64_t current) in dirtylimit_need_linear_adjustment() argument
273 min = MIN(quota, current); in dirtylimit_need_linear_adjustment()
274 max = MAX(quota, current); in dirtylimit_need_linear_adjustment()
276 return ((max - min) * 100 / max) > DIRTYLIMIT_LINEAR_ADJUSTMENT_PCT; in dirtylimit_need_linear_adjustment()
281 uint64_t current) in dirtylimit_set_throttle() argument
287 if (current == 0) { in dirtylimit_set_throttle()
288 cpu->throttle_us_per_full = 0; in dirtylimit_set_throttle()
292 ring_full_time_us = dirtylimit_dirty_ring_full_time(current); in dirtylimit_set_throttle()
294 if (dirtylimit_need_linear_adjustment(quota, current)) { in dirtylimit_set_throttle()
295 if (quota < current) { in dirtylimit_set_throttle()
296 sleep_pct = (current - quota) * 100 / current; in dirtylimit_set_throttle()
298 ring_full_time_us * sleep_pct / (double)(100 - sleep_pct); in dirtylimit_set_throttle()
299 cpu->throttle_us_per_full += throttle_us; in dirtylimit_set_throttle()
301 sleep_pct = (quota - current) * 100 / quota; in dirtylimit_set_throttle()
303 ring_full_time_us * sleep_pct / (double)(100 - sleep_pct); in dirtylimit_set_throttle()
304 cpu->throttle_us_per_full -= throttle_us; in dirtylimit_set_throttle()
307 trace_dirtylimit_throttle_pct(cpu->cpu_index, in dirtylimit_set_throttle()
311 if (quota < current) { in dirtylimit_set_throttle()
312 cpu->throttle_us_per_full += ring_full_time_us / 10; in dirtylimit_set_throttle()
314 cpu->throttle_us_per_full -= ring_full_time_us / 10; in dirtylimit_set_throttle()
320 * current dirty page rate may never reach the quota, we should stop in dirtylimit_set_throttle()
323 cpu->throttle_us_per_full = MIN(cpu->throttle_us_per_full, in dirtylimit_set_throttle()
326 cpu->throttle_us_per_full = MAX(cpu->throttle_us_per_full, 0); in dirtylimit_set_throttle()
332 uint64_t current = 0; in dirtylimit_adjust_throttle() local
333 int cpu_index = cpu->cpu_index; in dirtylimit_adjust_throttle()
335 quota = dirtylimit_vcpu_get_state(cpu_index)->quota; in dirtylimit_adjust_throttle()
336 current = vcpu_dirty_rate_get(cpu_index); in dirtylimit_adjust_throttle()
338 if (!dirtylimit_done(quota, current)) { in dirtylimit_adjust_throttle()
339 dirtylimit_set_throttle(cpu, quota, current); in dirtylimit_adjust_throttle()
358 if (!dirtylimit_vcpu_get_state(cpu->cpu_index)->enabled) { in dirtylimit_process()
383 dirtylimit_state->states[cpu_index].quota = quota; in dirtylimit_set_vcpu()
384 if (!dirtylimit_vcpu_get_state(cpu_index)->enabled) { in dirtylimit_set_vcpu()
385 dirtylimit_state->limited_nvcpu++; in dirtylimit_set_vcpu()
388 dirtylimit_state->states[cpu_index].quota = 0; in dirtylimit_set_vcpu()
389 if (dirtylimit_state->states[cpu_index].enabled) { in dirtylimit_set_vcpu()
390 dirtylimit_state->limited_nvcpu--; in dirtylimit_set_vcpu()
394 dirtylimit_state->states[cpu_index].enabled = enable; in dirtylimit_set_vcpu()
401 int max_cpus = ms->smp.max_cpus; in dirtylimit_set_all()
411 if (cpu->throttle_us_per_full) { in dirtylimit_vcpu_execute()
415 dirtylimit_vcpu_get_state(cpu->cpu_index)->enabled) { in dirtylimit_vcpu_execute()
417 trace_dirtylimit_vcpu_execute(cpu->cpu_index, in dirtylimit_vcpu_execute()
418 cpu->throttle_us_per_full); in dirtylimit_vcpu_execute()
420 g_usleep(cpu->throttle_us_per_full); in dirtylimit_vcpu_execute()
445 * dirty page rate limit is not allowed to set if migration
446 * is running with dirty-limit capability enabled.
473 error_setg(errp, "can't cancel dirty page rate limit while" in qmp_cancel_vcpu_dirty_limit()
490 if (!dirtylimit_state->limited_nvcpu) { in qmp_cancel_vcpu_dirty_limit()
499 int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1); in hmp_cancel_vcpu_dirty_limit()
502 qmp_cancel_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, &err); in hmp_cancel_vcpu_dirty_limit()
509 "dirty limit for virtual CPU]\n"); in hmp_cancel_vcpu_dirty_limit()
518 error_setg(errp, "dirty page limit feature requires KVM with" in qmp_set_vcpu_dirty_limit()
519 " accelerator property 'dirty-ring-size' set'"); in qmp_set_vcpu_dirty_limit()
529 error_setg(errp, "can't set dirty page rate limit while" in qmp_set_vcpu_dirty_limit()
557 int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1); in hmp_set_vcpu_dirty_limit()
561 error_setg(&err, "invalid dirty page limit %" PRId64, dirty_rate); in hmp_set_vcpu_dirty_limit()
565 qmp_set_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, dirty_rate, &err); in hmp_set_vcpu_dirty_limit()
578 if (cpu->throttle_us_per_full > max) { in dirtylimit_throttle_time_per_round()
579 max = cpu->throttle_us_per_full; in dirtylimit_throttle_time_per_round()
597 if (cpu->running) { in dirtylimit_ring_full_time()
599 curr_rate += vcpu_dirty_rate_get(cpu->cpu_index); in dirtylimit_ring_full_time()
615 info->cpu_index = cpu_index; in dirtylimit_query_vcpu()
616 info->limit_rate = dirtylimit_vcpu_get_state(cpu_index)->quota; in dirtylimit_query_vcpu()
617 info->current_rate = vcpu_dirty_rate_get(cpu_index); in dirtylimit_query_vcpu()
635 for (i = 0; i < dirtylimit_state->max_cpus; i++) { in dirtylimit_query_all()
636 index = dirtylimit_state->states[i].cpu_index; in dirtylimit_query_all()
637 if (dirtylimit_vcpu_get_state(index)->enabled) { in dirtylimit_query_all()
660 monitor_printf(mon, "Dirty page limit not enabled!\n"); in hmp_info_vcpu_dirty_limit()
670 for (info = head; info != NULL; info = info->next) { in hmp_info_vcpu_dirty_limit()
671 monitor_printf(mon, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s)," in hmp_info_vcpu_dirty_limit()
672 " current rate %"PRIi64 " (MB/s)\n", in hmp_info_vcpu_dirty_limit()
673 info->value->cpu_index, in hmp_info_vcpu_dirty_limit()
674 info->value->limit_rate, in hmp_info_vcpu_dirty_limit()
675 info->value->current_rate); in hmp_info_vcpu_dirty_limit()