On Wed, Jan 05, 2022 at 01:14:09AM +0800, huang...@chinatelecom.cn wrote: > ## > +# @set-vcpu-dirty-limit: > +# > +# Set the upper limit of dirty page rate for virtual CPU. > +# > +# Requires KVM with accelerator property "dirty-ring-size" set. > +# A virtual CPU's dirty page rate is a measure of its memory load. > +# To observe dirty page rates, use @calc-dirty-rate. > +# > +# @cpu-index: index of virtual CPU, default is all. > +# > +# @dirty-rate: upper limit of dirty page rate for virtual CPU.
Same here, we could add the unit of dirty rate (MB/s), and in all the rest of the places around dirty rate. > +void qmp_set_vcpu_dirty_limit(bool has_cpu_index, > + uint64_t cpu_index, > + uint64_t dirty_rate, > + Error **errp) > +{ > + if (!kvm_enabled() || !kvm_dirty_ring_enabled()) { > + error_setg(errp, "dirty page limit feature requires KVM with" > + " accelerator property 'dirty-ring-size' set'"); > + return; > + } > + > + if (!dirtylimit_in_service()) { > + vcpu_dirty_rate_stat_initialize(); > + vcpu_dirty_rate_stat_start(); > + } > + > + if (has_cpu_index && !dirtylimit_vcpu_index_valid(cpu_index)) { > + error_setg(errp, "incorrect cpu index specified"); > + return; > + } This could be moved before above vcpu_dirty_rate_stat_initialize() calls. I've left some comments in previous patch on this; please refer to the pesudo code. The rest looks good to me. Thanks, > + > + if (has_cpu_index) { > + dirtylimit_set_vcpu(cpu_index, dirty_rate, true); > + } else { > + dirtylimit_set_all(dirty_rate, true); > + } > +} -- Peter Xu