support dirty restraint on vCPU
v9 cover support dirty restraint on vCPU
From: Hyman Huang(黄勇) <[email protected]>
v9:
- rebase on master
- fix the meson directory change, keep it untouched.
v8:
- rebase on master
- polish the error message and remove the "unlikely" compilation syntax according to the advice given by Markus.
- keep the dirty tracking enabled during "dirtylimit-calc" lifecycle so that the overhead can be reduced according to the advice given by Peter.
- merge the "set/cancel" qmp commands into one named "vcpu-dirty-limit" and introduce qmp command "query-vcpu-dirty-limit" to query dirty limit information about virtual CPU, according to the advice given by Peter.
- check if vcpu index is valid and handle the unplug case before enabling, disabling dirty limit for virtual CPU.
- introduce hmp commands so developers can play with them easier, use "vcpu_dirty_limit" to enable dirty limit and "info vcpu_dirty_limit" to query.
The patch [2/3] has not been touched so far. Any corrections and suggetions are welcome.
Please review, thanks!
v7:
- rebase on master
- polish the comments and error message according to the advices given by Markus
- introduce dirtylimit_enabled function to pre-check if dirty page limit is enabled before canceling.
v6:
- rebase on master
- fix dirtylimit setup crash found by Markus
- polish the comments according to the advice given by Markus
- adjust the qemu qmp command tag to 7.0
v5:
- rebase on master
- adjust the throttle algorithm by removing the tuning in RESTRAINT_RATIO case so that dirty page rate could reachs the quota more quickly.
- fix percentage update in throttle iteration.
v4:
- rebase on master
- modify the following points according to the advice given by Markus
1. move the defination into migration.json
2. polish the comments of set-dirty-limit
3. do the syntax check and change dirty rate to dirty page rate
Thanks for the carefule reviews made by Markus.
Please review, thanks!
v3:
- rebase on master
- modify the following points according to the advice given by Markus
1. remove the DirtyRateQuotaVcpu and use its field as option directly
2. add comments to show details of what dirtylimit setup do
3. explain how to use dirtylimit in combination with existing qmp commands "calc-dirty-rate" and "query-dirty-rate" in documentation.
Thanks for the carefule reviews made by Markus.
Please review, thanks!
Hyman
v2:
- rebase on master
- modify the following points according to the advices given by Juan
1. rename dirtyrestraint to dirtylimit
2. implement the full lifecyle function of dirtylimit_calc, include dirtylimit_calc and dirtylimit_calc_quit
3. introduce 'quit' field in dirtylimit_calc_state to implement the dirtylimit_calc_quit
4. remove the ready_cond and ready_mtx since it may not be suitable
5. put the 'record_dirtypage' function code at the beggining of the file
6. remove the unnecesary return;
- other modifications has been made after code review
1. introduce 'bmap' and 'nr' field in dirtylimit_state to record the number of running thread forked by dirtylimit
2. stop the dirtyrate calculation thread if all the dirtylimit thread are stopped
3. do some renaming works
dirtyrate calulation thread -> dirtylimit-calc
dirtylimit thread -> dirtylimit-{cpu_index}
function name do_dirtyrestraint -> dirtylimit_check
qmp command dirty-restraint -> set-drity-limit
qmp command dirty-restraint-cancel -> cancel-dirty-limit
header file dirtyrestraint.h -> dirtylimit.hPlease review, thanks !
thanks for the accurate and timely advices given by Juan. we really appreciate it if corrections and suggetions about this patchset are proposed.
Best Regards !
Hyman
v1:
this patchset introduce a mechanism to impose dirty restraint on vCPU, aiming to keep the vCPU running in a certain dirtyrate given by user. dirty restraint on vCPU maybe an alternative method to implement convergence logic for live migration, which could improve guest memory performance during migration compared with traditional method in theory.
For the current live migration implementation, the convergence logic throttles all vCPUs of the VM, which has some side effects. -'read processes' on vCPU will be unnecessarily penalized
- throttle increase percentage step by step, which seems struggling to find the optimal throttle percentage when dirtyrate is high.
- hard to predict the remaining time of migration if the throttling percentage reachs 99%
to a certain extent, the dirty restraint machnism can fix these effects by throttling at vCPU granularity during migration.
the implementation is rather straightforward, we calculate vCPU dirtyrate via the Dirty Ring mechanism periodically as the commit 0e21bf246 "implement dirty-ring dirtyrate calculation" does, for vCPU that be specified to impose dirty restraint, we throttle it periodically as the auto-converge does, once after throttling, we compare the quota dirtyrate with current dirtyrate, if current dirtyrate is not under the quota, increase the throttling percentage until current dirtyrate is under the quota.
this patchset is the basis of implmenting a new auto-converge method for live migration, we introduce two qmp commands for impose/cancel the dirty restraint on specified vCPU, so it also can be an independent api to supply the upper app such as libvirt, which can use it to implement the convergence logic during live migration, supplemented with the qmp 'calc-dirty-rate' command or whatever.
we post this patchset for RFC and any corrections and suggetions about the implementation, api, throttleing algorithm or whatever are very appreciated!
Please review, thanks !
Best Regards !
Hyman Huang (3):
migration/dirtyrate: implement vCPU dirtyrate calculation periodically
cpu-throttle: implement vCPU throttle
cpus-common: implement dirty page limit on vCPU
cpus-common.c | 149 ++++++++++++++++++ hmp-commands-info.hx | 13 ++ hmp-commands.hx | 16 ++ include/exec/memory.h | 5 +- include/hw/core/cpu.h | 9 ++ include/monitor/hmp.h | 2 + include/sysemu/cpu-throttle.h | 45 ++++++ include/sysemu/dirtylimit.h | 44 ++++++ migration/dirtyrate.c | 142 +++++++++++++++-- migration/dirtyrate.h | 2 + qapi/migration.json | 70 +++++++++ softmmu/cpu-throttle.c | 355 ++++++++++++++++++++++++++++++++++++++++++ softmmu/trace-events | 5 + softmmu/vl.c | 1 + 14 files changed, 847 insertions(+), 11 deletions(-) create mode 100644 include/sysemu/dirtylimit.h
Signature · 1 line
1.8.3.1
PATCH v9 1/3 migration/dirtyrate: implement vCPU dirtyrate calculation periodically
From: Hyman Huang(黄勇) <[email protected]>
Introduce the third method GLOBAL_DIRTY_LIMIT of dirty tracking for calculate dirtyrate periodly for dirty restraint.
Implement thread for calculate dirtyrate periodly, which will be used for dirty restraint.
Add dirtylimit.h to introduce the util function for dirty limit implementation.
--- include/exec/memory.h | 5 +- include/sysemu/dirtylimit.h | 44 ++++++++++++++ migration/dirtyrate.c | 142 ++++++++++++++++++++++++++++++++++++++++---- migration/dirtyrate.h | 2 + 4 files changed, 182 insertions(+), 11 deletions(-) create mode 100644 include/sysemu/dirtylimit.h
include/exec/memory.h +4 -1
@@ -69,7 +69,10 @@ static inline void fuzz_dma_read_cb(size_t addr,/* Dirty tracking enabled because measuring dirty rate */ #define GLOBAL_DIRTY_DIRTY_RATE (1U << 1) -#define GLOBAL_DIRTY_MASK (0x3) +/* Dirty tracking enabled because dirty limit */ +#define GLOBAL_DIRTY_LIMIT (1U << 2) + +#define GLOBAL_DIRTY_MASK (0x7)extern unsigned int global_dirty_tracking;
include/sysemu/dirtylimit.h new file +44 -0
44 lines not on this page · raw message
migration/dirtyrate.c +132 -10
160 lines not on this page · raw message
migration/dirtyrate.h +2 -0
@@ -70,6 +70,8 @@ typedef struct VcpuStat {DirtyRateVcpu *rates;/* array of dirty rate for each vcpu */ } VcpuStat; +typedef struct VcpuStat DirtyRatesData ; +/* * Store calculation statistics for each measure. */
Signature · 1 line
1.8.3.1
Re: [PATCH v9 1/3] migration/dirtyrate: implement vCPU dirtyrate calculation periodically
Quoted 33 lines · On Fri, Dec 03, 2021 at 09:39:45AM +0800, [email protected] wrote:
migration/dirtyrate.c +33
-0+static void dirtylimit_calc_func (void ) +{ +CPUState *cpu; +DirtyPageRecord *dirty_pages; +int64_t start_time, end_time, calc_time; +DirtyRateVcpu rate; +int i =0 ; + + dirty_pages =g_malloc0 (sizeof (*dirty_pages) * + dirtylimit_calc_state->data.nvcpu); + +CPU_FOREACH (cpu) { +record_dirtypages (dirty_pages, cpu, true); + } + + start_time =qemu_clock_get_ms (QEMU_CLOCK_REALTIME ); +g_usleep (DIRTYLIMIT_CALC_TIME_MS *1000 ); + end_time =qemu_clock_get_ms (QEMU_CLOCK_REALTIME ); + calc_time = end_time - start_time; + +qemu_mutex_lock_iothread (); +memory_global_dirty_log_sync (); +qemu_mutex_unlock_iothread (); + +CPU_FOREACH (cpu) { +record_dirtypages (dirty_pages, cpu, false); + } + +for (i =0 ; i < dirtylimit_calc_state->data.nvcpu; i++) { +uint64_t increased_dirty_pages = + dirty_pages[i].end_pages - dirty_pages[i].start_pages; +uint64_t memory_size_MB = + (increased_dirty_pages *TARGET_PAGE_SIZE ) >>20 ;
migration/dirtyrate.c static struct DirtyRateStat DirtyStat; · line 124
Quoted 10 lines
migration/dirtyrate.c +10
-0+int64_t dirtyrate = (memory_size_MB *1000 ) / calc_time; + + rate.id = i; + rate.dirty_rate = dirtyrate; + dirtylimit_calc_state->data.rates[i] = rate; + +trace_dirtyrate_do_calculate_vcpu (i, + dirtylimit_calc_state->data.rates[i].dirty_rate); + } +}
This looks so like the calc-dirty-rate code already.
I think adding a new resion (GLOBAL_DIRTY_LIMIT) is fine, however still, any chance to merge the code?
Signature · 1 line
Peter Xu
Re: [PATCH v9 1/3] migration/dirtyrate: implement vCPU dirtyrate calculation periodically
Quoted 47 lines · Peter Xu
Quoted 33 lines · On Fri, Dec 03, 2021 at 09:39:45AM +0800, [email protected] wrote:
migration/dirtyrate.c +33
-0+static void dirtylimit_calc_func (void ) +{ +CPUState *cpu; +DirtyPageRecord *dirty_pages; +int64_t start_time, end_time, calc_time; +DirtyRateVcpu rate; +int i =0 ; + + dirty_pages =g_malloc0 (sizeof (*dirty_pages) * + dirtylimit_calc_state->data.nvcpu); + +CPU_FOREACH (cpu) { +record_dirtypages (dirty_pages, cpu, true); + } + + start_time =qemu_clock_get_ms (QEMU_CLOCK_REALTIME ); +g_usleep (DIRTYLIMIT_CALC_TIME_MS *1000 ); + end_time =qemu_clock_get_ms (QEMU_CLOCK_REALTIME ); + calc_time = end_time - start_time; + +qemu_mutex_lock_iothread (); +memory_global_dirty_log_sync (); +qemu_mutex_unlock_iothread (); + +CPU_FOREACH (cpu) { +record_dirtypages (dirty_pages, cpu, false); + } + +for (i =0 ; i < dirtylimit_calc_state->data.nvcpu; i++) { +uint64_t increased_dirty_pages = + dirty_pages[i].end_pages - dirty_pages[i].start_pages; +uint64_t memory_size_MB = + (increased_dirty_pages *TARGET_PAGE_SIZE ) >>20 ;migration/dirtyrate.c static struct DirtyRateStat DirtyStat; · line 124
Quoted 10 lines
migration/dirtyrate.c +10
-0+int64_t dirtyrate = (memory_size_MB *1000 ) / calc_time; + + rate.id = i; + rate.dirty_rate = dirtyrate; + dirtylimit_calc_state->data.rates[i] = rate; + +trace_dirtyrate_do_calculate_vcpu (i, + dirtylimit_calc_state->data.rates[i].dirty_rate); + } +}This looks so like the calc-dirty-rate code already.
Quoted 1 line
I think adding a new resion (
GLOBAL_DIRTY_LIMIT) is fine, however still, any
Ok.
Quoted 1 line
chance to merge the code?
I'm not sure about merging but i'll try it. :)
Quoted 1 line
PATCH v9 2/3 cpu-throttle: implement vCPU throttle
In reply to [email protected]From: Hyman Huang(黄勇) <[email protected]>
Impose dirty restraint on vCPU by kicking it and sleep as the auto-converge does during migration, but just kick the specified vCPU instead, not all vCPUs of vm.
Start a thread to track the dirtylimit status and adjust the throttle pencentage dynamically depend on current and quota dirtyrate.
Introduce the util function in the header for dirtylimit implementation.
--- include/sysemu/cpu-throttle.h | 45 ++++++ qapi/migration.json | 22 +++ softmmu/cpu-throttle.c | 355 ++++++++++++++++++++++++++++++++++++++++++ softmmu/trace-events | 5 + 4 files changed, 427 insertions(+)
include/sysemu/cpu-throttle.h +45 -0
@@ -65,4 +65,49 @@ bool cpu_throttle_active(void);*/ int cpu_throttle_get_percentage (void ); +/** +* dirtylimit_enabled +* +* Returns: %true if dirty page limit for vCPU is enabled, %false otherwise. +*/ +bool dirtylimit_enabled (int cpu_index); + +/** +* dirtylimit_is_vcpu_index_valid +* +* Returns: %true if cpu index valid, %false otherwise. +*/ +bool dirtylimit_is_vcpu_index_valid (int cpu_index); + +/** +* dirtylimit_state_init: +* +* initialize golobal state for dirtylimit +*/ +void dirtylimit_state_init (int max_cpus); + +/** +* dirtylimit_vcpu: +* +* impose dirtylimit on vcpu util reaching the quota dirtyrate +*/ +void dirtylimit_vcpu (int cpu_index, +uint64_t quota); + +/** +* dirtylimit_query_vcpu: +* +* Returns: dirty page limit information of specified virtual CPU. +*/ +struct DirtyLimitInfo *dirtylimit_query_vcpu (int cpu_index); + +/** +* dirtylimit_cancel_vcpu: +* +* cancel dirtylimit for the specified vcpu +* +* Returns: the number of running threads for dirtylimit +*/ +int dirtylimit_cancel_vcpu (int cpu_index); +#endif /* SYSEMU_CPU_THROTTLE_H */
qapi/migration.json +22 -0
@@ -1850,6 +1850,28 @@ { 'command': 'query-dirty-rate', 'returns': 'DirtyRateInfo' } ## +# @DirtyLimitInfo: +# +# Dirty page rate limit information of virtual CPU. +# +# @cpu-index: index of virtual CPU. +# +# @enable: true to enable, false to disable. +# +# @limit-rate: upper limit of dirty page rate for virtual CPU. +# +# @current-rate: current dirty page rate for virtual CPU. +# +# Since: 7.0 +# +## +{ 'struct': 'DirtyLimitInfo', + 'data': { 'cpu-index': 'int', + 'enable': 'bool', + 'limit-rate': 'int64', + 'current-rate': 'int64' } } + +## # @snapshot-save: # # Save a VM snapshot
softmmu/cpu-throttle.c +355 -0
367 lines not on this page · raw message
softmmu/trace-events +5 -0
@@ -31,3 +31,8 @@ runstate_set(int current_state, const char *current_state_str, int new_state, co system_wakeup_request(int reason) "reason=%d" qemu_system_shutdown_request(int reason) "reason=%d" qemu_system_powerdown_request(void) "" + +#cpu-throttle.c +dirtylimit_state_init(int max_cpus) "dirtylimit state init: max cpus %d" +dirtylimit_impose(int cpu_index, uint64_t quota, uint64_t current, int pct) "CPU[%d] impose dirtylimit: quota %" PRIu64 ", current %" PRIu64 ", percentage %d" +dirtylimit_vcpu(int cpu_index, uint64_t quota) "CPU[%d] set quota dirtylimit %"PRIu64
Signature · 1 line
1.8.3.1
Re: [PATCH v9 2/3] cpu-throttle: implement vCPU throttle
Quoted 86 lines · On Fri, Dec 03, 2021 at 09:39:46AM +0800, [email protected] wrote:
(quoted diff) +86
-0+static uint64_t dirtylimit_pct(unsigned int last_pct, + uint64_t quota, + uint64_t current) +{ + uint64_t limit_pct = 0; + RestrainPolicy policy; + bool mitigate = (quota > current) ? true : false; + + if (mitigate && ((current == 0) || + (last_pct <= DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE))) { + return 0; + } + + policy = dirtylimit_policy(last_pct, quota, current); + switch (policy) { + case RESTRAIN_SLIGHT: + /* [90, 99] */ + if (mitigate) { + limit_pct = + last_pct - DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE; + } else { + limit_pct = + last_pct + DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE; + + limit_pct = MIN(limit_pct, CPU_THROTTLE_PCT_MAX); + } + break; + case RESTRAIN_HEAVY: + /* [75, 90) */ + if (mitigate) { + limit_pct = + last_pct - DIRTYLIMIT_THROTTLE_HEAVY_STEP_SIZE; + } else { + limit_pct = + last_pct + DIRTYLIMIT_THROTTLE_HEAVY_STEP_SIZE; + + limit_pct = MIN(limit_pct, + DIRTYLIMIT_THROTTLE_SLIGHT_WATERMARK); + } + break; + case RESTRAIN_RATIO: + /* [0, 75) */ + if (mitigate) { + if (last_pct <= (((quota - current) * 100 / quota))) { + limit_pct = 0; + } else { + limit_pct = last_pct - + ((quota - current) * 100 / quota); + limit_pct = MAX(limit_pct, CPU_THROTTLE_PCT_MIN); + } + } else { + limit_pct = last_pct + + ((current - quota) * 100 / current); + + limit_pct = MIN(limit_pct, + DIRTYLIMIT_THROTTLE_HEAVY_WATERMARK); + } + break; + case RESTRAIN_KEEP: + default: + limit_pct = last_pct; + break; + } + + return limit_pct; +} + +static void *dirtylimit_thread(void *opaque) +{ + int cpu_index = *(int *)opaque; + uint64_t quota_dirtyrate, current_dirtyrate; + unsigned int last_pct = 0; + unsigned int pct = 0; + + rcu_register_thread(); + + quota_dirtyrate = dirtylimit_quota(cpu_index); + current_dirtyrate = dirtylimit_current(cpu_index); + + pct = dirtylimit_init_pct(quota_dirtyrate, current_dirtyrate); + + do { + trace_dirtylimit_impose(cpu_index, + quota_dirtyrate, current_dirtyrate, pct); + + last_pct = pct;
Review
Quoted 10 lines
(quoted diff) +10
-0+ if (pct == 0) { + sleep(DIRTYLIMIT_CALC_PERIOD_TIME_S); + } else { + dirtylimit_check(cpu_index, pct); + } + + quota_dirtyrate = dirtylimit_quota(cpu_index); + current_dirtyrate = dirtylimit_current(cpu_index); + + pct = dirtylimit_pct(last_pct, quota_dirtyrate, current_dirtyrate);
So what I had in mind is we can start with an extremely simple version of negative feedback system. Say, firstly each vcpu will have a simple number to sleep for some interval (this is ugly code, but just show what I meant..):
===============
accel/kvm/kvm-all.c +2 -0
@@ -2932,6 +2932,8 @@ int kvm_cpu_exec(CPUState *cpu)trace_kvm_dirty_ring_full (cpu->cpu_index);qemu_mutex_lock_iothread ();kvm_dirty_ring_reap (kvm_state); +if (dirtylimit_enabled (cpu->cpu_index) && cpu->throttle_us_per_full) +usleep (cpu->throttle_us_per_full);qemu_mutex_unlock_iothread (); ret =0 ;break ;
===============
I think this will have finer granularity when throttle (for 4096 ring size, that's per-16MB operation) than current way where we inject per-vcpu async task to sleep, like auto-converge.
Then we have the "black box" to tune this value with below input/output:
- Input: dirty rate information, same as current algo
- Output: increase/decrease of per-vcpu throttle_us_per_full above, and that's all
We can do the sampling per-second, then we keep doing it: we can have 1 thread doing per-second task collecting dirty rate information for all the vcpus, then tune that throttle_us_per_full for each of them.
The simplest linear algorithm would be as simple as (for each vcpu):
if (quota < current)
throttle_us_per_full += SOMETHING;
if (throttle_us_per_full > MAX)
throttle_us_per_full = MAX;
else
throttle_us_per_full -= SOMETHING;
if (throttle_us_per_full < 0)
throttle_us_per_full = 0;I think your algorithm is fine, but thoroughly review every single bit of it in one shot will be challenging, and it's also hard to prove every bit of the algorithm is helpful, as there're a lot of hand-made macros and state changes.
I actually tested the current algorithm of yours, the dirty rate fluctuates a bit (when I specified 200MB/s, it can go into either a few tens of MB/s or 300MB/s, normally less), neither does it respond fast (the initial throtle from 500MB/s -> 200MB/s should need 1 minute or something), so it seems not ideal anyway. In that case I prefer we start with simple.
So IMHO we can start with this simple scheme first then it'll start working with much less line of codes, afaict. With that scheme ready in the 1st or initial patches, it'll be easier to either apply any better algorithm (e.g. your current one, if you're confident with that) or other things then it'll be much easier to review too if you could consider split your patch like that.
Normally per my knowledge for the need on migration, we could consider add an integral algorithm into this linear algorithm that I said above, and it should help us reach a very stable and constant state of throttling already. But we'll need to try it out, as I never tried.
What do you think?
Signature · 1 line
Peter Xu
Re: [PATCH v9 2/3] cpu-throttle: implement vCPU throttle
Quoted 161 lines · Peter Xu
Quoted 86 lines · On Fri, Dec 03, 2021 at 09:39:46AM +0800, [email protected] wrote:
(quoted diff) +86
-0+static uint64_t dirtylimit_pct(unsigned int last_pct, + uint64_t quota, + uint64_t current) +{ + uint64_t limit_pct = 0; + RestrainPolicy policy; + bool mitigate = (quota > current) ? true : false; + + if (mitigate && ((current == 0) || + (last_pct <= DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE))) { + return 0; + } + + policy = dirtylimit_policy(last_pct, quota, current); + switch (policy) { + case RESTRAIN_SLIGHT: + /* [90, 99] */ + if (mitigate) { + limit_pct = + last_pct - DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE; + } else { + limit_pct = + last_pct + DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE; + + limit_pct = MIN(limit_pct, CPU_THROTTLE_PCT_MAX); + } + break; + case RESTRAIN_HEAVY: + /* [75, 90) */ + if (mitigate) { + limit_pct = + last_pct - DIRTYLIMIT_THROTTLE_HEAVY_STEP_SIZE; + } else { + limit_pct = + last_pct + DIRTYLIMIT_THROTTLE_HEAVY_STEP_SIZE; + + limit_pct = MIN(limit_pct, + DIRTYLIMIT_THROTTLE_SLIGHT_WATERMARK); + } + break; + case RESTRAIN_RATIO: + /* [0, 75) */ + if (mitigate) { + if (last_pct <= (((quota - current) * 100 / quota))) { + limit_pct = 0; + } else { + limit_pct = last_pct - + ((quota - current) * 100 / quota); + limit_pct = MAX(limit_pct, CPU_THROTTLE_PCT_MIN); + } + } else { + limit_pct = last_pct + + ((current - quota) * 100 / current); + + limit_pct = MIN(limit_pct, + DIRTYLIMIT_THROTTLE_HEAVY_WATERMARK); + } + break; + case RESTRAIN_KEEP: + default: + limit_pct = last_pct; + break; + } + + return limit_pct; +} + +static void *dirtylimit_thread(void *opaque) +{ + int cpu_index = *(int *)opaque; + uint64_t quota_dirtyrate, current_dirtyrate; + unsigned int last_pct = 0; + unsigned int pct = 0; + + rcu_register_thread(); + + quota_dirtyrate = dirtylimit_quota(cpu_index); + current_dirtyrate = dirtylimit_current(cpu_index); + + pct = dirtylimit_init_pct(quota_dirtyrate, current_dirtyrate); + + do { + trace_dirtylimit_impose(cpu_index, + quota_dirtyrate, current_dirtyrate, pct); + + last_pct = pct;Review
Quoted 10 lines
(quoted diff) +10
-0+ if (pct == 0) { + sleep(DIRTYLIMIT_CALC_PERIOD_TIME_S); + } else { + dirtylimit_check(cpu_index, pct); + } + + quota_dirtyrate = dirtylimit_quota(cpu_index); + current_dirtyrate = dirtylimit_current(cpu_index); + + pct = dirtylimit_pct(last_pct, quota_dirtyrate, current_dirtyrate);So what I had in mind is we can start with an extremely simple version of negative feedback system. Say, firstly each vcpu will have a simple number to sleep for some interval (this is ugly code, but just show what I meant..):
===============
accel/kvm/kvm-all.c +2
-0@@ -2932,6 +2932,8 @@ int kvm_cpu_exec(CPUState *cpu)trace_kvm_dirty_ring_full (cpu->cpu_index);qemu_mutex_lock_iothread ();kvm_dirty_ring_reap (kvm_state); +if (dirtylimit_enabled (cpu->cpu_index) && cpu->throttle_us_per_full) +usleep (cpu->throttle_us_per_full);qemu_mutex_unlock_iothread (); ret =0 ;break ;===============
I think this will have finer granularity when throttle (for 4096 ring size, that's per-16MB operation) than current way where we inject per-vcpu async task to sleep, like auto-converge.
Then we have the "black box" to tune this value with below input/output:
- Input: dirty rate information, same as current algo
- Output: increase/decrease of per-vcpu
throttle_us_per_fullabove, and that's allWe can do the sampling per-second, then we keep doing it: we can have 1 thread doing per-second task collecting dirty rate information for all the vcpus, then tune that
throttle_us_per_fullfor each of them.The simplest linear algorithm would be as simple as (for each vcpu):
if (quota < current) throttle_us_per_full += SOMETHING; if (throttle_us_per_full > MAX) throttle_us_per_full = MAX; else throttle_us_per_full -= SOMETHING; if (throttle_us_per_full < 0) throttle_us_per_full = 0;I think your algorithm is fine, but thoroughly review every single bit of it in one shot will be challenging, and it's also hard to prove every bit of the algorithm is helpful, as there're a lot of hand-made macros and state changes.
I actually tested the current algorithm of yours, the dirty rate fluctuates a bit (when I specified 200MB/s, it can go into either a few tens of MB/s or 300MB/s, normally less), neither does it respond fast (the initial throtle from 500MB/s -> 200MB/s should need 1 minute or something), so it seems not ideal anyway. In that case I prefer we start with simple.
So IMHO we can start with this simple scheme first then it'll start working with much less line of codes, afaict. With that scheme ready in the 1st or initial patches, it'll be easier to either apply any better algorithm (e.g. your current one, if you're confident with that) or other things then it'll be much easier to review too if you could consider split your patch like that.
Quoted 7 lines
Normally per my knowledge for the need on migration, we could consider add an integral algorithm into this linear algorithm that I said above, and it should help us reach a very stable and constant state of throttling already. But we'll need to try it out, as I never tried.
What do you think?
I absolutely agree with your point, negative feedback system is also what i thought in the first place, and theoretically may be the most appropriate algo to control the vcpu in a stable dirty page rate from my point of view, but at the very beginning i'm not sure the new algo of throttling can be accepted, so i adopted the exiting auto-converge algo in qemu... :). One of my purposes of posting this patchset is for the sake of RFC, and thanks Peter very much for giving the advice.
I'll try it out and see the results. If things go well, the negative feedback system to control the dirty page rate for a vcpu will be introduced next version.
Re: [PATCH v9 2/3] cpu-throttle: implement vCPU throttle
Quoted 171 lines · Hyman
Quoted 168 lines · Peter Xu
Quoted 96 lines · On Fri, Dec 03, 2021 at 09:39:46AM +0800, [email protected] wrote:
(quoted diff) +96
-0+static uint64_t dirtylimit_pct(unsigned int last_pct, + uint64_t quota, + uint64_t current) +{ + uint64_t limit_pct = 0; + RestrainPolicy policy; + bool mitigate = (quota > current) ? true : false; + + if (mitigate && ((current == 0) || + (last_pct <= DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE))) { + return 0; + } + + policy = dirtylimit_policy(last_pct, quota, current); + switch (policy) { + case RESTRAIN_SLIGHT: + /* [90, 99] */ + if (mitigate) { + limit_pct = + last_pct - DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE; + } else { + limit_pct = + last_pct + DIRTYLIMIT_THROTTLE_SLIGHT_STEP_SIZE; + + limit_pct = MIN(limit_pct, CPU_THROTTLE_PCT_MAX); + } + break; + case RESTRAIN_HEAVY: + /* [75, 90) */ + if (mitigate) { + limit_pct = + last_pct - DIRTYLIMIT_THROTTLE_HEAVY_STEP_SIZE; + } else { + limit_pct = + last_pct + DIRTYLIMIT_THROTTLE_HEAVY_STEP_SIZE; + + limit_pct = MIN(limit_pct, + DIRTYLIMIT_THROTTLE_SLIGHT_WATERMARK); + } + break; + case RESTRAIN_RATIO: + /* [0, 75) */ + if (mitigate) { + if (last_pct <= (((quota - current) * 100 / quota))) { + limit_pct = 0; + } else { + limit_pct = last_pct - + ((quota - current) * 100 / quota); + limit_pct = MAX(limit_pct, CPU_THROTTLE_PCT_MIN); + } + } else { + limit_pct = last_pct + + ((current - quota) * 100 / current); + + limit_pct = MIN(limit_pct, + DIRTYLIMIT_THROTTLE_HEAVY_WATERMARK); + } + break; + case RESTRAIN_KEEP: + default: + limit_pct = last_pct; + break; + } + + return limit_pct; +} + +static void *dirtylimit_thread(void *opaque) +{ + int cpu_index = *(int *)opaque; + uint64_t quota_dirtyrate, current_dirtyrate; + unsigned int last_pct = 0; + unsigned int pct = 0; + + rcu_register_thread(); + + quota_dirtyrate = dirtylimit_quota(cpu_index); + current_dirtyrate = dirtylimit_current(cpu_index); + + pct = dirtylimit_init_pct(quota_dirtyrate, current_dirtyrate); + + do { + trace_dirtylimit_impose(cpu_index, + quota_dirtyrate, current_dirtyrate, pct); + + last_pct = pct; + if (pct == 0) { + sleep(DIRTYLIMIT_CALC_PERIOD_TIME_S); + } else { + dirtylimit_check(cpu_index, pct); + } + + quota_dirtyrate = dirtylimit_quota(cpu_index); + current_dirtyrate = dirtylimit_current(cpu_index); + + pct = dirtylimit_pct(last_pct, quota_dirtyrate,Quoted 1 line
current_dirtyrate);So what I had in mind is we can start with an extremely simple version of negative feedback system. Say, firstly each vcpu will have a simple number to sleep for some interval (this is ugly code, but just show what I meant..):
===============
accel/kvm/kvm-all.c +2
-0@@ -2932,6 +2932,8 @@ int kvm_cpu_exec(CPUState *cpu) trace_kvm_dirty_ring_full(cpu->cpu_index); qemu_mutex_lock_iothread(); kvm_dirty_ring_reap(kvm_state); + if (dirtylimit_enabled(cpu->cpu_index) && cpu->throttle_us_per_full) + usleep(cpu->throttle_us_per_full); qemu_mutex_unlock_iothread(); ret = 0;break;
===============I think this will have finer granularity when throttle (for 4096 ring size, that's per-16MB operation) than current way where we inject per-vcpu async task to sleep, like auto-converge.
Then we have the "black box" to tune this value with below input/output:
- Input: dirty rate information, same as current algo
- Output: increase/decrease of per-vcpu
throttle_us_per_fullabove, and that's allWe can do the sampling per-second, then we keep doing it: we can have 1 thread doing per-second task collecting dirty rate information for all the vcpus, then tune that
throttle_us_per_fullfor each of them.The simplest linear algorithm would be as simple as (for each vcpu):
if (quota < current)
throttle_us_per_full+= SOMETHING;
if (throttle_us_per_full> MAX)
throttle_us_per_full= MAX;
else
throttle_us_per_full-= SOMETHING;
if (throttle_us_per_full< 0)
throttle_us_per_full= 0;I think your algorithm is fine, but thoroughly review every single bit of it in one shot will be challenging, and it's also hard to prove every bit of the algorithm is helpful, as there're a lot of hand-made macros and state changes.
I actually tested the current algorithm of yours, the dirty rate fluctuates a bit (when I specified 200MB/s, it can go into either a few tens of MB/s or 300MB/s, normally less), neither does it respond fast (the initial throtle from 500MB/s -> 200MB/s should need 1 minute or something), so it seems not ideal anyway. In that case I prefer we start with simple.
So IMHO we can start with this simple scheme first then it'll start working with much less line of codes, afaict. With that scheme ready in the 1st or initial patches, it'll be easier to either apply any better algorithm (e.g. your current one, if you're confident with that) or other things then it'll be much easier to review too if you could consider split your patch like that.
Normally per my knowledge for the need on migration, we could consider add an integral algorithm into this linear algorithm that I said above, and it should help us reach a very stable and constant state of throttling already. But we'll need to try it out, as I never tried.
Quoted 5 lines
Quoted 2 lines
What do you think?
I absolutely agree with your point, negative feedback system is also what i thought in the first place, and theoretically may be the most appropriate algo to control the vcpu in a stable dirty page rate from my point of view, but at the very beginning i'm not sure the new algo of throttling can be accepted, so i adopted the exiting auto-converge algo in qemu... :). One of my purposes of posting this patchset is for the sake of RFC, and thanks Peter very much for giving the advice.
I'll try it out and see the results. If things go well, the negative feedback system to control the dirty page rate for a vcpu will be introduced next version.
uh... "method" may be a better word to express what i mean instead of "algo" in my reply above, and the real "algo" implemented in "black box".
PATCH v9 3/3 cpus-common: implement dirty page limit on vCPU
In reply to [email protected]From: Hyman Huang(黄勇) <[email protected]>
Implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirty page rate given by user.
Introduce qmp commands "vcpu-dirty-limit", "query-vcpu-dirty-limit" to enable, disable, query dirty page limit for virtual CPU.
Meanwhile, introduce corresponding hmp commands "vcpu_dirty_limit", "info vcpu_dirty_limit" so developers can play with them easier.
--- cpus-common.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++ hmp-commands-info.hx | 13 +++++ hmp-commands.hx | 16 ++++++ include/hw/core/cpu.h | 9 +++ include/monitor/hmp.h | 2 + qapi/migration.json | 48 ++++++++++++++++ softmmu/vl.c | 1 + 7 files changed, 238 insertions(+)
cpus-common.c +149 -0
@@ -23,6 +23,14 @@#include "hw/core/cpu.h" #include "sysemu/cpus.h" #include "qemu/lockable.h" +#include "sysemu/dirtylimit.h" +#include "sysemu/cpu-throttle.h" +#include "sysemu/kvm.h" +#include "monitor/hmp.h" +#include "monitor/monitor.h" +#include "qapi/qmp/qdict.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-migration.h" static QemuMutex qemu_cpu_list_lock;static QemuCond exclusive_cond;
@@ -352,3 +360,144 @@ void process_queued_cpu_work(CPUState *cpu)qemu_mutex_unlock (&cpu->work_mutex);qemu_cond_broadcast (&qemu_work_cond); } + +void qmp_vcpu_dirty_limit (int64_t cpu_index, +bool enable, +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_is_vcpu_index_valid (cpu_index)) { +error_setg (errp,"cpu index out of range" ); +return ; + } + +if (enable) { +dirtylimit_calc (); +dirtylimit_vcpu (cpu_index, dirty_rate); + }else { +if (!dirtylimit_enabled (cpu_index)) { +error_setg (errp,"dirty page limit for CPU %ld not set" , + cpu_index); +return ; + } + +if (!dirtylimit_cancel_vcpu (cpu_index)) { +dirtylimit_calc_quit (); + } + } +} + +void hmp_vcpu_dirty_limit (Monitor *mon,const QDict *qdict) +{ +int64_t cpu_index =qdict_get_try_int (qdict,"cpu_index" ,-1 ); +int64_t dirty_rate =qdict_get_try_int (qdict,"dirty_rate" ,-1 ); +bool enable =qdict_get_bool (qdict,"enable" ); +Error *err =NULL ; + +if (enable && dirty_rate <0 ) { +monitor_printf (mon,"Enabling dirty limit requires dirty_rate set!\n" ); +return ; + } + +if (!dirtylimit_is_vcpu_index_valid (cpu_index)) { +monitor_printf (mon,"Incorrect cpu index specified!\n" ); +return ; + } + +qmp_vcpu_dirty_limit (cpu_index, enable, dirty_rate, &err); + +if (err) { +hmp_handle_error (mon, err); +return ; + } + +monitor_printf (mon,"Enabling dirty page rate limit with %" PRIi64 +" MB/s\n" , dirty_rate); + +monitor_printf (mon,"[Please use 'info vcpu_dirty_limit' to query " +"dirty limit for virtual CPU]\n" ); +} + +struct DirtyLimitInfoList *qmp_query_vcpu_dirty_limit (bool has_cpu_index, +int64_t cpu_index, +Error **errp) +{ +DirtyLimitInfo *info =NULL ; +DirtyLimitInfoList *head =NULL , **tail = &head; + +if (has_cpu_index && + (!dirtylimit_is_vcpu_index_valid (cpu_index))) { +error_setg (errp,"cpu index out of range" ); +return NULL ; + } + +if (has_cpu_index) { + info =dirtylimit_query_vcpu (cpu_index); +QAPI_LIST_APPEND (tail, info); + }else { +CPUState *cpu; +CPU_FOREACH (cpu) { +if (!cpu->unplug) { + info =dirtylimit_query_vcpu (cpu->cpu_index); +QAPI_LIST_APPEND (tail, info); + } + } + } + +return head; +} + +void hmp_info_vcpu_dirty_limit (Monitor *mon,const QDict *qdict) +{ +DirtyLimitInfoList *limit, *head, *info =NULL ; +int64_t cpu_index =qdict_get_try_int (qdict,"cpu_index" ,-1 ); +Error *err =NULL ; + +if (cpu_index >=0 && + !dirtylimit_is_vcpu_index_valid (cpu_index)) { +monitor_printf (mon,"cpu index out of range\n" ); +return ; + } + +if (cpu_index <0 ) { + info =qmp_query_vcpu_dirty_limit (false,-1 , &err); + }else { + info =qmp_query_vcpu_dirty_limit (true, cpu_index, &err); + } + +if (err) { +hmp_handle_error (mon, err); +return ; + } + + head = info; +for (limit = head; limit !=NULL ; limit = limit->next) { +monitor_printf (mon,"vcpu[%" PRIi64"], Enable: %s" , + limit->value->cpu_index, + limit->value->enable ?"true" :"false" ); +if (limit->value->enable) { +monitor_printf (mon,", limit rate %" PRIi64" (MB/s)," +" current rate %" PRIi64" (MB/s)\n" , + limit->value->limit_rate, + limit->value->current_rate); + }else { +monitor_printf (mon,"\n" ); + } + } +} + +void dirtylimit_setup (int max_cpus) +{ +if (!kvm_enabled () || !kvm_dirty_ring_enabled ()) { +return ; + } + +dirtylimit_calc_state_init (max_cpus); +dirtylimit_state_init (max_cpus); +}
hmp-commands-info.hx +13 -0
@@ -863,6 +863,19 @@ SRST Display the vcpu dirty rate information. ERST + { + .name = "vcpu_dirty_limit", + .args_type = "cpu_index:l?", + .params = "cpu_index", + .help = "show dirty page limit information", + .cmd = hmp_info_vcpu_dirty_limit, + }, + +SRST + ``info vcpu_dirty_limit`` + Display the vcpu dirty page limit information. +ERST + #if defined(TARGET_I386) { .name = "sgx",
hmp-commands.hx +16 -0
@@ -1744,3 +1744,19 @@ ERST "\n\t\t\t -b to specify dirty bitmap as method of calculation)", .cmd = hmp_calc_dirty_rate, }, + +SRST +``vcpu_dirty_limit`` + Start dirty page rate limit on a virtual CPU, the information about all the + virtual CPU dirty limit status can be observed with ``info vcpu_dirty_limit`` + command. +ERST + + { + .name = "vcpu_dirty_limit", + .args_type = "cpu_index:l,enable:b,dirty_rate:l?", + .params = "cpu_index on|off [dirty_rate]", + .help = "enable, disable dirty page rate limit on a virtual CPU" + "(dirty_rate should be specified dirty_rate if enable)", + .cmd = hmp_vcpu_dirty_limit, + },
include/hw/core/cpu.h +9 -0
@@ -881,6 +881,15 @@ void end_exclusive(void);*/ void qemu_init_vcpu (CPUState *cpu); +/** +* dirtylimit_setup: +* +* Initializes the global state of dirtylimit calculation and +* dirtylimit itself. This is prepared for vCPU dirtylimit which +* could be triggered during vm lifecycle. +*/ +void dirtylimit_setup (int max_cpus); +#define SSTEP_ENABLE 0x1/* Enable simulated HW single stepping */ #define SSTEP_NOIRQ 0x2/* Do not use IRQ while single stepping */ #define SSTEP_NOTIMER 0x4/* Do not Timers while single stepping */
include/monitor/hmp.h +2 -0
@@ -131,6 +131,8 @@ void hmp_replay_delete_break(Monitor *mon, const QDict *qdict);void hmp_replay_seek (Monitor *mon,const QDict *qdict);void hmp_info_dirty_rate (Monitor *mon,const QDict *qdict);void hmp_calc_dirty_rate (Monitor *mon,const QDict *qdict); +void hmp_info_vcpu_dirty_limit (Monitor *mon,const QDict *qdict); +void hmp_vcpu_dirty_limit (Monitor *mon,const QDict *qdict);void hmp_human_readable_text_helper (Monitor *mon,HumanReadableText *(*qmp_handler)(Error **));
qapi/migration.json +48 -0
54 lines not on this page · raw message
softmmu/vl.c +1 -0
@@ -3777,5 +3777,6 @@ void qemu_init(int argc, char **argv, char **envp)qemu_init_displays ();accel_setup_post (current_machine);os_setup_post (); +dirtylimit_setup (current_machine->smp.max_cpus);resume_mux_open (); }
Signature · 1 line
1.8.3.1
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 6 lines · [email protected] writes:
From: Hyman Huang(黄勇) <[email protected]>
Implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirty page rate given by user.
Quoted 7 lines
Introduce qmp commands "vcpu-dirty-limit", "query-vcpu-dirty-limit" to enable, disable, query dirty page limit for virtual CPU.
Meanwhile, introduce corresponding hmp commands "
vcpu_dirty_limit", "infovcpu_dirty_limit" so developers can play with them easier.Signed-off-by Hyman Huang(黄勇) <[email protected]>
[...]
I see you replaced the interface. Back to square one...
Quoted 25 lines
qapi/migration.json +17
-0@@ -1872,6 +1872,54 @@ 'current-rate': 'int64' } } ## +# @vcpu-dirty-limit: +# +# Set or cancel the upper limit of dirty page rate for a 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. +# +# @enable: true to enable, false to disable. +# +# @dirty-rate: upper limit of dirty page rate for virtual CPU. +# +# Since: 7.0 +# +# Example:
qapi/migration.json line 1901
Quoted 10 lines
qapi/migration.json +10
-0+# {"execute": "vcpu-dirty-limit"} +# "arguments": { "cpu-index": 0, +# "enable": true, +# "dirty-rate": 200 } } +# +## +{ 'command': 'vcpu-dirty-limit', + 'data': { 'cpu-index': 'int', + 'enable': 'bool', + 'dirty-rate': 'uint64'} }
When @enable is false, @dirty-rate makes no sense and is not used (I checked the code), but users have to specify it anyway. That's bad design.
Better: drop @enable, make @dirty-rate optional, present means enable, absent means disable.
Quoted 9 lines
qapi/migration.json +9
-0+ +## +# @query-vcpu-dirty-limit: +# +# Returns information about the virtual CPU dirty limit status. +# +# @cpu-index: index of the virtual CPU to query, if not specified, all +# virtual CPUs will be queried. +#
qapi/migration.json line 1920
Quoted 10 lines
qapi/migration.json +10
-0+# Since: 7.0 +# +# Example: +# {"execute": "query-vcpu-dirty-limit"} +# "arguments": { "cpu-index": 0 } } +# +## +{ 'command': 'query-vcpu-dirty-limit', + 'data': { '*cpu-index': 'int' }, + 'returns': [ 'DirtyLimitInfo' ] }
Why would anyone ever want to specify @cpu-index? Output isn't that large even if you have a few hundred CPUs.
Let's keep things simple and drop the parameter.
Quoted 16 lines
qapi/migration.json +2
-0+ +## # @snapshot-save: # # Save a VM snapshotsoftmmu/vl.c +1
-0@@ -3777,5 +3777,6 @@ void qemu_init(int argc, char **argv, char **envp)qemu_init_displays ();accel_setup_post (current_machine);os_setup_post (); +dirtylimit_setup (current_machine->smp.max_cpus);resume_mux_open (); }
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 60 lines · Markus Armbruster
Quoted 6 lines · [email protected] writes:
From: Hyman Huang(黄勇) <[email protected]>
Implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirty page rate given by user.
Quoted 7 lines
Introduce qmp commands "vcpu-dirty-limit", "query-vcpu-dirty-limit" to enable, disable, query dirty page limit for virtual CPU.
Meanwhile, introduce corresponding hmp commands "
vcpu_dirty_limit", "infovcpu_dirty_limit" so developers can play with them easier.Signed-off-by Hyman Huang(黄勇) <[email protected]>[...]
I see you replaced the interface. Back to square one...
Quoted 25 lines
qapi/migration.json +17
-0@@ -1872,6 +1872,54 @@ 'current-rate': 'int64' } } ## +# @vcpu-dirty-limit: +# +# Set or cancel the upper limit of dirty page rate for a 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. +# +# @enable: true to enable, false to disable. +# +# @dirty-rate: upper limit of dirty page rate for virtual CPU. +# +# Since: 7.0 +# +# Example:qapi/migration.json line 1901
Quoted 10 lines
qapi/migration.json +10
-0+# {"execute": "vcpu-dirty-limit"} +# "arguments": { "cpu-index": 0, +# "enable": true, +# "dirty-rate": 200 } } +# +## +{ 'command': 'vcpu-dirty-limit', + 'data': { 'cpu-index': 'int', + 'enable': 'bool', + 'dirty-rate': 'uint64'} }When @enable is false, @dirty-rate makes no sense and is not used (I checked the code), but users have to specify it anyway. That's bad design.
Quoted 2 lines
Better: drop @enable, make @dirty-rate optional, present means enable, absent means disable.
Uh, if we drop @enable, enabling dirty limit should be like:
vcpu-dirty-limit cpu-index=0 dirty-rate=1000
And disabling dirty limit like:
vcpu-dirty-limit cpu-index=0
For disabling case, there is no hint of disabling in command "vcpu-dirty-limit".
How about make @dirty-rate optional, when enable dirty limit, it should present, ignored otherwise?
Quoted 24 lines
Quoted 10 lines
qapi/migration.json +9
-0+ +## +# @query-vcpu-dirty-limit: +# +# Returns information about the virtual CPU dirty limit status. +# +# @cpu-index: index of the virtual CPU to query, if not specified, all +# virtual CPUs will be queried. +#qapi/migration.json line 1920
Quoted 10 lines
qapi/migration.json +10
-0+# Since: 7.0 +# +# Example: +# {"execute": "query-vcpu-dirty-limit"} +# "arguments": { "cpu-index": 0 } } +# +## +{ 'command': 'query-vcpu-dirty-limit', + 'data': { '*cpu-index': 'int' }, + 'returns': [ 'DirtyLimitInfo' ] }Why would anyone ever want to specify @cpu-index? Output isn't that large even if you have a few hundred CPUs.
Quoted 1 line
Let's keep things simple and drop the parameter.
Ok, this make things simple.
Quoted 18 lines
Quoted 17 lines
qapi/migration.json +2
-0+ +## # @snapshot-save: # # Save a VM snapshotsoftmmu/vl.c +1
-0@@ -3777,5 +3777,6 @@ void qemu_init(int argc, char **argv, char **envp)qemu_init_displays ();accel_setup_post (current_machine);os_setup_post (); +dirtylimit_setup (current_machine->smp.max_cpus);resume_mux_open (); }
Signature · 3 lines
Best regard Hyman Huang(黄勇)
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 67 lines · Hyman Huang
Quoted 59 lines · Markus Armbruster
Quoted 6 lines · [email protected] writes:
From: Hyman Huang(黄勇) <[email protected]>
Implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirty page rate given by user.
Quoted 7 lines
Introduce qmp commands "vcpu-dirty-limit", "query-vcpu-dirty-limit" to enable, disable, query dirty page limit for virtual CPU.
Meanwhile, introduce corresponding hmp commands "
vcpu_dirty_limit", "infovcpu_dirty_limit" so developers can play with them easier.Signed-off-by Hyman Huang(黄勇) <[email protected]>[...]
I see you replaced the interface. Back to square one...
Quoted 24 lines
qapi/migration.json +17
-0@@ -1872,6 +1872,54 @@ 'current-rate': 'int64' } } ## +# @vcpu-dirty-limit: +# +# Set or cancel the upper limit of dirty page rate for a 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. +# +# @enable: true to enable, false to disable. +# +# @dirty-rate: upper limit of dirty page rate for virtual CPU. +# +# Since: 7.0 +# +# Example:qapi/migration.json line 1900
Quoted 10 lines
qapi/migration.json +10
-0+# {"execute": "vcpu-dirty-limit"} +# "arguments": { "cpu-index": 0, +# "enable": true, +# "dirty-rate": 200 } } +# +## +{ 'command': 'vcpu-dirty-limit', + 'data': { 'cpu-index': 'int', + 'enable': 'bool', + 'dirty-rate': 'uint64'} }When @enable is false, @dirty-rate makes no sense and is not used (I checked the code), but users have to specify it anyway. That's bad design.
Quoted 2 lines
Better: drop @enable, make @dirty-rate optional, present means enable, absent means disable.
Uh, if we drop @enable, enabling dirty limit should be like:
vcpu-dirty-limit cpu-index=0 dirty-rate=1000
Quoted 8 lines
And disabling dirty limit like:
vcpu-dirty-limit cpu-index=0For disabling case, there is no hint of disabling in command "vcpu-dirty-limit".
How about make @dirty-rate optional, when enable dirty limit, it should present, ignored otherwise?
Sounds good, I think we can make both "enable" and "dirty-rate" optional.
To turn it on we either use "enable=true,dirty-rate=XXX" or "dirty-rate=XXX".
To turn it off we use "enable=false".
Quoted 25 lines
Quoted 25 lines
Quoted 11 lines
qapi/migration.json +9
-0+ +## +# @query-vcpu-dirty-limit: +# +# Returns information about the virtual CPU dirty limit status. +# +# @cpu-index: index of the virtual CPU to query, if not specified, all +# virtual CPUs will be queried. +#qapi/migration.json line 1920
Quoted 10 lines
qapi/migration.json +10
-0+# Since: 7.0 +# +# Example: +# {"execute": "query-vcpu-dirty-limit"} +# "arguments": { "cpu-index": 0 } } +# +## +{ 'command': 'query-vcpu-dirty-limit', + 'data': { '*cpu-index': 'int' }, + 'returns': [ 'DirtyLimitInfo' ] }Why would anyone ever want to specify @cpu-index? Output isn't that large even if you have a few hundred CPUs.
Quoted 2 lines
Quoted 1 line
Let's keep things simple and drop the parameter.
Ok, this make things simple.
I found that it'll be challenging for any human being to identify "whether he/she has turned throttle off for all vcpus".. I think that could be useful when we finally decided to cancel current migration.
I thought about adding a "global=on/off" flag, but instead can we just return the vcpu info for the ones that enabled the per-vcpu throttling? For anyone who wants to read all vcpu dirty information he/she can use calc-dirty-rate.
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 74 lines · Peter Xu
Quoted 73 lines · Hyman Huang
Quoted 59 lines · Markus Armbruster
Quoted 6 lines · [email protected] writes:
From: Hyman Huang(黄勇) <[email protected]>
Implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirty page rate given by user.
Quoted 7 lines
Introduce qmp commands "vcpu-dirty-limit", "query-vcpu-dirty-limit" to enable, disable, query dirty page limit for virtual CPU.
Meanwhile, introduce corresponding hmp commands "
vcpu_dirty_limit", "infovcpu_dirty_limit" so developers can play with them easier.Signed-off-by Hyman Huang(黄勇) <[email protected]>[...]
I see you replaced the interface. Back to square one...
Quoted 24 lines
qapi/migration.json +17
-0@@ -1872,6 +1872,54 @@ 'current-rate': 'int64' } } ## +# @vcpu-dirty-limit: +# +# Set or cancel the upper limit of dirty page rate for a 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. +# +# @enable: true to enable, false to disable. +# +# @dirty-rate: upper limit of dirty page rate for virtual CPU. +# +# Since: 7.0 +# +# Example:qapi/migration.json line 1900
Quoted 10 lines
qapi/migration.json +10
-0+# {"execute": "vcpu-dirty-limit"} +# "arguments": { "cpu-index": 0, +# "enable": true, +# "dirty-rate": 200 } } +# +## +{ 'command': 'vcpu-dirty-limit', + 'data': { 'cpu-index': 'int', + 'enable': 'bool', + 'dirty-rate': 'uint64'} }When @enable is false, @dirty-rate makes no sense and is not used (I checked the code), but users have to specify it anyway. That's bad design.
Quoted 2 lines
Better: drop @enable, make @dirty-rate optional, present means enable, absent means disable.
Uh, if we drop @enable, enabling dirty limit should be like:
vcpu-dirty-limit cpu-index=0 dirty-rate=1000And disabling dirty limit like:
vcpu-dirty-limit cpu-index=0For disabling case, there is no hint of disabling in command "vcpu-dirty-limit".
Quoted 7 lines
Quoted 2 lines
How about make @dirty-rate optional, when enable dirty limit, it should present, ignored otherwise?
Sounds good, I think we can make both "enable" and "dirty-rate" optional.
To turn it on we either use "enable=true,dirty-rate=XXX" or "dirty-rate=XXX" > To turn it off we use "enable=false".
Indeed, this make things more convenient.
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 11 lines
qapi/migration.json +9
-0+ +## +# @query-vcpu-dirty-limit: +# +# Returns information about the virtual CPU dirty limit status. +# +# @cpu-index: index of the virtual CPU to query, if not specified, all +# virtual CPUs will be queried. +#qapi/migration.json line 1920
Quoted 10 lines
qapi/migration.json +10
-0+# Since: 7.0 +# +# Example: +# {"execute": "query-vcpu-dirty-limit"} +# "arguments": { "cpu-index": 0 } } +# +## +{ 'command': 'query-vcpu-dirty-limit', + 'data': { '*cpu-index': 'int' }, + 'returns': [ 'DirtyLimitInfo' ] }Why would anyone ever want to specify @cpu-index? Output isn't that large even if you have a few hundred CPUs.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Let's keep things simple and drop the parameter.
Ok, this make things simple.
I found that it'll be challenging for any human being to identify "whether he/she has turned throttle off for all vcpus".. I think that could be useful when we finally decided to cancel current migration.
That's question, how about adding an optional argument "global" and making "cpu-index", "enable", "dirty-rate" all optional in "vcpu-dirty-limit", keeping the "cpu-index" and "global" options mutually exclusive? { 'command': 'vcpu-dirty-limit',
'data': { '*cpu-index': 'int',
'*global': 'bool'
'*enable': 'bool',
'*dirty-rate': 'uint64'} }In the case of enabling all vcpu throttle:
Either use "global=true,enable=true,dirty-rate=XXX" or "global=true,dirty-rate=XXX"
In the case of disabling all vcpu throttle:
use "global=true,enable=false,dirty-rate=XXX"
In other case, we pass the same option just like what we did for specified vcpu throttle before.
Quoted 5 lines
I thought about adding a "global=on/off" flag, but instead can we just return the vcpu info for the ones that enabled the per-vcpu throttling? For anyone who wants to read all vcpu dirty information he/she can use calc-dirty-rate.
Ok, I'll pick up this advice next version.
Quoted 2 lines
Thanks,
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 15 lines · Hyman
Quoted 3 lines
I found that it'll be challenging for any human being to identify "whether he/she has turned throttle off for all vcpus".. I think that could be useful when we finally decided to cancel current migration.
That's question, how about adding an optional argument "global" and making "cpu-index", "enable", "dirty-rate" all optional in "vcpu-dirty-limit", keeping the "cpu-index" and "global" options mutually exclusive? { 'command': 'vcpu-dirty-limit',
'data': { '*cpu-index': 'int','*global': 'bool' '*enable': 'bool', '*dirty-rate': 'uint64'} }In the case of enabling all vcpu throttle:
Either use "global=true,enable=true,dirty-rate=XXX" or "global=true,dirty-rate=XXX"
Quoted 5 lines
In the case of disabling all vcpu throttle:
use "global=true,enable=false,dirty-rate=XXX"In other case, we pass the same option just like what we did for specified vcpu throttle before.
Could we merge "cpu-index" and "global" somehow? They're mutual exclusive.
For example, merge them into one "vcpu" parameter, "vcpu=all" means global, "vcpu=1" means vcpu 1. But then we'll need to make it a string.
Signature · 1 line
Peter Xu
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 26 lines · Peter Xu
Quoted 15 lines · Hyman
Quoted 3 lines
I found that it'll be challenging for any human being to identify "whether he/she has turned throttle off for all vcpus".. I think that could be useful when we finally decided to cancel current migration.
That's question, how about adding an optional argument "global" and making "cpu-index", "enable", "dirty-rate" all optional in "vcpu-dirty-limit", keeping the "cpu-index" and "global" options mutually exclusive? { 'command': 'vcpu-dirty-limit',
'data': { '*cpu-index': 'int','*global': 'bool' '*enable': 'bool', '*dirty-rate': 'uint64'} }In the case of enabling all vcpu throttle:
Either use "global=true,enable=true,dirty-rate=XXX" or "global=true,dirty-rate=XXX"Quoted 5 lines
In the case of disabling all vcpu throttle:
use "global=true,enable=false,dirty-rate=XXX"In other case, we pass the same option just like what we did for specified vcpu throttle before.
Could we merge "cpu-index" and "global" somehow? They're mutual exclusive. > For example, merge them into one "vcpu" parameter, "vcpu=all" means global, "vcpu=1" means vcpu 1. But then we'll need to make it a string. Ok, sound good
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
In reply to [email protected]Quoted 11 lines · On Fri, Dec 03, 2021 at 09:39:47AM +0800, [email protected] wrote:
From: Hyman Huang(黄勇) <[email protected]>
Implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirty page rate given by user.
Introduce qmp commands "vcpu-dirty-limit", "query-vcpu-dirty-limit" to enable, disable, query dirty page limit for virtual CPU.
Meanwhile, introduce corresponding hmp commands "
vcpu_dirty_limit", "infovcpu_dirty_limit" so developers can play with them easier.
Thanks. Even if I start to use qmp-shell more recently but still in some case where only hmp is specified this could still be handy.
Quoted 15 lines
cpus-common.c +15
-0+void qmp_vcpu_dirty_limit (int64_t cpu_index, +bool enable, +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_is_vcpu_index_valid (cpu_index)) { +error_setg (errp,"cpu index out of range" ); +return ; + }
cpus-common.c void process_queued_cpu_work(CPUState *cpu) · line 388
Quoted 10 lines
cpus-common.c +10
-0+ +if (enable) { +dirtylimit_calc (); +dirtylimit_vcpu (cpu_index, dirty_rate); + }else { +if (!dirtylimit_enabled (cpu_index)) { +error_setg (errp,"dirty page limit for CPU %ld not set" , + cpu_index); +return ; + }
We don't need to fail the user for enable=off even if vcpu is not throttled, imho.
Quoted 6 lines
cpus-common.c +6
-0+ +if (!dirtylimit_cancel_vcpu (cpu_index)) { +dirtylimit_calc_quit (); + } + } +}
[...]
Quoted 13 lines
cpus-common.c +13
-0+struct DirtyLimitInfoList *qmp_query_vcpu_dirty_limit (bool has_cpu_index, +int64_t cpu_index, +Error **errp) +{ +DirtyLimitInfo *info =NULL ; +DirtyLimitInfoList *head =NULL , **tail = &head; + +if (has_cpu_index && + (!dirtylimit_is_vcpu_index_valid (cpu_index))) { +error_setg (errp,"cpu index out of range" ); +return NULL ; + } +
cpus-common.c void process_queued_cpu_work(CPUState *cpu) · line 449
Quoted 10 lines
cpus-common.c +10
-0+if (has_cpu_index) { + info =dirtylimit_query_vcpu (cpu_index); +QAPI_LIST_APPEND (tail, info); + }else { +CPUState *cpu; +CPU_FOREACH (cpu) { +if (!cpu->unplug) { + info =dirtylimit_query_vcpu (cpu->cpu_index); +QAPI_LIST_APPEND (tail, info); + }
There're special handling for unplug in a few places. Could you explain why? E.g. if the vcpu is unplugged then dirty rate is zero, then it seems fine to even keep it there?
Quoted 5 lines
cpus-common.c +5
-0+ } + } + +return head; +}
Signature · 1 line
Peter Xu
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 36 lines · Peter Xu
Quoted 11 lines · On Fri, Dec 03, 2021 at 09:39:47AM +0800, [email protected] wrote:
From: Hyman Huang(黄勇) <[email protected]>
Implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirty page rate given by user.
Introduce qmp commands "vcpu-dirty-limit", "query-vcpu-dirty-limit" to enable, disable, query dirty page limit for virtual CPU.
Meanwhile, introduce corresponding hmp commands "
vcpu_dirty_limit", "infovcpu_dirty_limit" so developers can play with them easier.Thanks. Even if I start to use qmp-shell more recently but still in some case where only hmp is specified this could still be handy.
Quoted 20 lines
cpus-common.c +20
-0+void qmp_vcpu_dirty_limit (int64_t cpu_index, +bool enable, +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_is_vcpu_index_valid (cpu_index)) { +error_setg (errp,"cpu index out of range" ); +return ; + } + +if (enable) { +dirtylimit_calc (); +dirtylimit_vcpu (cpu_index, dirty_rate); + }else {
Quoted 8 lines
cpus-common.c void process_queued_cpu_work(CPUState *cpu) · line 388
Quoted 5 lines
cpus-common.c +5
-0+if (!dirtylimit_enabled (cpu_index)) { +error_setg (errp,"dirty page limit for CPU %ld not set" , + cpu_index); +return ; + }We don't need to fail the user for enable=off even if vcpu is not throttled, imho.
Ok.
Quoted 30 lines
Quoted 7 lines
cpus-common.c +6
-0+ +if (!dirtylimit_cancel_vcpu (cpu_index)) { +dirtylimit_calc_quit (); + } + } +}[...]
Quoted 20 lines
cpus-common.c +20
-0+struct DirtyLimitInfoList *qmp_query_vcpu_dirty_limit (bool has_cpu_index, +int64_t cpu_index, +Error **errp) +{ +DirtyLimitInfo *info =NULL ; +DirtyLimitInfoList *head =NULL , **tail = &head; + +if (has_cpu_index && + (!dirtylimit_is_vcpu_index_valid (cpu_index))) { +error_setg (errp,"cpu index out of range" ); +return NULL ; + } + +if (has_cpu_index) { + info =dirtylimit_query_vcpu (cpu_index); +QAPI_LIST_APPEND (tail, info); + }else { +CPUState *cpu; +CPU_FOREACH (cpu) { +if (!cpu->unplug) {
Quoted 8 lines
cpus-common.c void process_queued_cpu_work(CPUState *cpu) · line 449
Quoted 3 lines
cpus-common.c +3
-0+ info =dirtylimit_query_vcpu (cpu->cpu_index); +QAPI_LIST_APPEND (tail, info); + }There're special handling for unplug in a few places. Could you explain why? E.g. if the vcpu is unplugged then dirty rate is zero, then it seems fine to even keep it there?
The dirty limit logic only allow plugged vcpu to be enabled throttle, so
that the "dirtylimit-{cpu-index}" thread don't need to be forked and we can save the overhead. So in query logic we just filter the unplugged vcpu.
Another reason is that i thought it could make user confused when we return the unplugged vcpu dirtylimit info. Uh, in most time of vm lifecycle, hotplugging vcpu may never happen.
Quoted 6 lines
Quoted 5 lines
cpus-common.c +5
-0+ } + } + +return head; +}
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 11 lines · Hyman
Quoted 11 lines
Quoted 10 lines
cpus-common.c +10
-0+if (has_cpu_index) { + info =dirtylimit_query_vcpu (cpu_index); +QAPI_LIST_APPEND (tail, info); + }else { +CPUState *cpu; +CPU_FOREACH (cpu) { +if (!cpu->unplug) { + info =dirtylimit_query_vcpu (cpu->cpu_index); +QAPI_LIST_APPEND (tail, info); + }
Quoted 6 lines
Quoted 4 lines
There're special handling for unplug in a few places. Could you explain why? E.g. if the vcpu is unplugged then dirty rate is zero, then it seems fine to even keep it there?
The dirty limit logic only allow plugged vcpu to be enabled throttle, sothat the "dirtylimit-{cpu-index}" thread don't need to be forked and we can save the overhead. So in query logic we just filter the unplugged vcpu.
I've commented similarly in the other thread - please consider not using NVCPU threads only for vcpu throttling, irrelevant of vcpu hot plug/unplug.
Per-vcpu throttle is totally not a cpu intensive workload, 1 thread should be enough globally, imho.
A guest with hundreds of vcpus are becoming more common, we shouldn't waste OS thread resources just for this.
Quoted 4 lines
Another reason is that i thought it could make user confused when we return the unplugged vcpu dirtylimit info. Uh, in most time of vm lifecycle, hotplugging vcpu may never happen.
I just think if plug/unplug does not affect the throttle logic then we should treat them the same, it avoids unnecessary special care on those vcpus too.
Signature · 1 line
Peter Xu
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 19 lines · Peter Xu
Quoted 11 lines · Hyman
Quoted 11 lines
Quoted 10 lines
cpus-common.c +10
-0+if (has_cpu_index) { + info =dirtylimit_query_vcpu (cpu_index); +QAPI_LIST_APPEND (tail, info); + }else { +CPUState *cpu; +CPU_FOREACH (cpu) { +if (!cpu->unplug) { + info =dirtylimit_query_vcpu (cpu->cpu_index); +QAPI_LIST_APPEND (tail, info); + }Quoted 6 lines
Quoted 4 lines
There're special handling for unplug in a few places. Could you explain why? E.g. if the vcpu is unplugged then dirty rate is zero, then it seems fine to even keep it there?
The dirty limit logic only allow plugged vcpu to be enabled throttle, sothat the "dirtylimit-{cpu-index}" thread don't need to be forked and we can save the overhead. So in query logic we just filter the unplugged vcpu.
Quoted 9 lines
I've commented similarly in the other thread - please consider not using NVCPU threads only for vcpu throttling, irrelevant of vcpu hot plug/unplug.
Per-vcpu throttle is totally not a cpu intensive workload, 1 thread should be enough globally, imho.
A guest with hundreds of vcpus are becoming more common, we shouldn't waste OS thread resources just for this.
Ok, i'll try this out next version
Quoted 8 lines
Quoted 4 lines
Another reason is that i thought it could make user confused when we return the unplugged vcpu dirtylimit info. Uh, in most time of vm lifecycle, hotplugging vcpu may never happen.
I just think if plug/unplug does not affect the throttle logic then we should treat them the same, it avoids unnecessary special care on those vcpus too.
Indeed, i'm struggling too :), i'll remove the plug/unplug logic the next version.
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
In reply to [email protected]Quoted 9 lines · On Fri, Dec 03, 2021 at 09:39:47AM +0800, [email protected] wrote:
cpus-common.c +9
-0+void dirtylimit_setup (int max_cpus) +{ +if (!kvm_enabled () || !kvm_dirty_ring_enabled ()) { +return ; + } + +dirtylimit_calc_state_init (max_cpus); +dirtylimit_state_init (max_cpus); +}
[...]
softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 3781
Quoted 10 lines
softmmu/vl.c +1
-0@@ -3777,5 +3777,6 @@ void qemu_init(int argc, char **argv, char **envp)qemu_init_displays ();accel_setup_post (current_machine);os_setup_post (); +dirtylimit_setup (current_machine->smp.max_cpus);resume_mux_open ();
Can we do the init only when someone enables it? We could also do proper free() for the structs when it's globally turned off.
Signature · 1 line
Peter Xu
Re: [PATCH v9 3/3] cpus-common: implement dirty page limit on vCPU
Quoted 13 lines · Peter Xu
Quoted 9 lines · On Fri, Dec 03, 2021 at 09:39:47AM +0800, [email protected] wrote:
cpus-common.c +9
-0+void dirtylimit_setup (int max_cpus) +{ +if (!kvm_enabled () || !kvm_dirty_ring_enabled ()) { +return ; + } + +dirtylimit_calc_state_init (max_cpus); +dirtylimit_state_init (max_cpus); +}[...]
Quoted 13 lines
softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 3781
Quoted 10 lines
softmmu/vl.c +1
-0@@ -3777,5 +3777,6 @@ void qemu_init(int argc, char **argv, char **envp)qemu_init_displays ();accel_setup_post (current_machine);os_setup_post (); +dirtylimit_setup (current_machine->smp.max_cpus);resume_mux_open ();Can we do the init only when someone enables it? We could also do proper
free()for the structs when it's globally turned off.
Yes, i'll try this next version