support dirty restraint on vCPU
v3 cover support dirty restraint on vCPU
From: Hyman Huang(黄勇) <[email protected]>
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 limit on vCPU
cpus-common.c | 41 ++++++ include/exec/memory.h | 5 +- include/hw/core/cpu.h | 9 ++ include/sysemu/cpu-throttle.h | 23 +++ include/sysemu/dirtylimit.h | 44 ++++++ migration/dirtyrate.c | 139 ++++++++++++++++-- migration/dirtyrate.h | 2 + qapi/misc.json | 39 ++++++ softmmu/cpu-throttle.c | 319 ++++++++++++++++++++++++++++++++++++++++++ softmmu/trace-events | 5 + softmmu/vl.c | 1 + 11 files changed, 616 insertions(+), 11 deletions(-) create mode 100644 include/sysemu/dirtylimit.h
Signature · 1 line
1.8.3.1
PATCH v3 1/3 migration/dirtyrate: implement vCPU dirtyrate calculation periodically
From: Hyman Huang(黄勇) <[email protected]>
introduce the third method GLOBAL_DIRTY_RESTRAINT 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 | 139 ++++++++++++++++++++++++++++++++++++++++---- migration/dirtyrate.h | 2 + 4 files changed, 179 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 +129 -10
157 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
PATCH v3 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 | 23 +++ softmmu/cpu-throttle.c | 319 ++++++++++++++++++++++++++++++++++++++++++ softmmu/trace-events | 5 + 3 files changed, 347 insertions(+)
include/sysemu/cpu-throttle.h +23 -0
@@ -65,4 +65,27 @@ bool cpu_throttle_active(void);*/ int cpu_throttle_get_percentage (void ); +/** +* 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_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 */
softmmu/cpu-throttle.c +319 -0
331 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
PATCH v3 3/3 cpus-common: implement dirty 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 dirtyrate given by user.
introduce qmp commands set-dirty-limit/cancel-dirty-limit to set/cancel dirty limit on vCPU.
--- cpus-common.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/hw/core/cpu.h | 9 +++++++++ qapi/misc.json | 39 +++++++++++++++++++++++++++++++++++++++ softmmu/vl.c | 1 + 4 files changed, 90 insertions(+)
cpus-common.c +41 -0
@@ -23,6 +23,11 @@#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 "qapi/error.h" +#include "qapi/qapi-commands-misc.h" static QemuMutex qemu_cpu_list_lock;static QemuCond exclusive_cond;
@@ -352,3 +357,39 @@ void process_queued_cpu_work(CPUState *cpu)qemu_mutex_unlock (&cpu->work_mutex);qemu_cond_broadcast (&qemu_work_cond); } + +void qmp_set_dirty_limit (int64_t idx, +uint64_t dirtyrate, +Error **errp) +{ +if (!kvm_dirty_ring_enabled ()) { +error_setg (errp,"dirty ring not enable, needed by dirty restraint!" ); +return ; + } + +dirtylimit_calc (); +dirtylimit_vcpu (idx, dirtyrate); +} + +void qmp_cancel_dirty_limit (int64_t idx, +Error **errp) +{ +if (!kvm_dirty_ring_enabled ()) { +error_setg (errp,"dirty ring not enable, needed by dirty restraint!" ); +return ; + } + +if (unlikely (!dirtylimit_cancel_vcpu (idx))) { +dirtylimit_calc_quit (); + } +} + +void dirtylimit_setup (int max_cpus) +{ +if (!kvm_dirty_ring_enabled ()) { +return ; + } + +dirtylimit_calc_state_init (max_cpus); +dirtylimit_state_init (max_cpus); +}
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 */
qapi/misc.json +39 -0
@@ -527,3 +527,42 @@ 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'], 'allow-preconfig': true } + +## +# @set-dirty-limit: +# +# This command could be used to cap the vCPU memory load, which is also +# refered as dirtyrate. One should use "calc-dirty-rate" with "dirty-ring" +# and to calculate vCPU dirtyrate and query it with "query-dirty-rate". +# Once getting the vCPU current dirtyrate, "set-dirty-limit" can be used +# to set the upper limit of dirtyrate for the interested vCPU. +# +# @idx: vCPU index to set dirtylimit. +# +# @dirtyrate: upper limit of drityrate the specified vCPU could reach (MB/s) +# +# Since: 6.3 +# +# Example: +# {"execute": "set-dirty-limit"} +# "arguments": { "idx": 0, +# "dirtyrate": 200 } } +# +## +{ 'command': 'set-dirty-limit', + 'data': { 'idx': 'int', 'dirtyrate': 'uint64' } } + +## +# @cancel-dirty-limit: +# +# @idx: vCPU index to canceled the dirtylimit +# +# Since: 6.3 +# +# Example: +# {"execute": "cancel-dirty-limit"} +# "arguments": { "idx": 0 } } +# +## +{ 'command': 'cancel-dirty-limit', + 'data': { 'idx': 'int' } }
softmmu/vl.c +1 -0
@@ -3776,5 +3776,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 v3 3/3] cpus-common: implement dirty limit on vCPU
Quoted 8 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 dirtyrate given by user.
introduce qmp commands set-dirty-limit/cancel-dirty-limit to set/cancel dirty limit on vCPU.
Please start sentences with a capital letter.
Quoted 2 lines
Signed-off-by Hyman Huang(黄勇) <[email protected]>
[...]
Quoted 7 lines
qapi/misc.json +0
-0@@ -527,3 +527,42 @@ 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'],
qapi/misc.json line 538
Quoted 10 lines
qapi/misc.json +9
-0'allow-preconfig': true } + +## +# @set-dirty-limit: +# +# This command could be used to cap the vCPU memory load, which is also +# refered as dirtyrate. One should use "calc-dirty-rate" with "dirty-ring" +# and to calculate vCPU dirtyrate and query it with "query-dirty-rate". +# Once getting the vCPU current dirtyrate, "set-dirty-limit" can be used +# to set the upper limit of dirtyrate for the interested vCPU.
"dirtyrate" is not a word. Let's spell it "dirty page rate", for consistency with the documentation in migration.json.
Regarding "One should use ...": sounds like you have to run calc-dirty-rate with argument @mode set to @dirty-ring before this command. Correct? What happens when you don't? set-dirty-limit fails?
Do you also have to run query-dirty-rate before this command?
Speaking of migration.json: should these commands be defined there, next to calc-dirty-rate and query-dirty-rate?
qapi/misc.json line 542
Quoted 4 lines
qapi/misc.json +4
-0+# +# @idx: vCPU index to set dirtylimit. +# +# @dirtyrate: upper limit of drityrate the specified vCPU could reach (MB/s)
Typo "drityrate".
Suggest "upper limit for the specified vCPU's dirty page rate (MB/s)".
Quoted 37 lines
qapi/misc.json +26
-0+# +# Since: 6.3 +# +# Example: +# {"execute": "set-dirty-limit"} +# "arguments": { "idx": 0, +# "dirtyrate": 200 } } +# +## +{ 'command': 'set-dirty-limit', + 'data': { 'idx': 'int', 'dirtyrate': 'uint64' } } + +## +# @cancel-dirty-limit: +# +# @idx: vCPU index to canceled the dirtylimit +# +# Since: 6.3 +# +# Example: +# {"execute": "cancel-dirty-limit"} +# "arguments": { "idx": 0 } } +# +## +{ 'command': 'cancel-dirty-limit', + 'data': { 'idx': 'int' } }softmmu/vl.c +1
-0@@ -3776,5 +3776,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 v3 3/3] cpus-common: implement dirty limit on vCPU
Quoted 4 lines · Markus Armbruster
Quoted 2 lines · [email protected] writes:
From: Hyman Huang(黄勇) <[email protected]>
Quoted 9 lines
Quoted 6 lines
implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirtyrate given by user.
introduce qmp commands set-dirty-limit/cancel-dirty-limit to set/cancel dirty limit on vCPU.
Please start sentences with a capital letter.
Ok,i'll check the syntax problem next version.
Quoted 17 lines
Quoted 2 lines
Signed-off-by Hyman Huang(黄勇) <[email protected]>[...]
Quoted 12 lines
qapi/misc.json +4
-0@@ -527,3 +527,42 @@ 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'], 'allow-preconfig': true } + +## +# @set-dirty-limit: +#
Quoted 8 lines
qapi/misc.json line 538
Quoted 5 lines
qapi/misc.json +5
-0+# This command could be used to cap the vCPU memory load, which is also +# refered as dirtyrate. One should use "calc-dirty-rate" with "dirty-ring" +# and to calculate vCPU dirtyrate and query it with "query-dirty-rate". +# Once getting the vCPU current dirtyrate, "set-dirty-limit" can be used +# to set the upper limit of dirtyrate for the interested vCPU."dirtyrate" is not a word. Let's spell it "dirty page rate", for consistency with the documentation in migration.json.
Ok, sounds good.
Quoted 6 lines
Regarding "One should use ...": sounds like you have to run calc-dirty-rate with argument @mode set to @dirty-ring before this command. Correct? What happens when you don't? set-dirty-limit fails?
Do you also have to run query-dirty-rate before this command?
Actually no, i'll clarify the usage next verison.
Quoted 3 lines
Speaking of migration.json: should these commands be defined there, next to calc-dirty-rate and query-dirty-rate?
I'm struggling too because these commands will be used in migration but it is vCPU they handle.
Quoted 9 lines
qapi/misc.json line 542
Quoted 5 lines
qapi/misc.json +4
-0+# +# @idx: vCPU index to set dirtylimit. +# +# @dirtyrate: upper limit of drityrate the specified vCPU could reach (MB/s)Typo "drityrate".
Suggest "upper limit for the specified vCPU's dirty page rate (MB/s)".
Ok.
Quoted 39 lines
Quoted 38 lines
qapi/misc.json +26
-0+# +# Since: 6.3 +# +# Example: +# {"execute": "set-dirty-limit"} +# "arguments": { "idx": 0, +# "dirtyrate": 200 } } +# +## +{ 'command': 'set-dirty-limit', + 'data': { 'idx': 'int', 'dirtyrate': 'uint64' } } + +## +# @cancel-dirty-limit: +# +# @idx: vCPU index to canceled the dirtylimit +# +# Since: 6.3 +# +# Example: +# {"execute": "cancel-dirty-limit"} +# "arguments": { "idx": 0 } } +# +## +{ 'command': 'cancel-dirty-limit', + 'data': { 'idx': 'int' } }softmmu/vl.c +1
-0@@ -3776,5 +3776,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 v3 3/3] cpus-common: implement dirty limit on vCPU
Quoted 41 lines · Hyman Huang
=E5=9C=A8 2021/11/22 15:35, Markus Armbruster =E5=86=99=E9=81=93:
Quoted 4 lines
Quoted 2 lines · [email protected] writes:
From: Hyman Huang(=E9=BB=84=E5=8B=87) <[email protected]>
Quoted 9 lines
Quoted 6 lines
implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirtyrate given by user.
introduce qmp commands set-dirty-limit/cancel-dirty-limit to set/cancel dirty limit on vCPU.
Please start sentences with a capital letter.
Ok,i'll check the syntax problem next version.
Quoted 18 lines
Quoted 2 lines
Signed-off-by Hyman Huang(黄勇) <[email protected]>[...]
Quoted 12 lines
qapi/misc.json +4
-0@@ -527,3 +527,42 @@ 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'], 'allow-preconfig': true } + +## +# @set-dirty-limit: +#Quoted 8 lines
qapi/misc.json line 538
Quoted 5 lines
qapi/misc.json +5
-0+# This command could be used to cap the vCPU memory load, which is also +# refered as dirtyrate. One should use "calc-dirty-rate" with "dirty-ring" +# and to calculate vCPU dirtyrate and query it with "query-dirty-rate". +# Once getting the vCPU current dirtyrate, "set-dirty-limit" can be used +# to set the upper limit of dirtyrate for the interested vCPU."dirtyrate" is not a word. Let's spell it "dirty page rate", for consistency with the documentation in migration.json.
Quoted 5 lines
Ok, sounds good.
Quoted 4 lines
Regarding "One should use ...": sounds like you have to run calc-dirty-rate with argument @mode set to @dirty-ring before this command. Correct? What happens when you don't? set-dirty-limit fails?
You didn't answer this question.
Quoted 2 lines
Quoted 1 line
Do you also have to run query-dirty-rate before this command?
Actually no, i'll clarify the usage next verison.
Regarding "dirty-ring": is this merely a limitation of the implementation, i.e. other modes could be made to work if we cared, or is it more fundamental?
Quoted 4 lines
Quoted 2 lines
Speaking of migration.json: should these commands be defined there, next to calc-dirty-rate and query-dirty-rate?
I'm struggling too because these commands will be used in migration but it is vCPU they handle.
I think migration.json is more about CPUs than misc.json is. Let's add the new commands to migration.json if migration maintainers are okay with it.
[...]
Re: [PATCH v3 3/3] cpus-common: implement dirty limit on vCPU
Quoted 43 lines · Markus Armbruster
Quoted 41 lines · Hyman Huang
=E5=9C=A8 2021/11/22 15:35, Markus Armbruster =E5=86=99=E9=81=93:
Quoted 4 lines
Quoted 2 lines · [email protected] writes:
From: Hyman Huang(=E9=BB=84=E5=8B=87) <[email protected]>
Quoted 9 lines
Quoted 6 lines
implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirtyrate given by user.
introduce qmp commands set-dirty-limit/cancel-dirty-limit to set/cancel dirty limit on vCPU.
Please start sentences with a capital letter.
Ok,i'll check the syntax problem next version.
Quoted 26 lines
Quoted 2 lines
Signed-off-by Hyman Huang(黄勇) <[email protected]>[...]
Quoted 7 lines
qapi/misc.json +0
-0@@ -527,3 +527,42 @@ 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'],qapi/misc.json line 538
Quoted 10 lines
qapi/misc.json +9
-0'allow-preconfig': true } + +## +# @set-dirty-limit: +# +# This command could be used to cap the vCPU memory load, which is also +# refered as dirtyrate. One should use "calc-dirty-rate" with "dirty-ring" +# and to calculate vCPU dirtyrate and query it with "query-dirty-rate". +# Once getting the vCPU current dirtyrate, "set-dirty-limit" can be used +# to set the upper limit of dirtyrate for the interested vCPU."dirtyrate" is not a word. Let's spell it "dirty page rate", for consistency with the documentation in migration.json.
Quoted 7 lines
Quoted 5 lines
Ok, sounds good.
Quoted 4 lines
Regarding "One should use ...": sounds like you have to run calc-dirty-rate with argument @mode set to @dirty-ring before this command. Correct? What happens when you don't? set-dirty-limit fails?
You didn't answer this question.
set-dirty-limit doesn't do any pre-check about if calc-dirty-rate has executed, so it doesn't fail.
Since only executing calc-dirty-rate with dirty-ring mode can we get the vCPU dirty page rate currently(while the dirty-bitmap only get the vm dirty page rate), "One should use ..." maybe misleading, what i actually want to say is "One should use the dirty-ring mode to calculate the vCPU dirty page rate".
Quoted 19 lines
Quoted 3 lines
Quoted 2 lines
Do you also have to run query-dirty-rate before this command?
Actually no, i'll clarify the usage next verison.
Regarding "dirty-ring": is this merely a limitation of the implementation, i.e. other modes could be made to work if we cared, or is it more fundamental?
Quoted 4 lines
Quoted 2 lines
Speaking of migration.json: should these commands be defined there, next to calc-dirty-rate and query-dirty-rate?
I'm struggling too because these commands will be used in migration but it is vCPU they handle.
I think migration.json is more about CPUs than misc.json is. Let's add the new commands to migration.json if migration maintainers are okay with it.
[...]
Signature · 3 lines
Best regard Hyman Huang(黄勇)
Re: [PATCH v3 3/3] cpus-common: implement dirty limit on vCPU
Quoted 44 lines · Hyman Huang
Quoted 43 lines · Markus Armbruster
Quoted 41 lines · Hyman Huang
=E5=9C=A8 2021/11/22 15:35, Markus Armbruster =E5=86=99=E9=81=93:
Quoted 4 lines
Quoted 2 lines · [email protected] writes:
From: Hyman Huang(=E9=BB=84=E5=8B=87) <[email protected]>
Quoted 9 lines
Quoted 6 lines
implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirtyrate given by user.
introduce qmp commands set-dirty-limit/cancel-dirty-limit to set/cancel dirty limit on vCPU.
Please start sentences with a capital letter.
Ok,i'll check the syntax problem next version.
Quoted 26 lines
Quoted 2 lines
Signed-off-by Hyman Huang(黄勇) <[email protected]>[...]
Quoted 7 lines
qapi/misc.json +0
-0@@ -527,3 +527,42 @@ 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'],qapi/misc.json line 538
Quoted 10 lines
qapi/misc.json +9
-0'allow-preconfig': true } + +## +# @set-dirty-limit: +# +# This command could be used to cap the vCPU memory load, which is also +# refered as dirtyrate. One should use "calc-dirty-rate" with "dirty-ring" +# and to calculate vCPU dirtyrate and query it with "query-dirty-rate". +# Once getting the vCPU current dirtyrate, "set-dirty-limit" can be used +# to set the upper limit of dirtyrate for the interested vCPU."dirtyrate" is not a word. Let's spell it "dirty page rate", for consistency with the documentation in migration.json.
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Ok, sounds good.
Quoted 4 lines
Regarding "One should use ...": sounds like you have to run calc-dirty-rate with argument @mode set to @dirty-ring before this command. Correct? What happens when you don't? set-dirty-limit fails?
You didn't answer this question.
set-dirty-limit doesn't do any pre-check about if calc-dirty-rate has executed, so it doesn't fail.
Peeking at qmp_set_dirty_limit()... it fails when !kvm_dirty_ring_enabled(). kvm_dirty_ring_enabled() returns true when kvm_state->kvm_dirty_ring_size is non-zero. How can it become non-zero?
Quoted 5 lines
Since only executing calc-dirty-rate with dirty-ring mode can we get the vCPU dirty page rate currently(while the dirty-bitmap only get the vm dirty page rate), "One should use ..." maybe misleading, what i actually want to say is "One should use the dirty-ring mode to calculate the vCPU dirty page rate".
I'm still confused on what exactly users must do for the page dirty rate limiting to work as intended, and at least as importantly, what happens when they get it wrong.
[...]
Re: [PATCH v3 3/3] cpus-common: implement dirty limit on vCPU
Quoted 51 lines · Markus Armbruster
Quoted 49 lines · Hyman Huang
Quoted 48 lines · Markus Armbruster
Quoted 46 lines · Hyman Huang
=E5=9C=A8 2021/11/22 15:35, Markus Armbruster =E5=86=99=E9=81=93:
Quoted 4 lines
Quoted 2 lines · [email protected] writes:
From: Hyman Huang(=E9=BB=84=E5=8B=87) <[email protected]>
Quoted 9 lines
Quoted 6 lines
implement dirtyrate calculation periodically basing on dirty-ring and throttle vCPU until it reachs the quota dirtyrate given by user.
introduce qmp commands set-dirty-limit/cancel-dirty-limit to set/cancel dirty limit on vCPU.
Please start sentences with a capital letter.
Ok,i'll check the syntax problem next version.
Quoted 18 lines
Quoted 2 lines
Signed-off-by Hyman Huang(黄勇) <[email protected]>[...]
Quoted 12 lines
qapi/misc.json +4
-0@@ -527,3 +527,42 @@ 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'], 'allow-preconfig': true } + +## +# @set-dirty-limit: +#Quoted 8 lines
qapi/misc.json line 538
Quoted 5 lines
qapi/misc.json +5
-0+# This command could be used to cap the vCPU memory load, which is also +# refered as dirtyrate. One should use "calc-dirty-rate" with "dirty-ring" +# and to calculate vCPU dirtyrate and query it with "query-dirty-rate". +# Once getting the vCPU current dirtyrate, "set-dirty-limit" can be used +# to set the upper limit of dirtyrate for the interested vCPU."dirtyrate" is not a word. Let's spell it "dirty page rate", for consistency with the documentation in migration.json.
Ok, sounds good.
Quoted 4 lines
Regarding "One should use ...": sounds like you have to run calc-dirty-rate with argument @mode set to @dirty-ring before this command. Correct? What happens when you don't? set-dirty-limit fails?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
You didn't answer this question.
set-dirty-limit doesn't do any pre-check about if calc-dirty-rate has executed, so it doesn't fail.
Peeking at
qmp_set_dirty_limit()... it fails when !kvm_dirty_ring_enabled().kvm_dirty_ring_enabled()returns true whenkvm_state->kvm_dirty_ring_sizeis non-zero. How can it become non-zero?
If we enable dirty-ring with qemu commandline "-accel kvm,dirty-ring-size=xxx",qemu will parse the dirty-ring-size and set it. So we check if dirty-ring is enabled by the kvm_dirty_ring_size.
Quoted 10 lines
Quoted 6 lines
Since only executing calc-dirty-rate with dirty-ring mode can we get the vCPU dirty page rate currently(while the dirty-bitmap only get the vm dirty page rate), "One should use ..." maybe misleading, what i actually want to say is "One should use the dirty-ring mode to calculate the vCPU dirty page rate".
I'm still confused on what exactly users must do for the page dirty rate limiting to work as intended, and at least as importantly, what happens when they get it wrong.
User can set-dirty-limit unconditionally and the dirtylimit will work.
"One should use ..." just emphasize if users want to know which vCPU is in high memory load and want to limit it's dirty page rate, they can use calc-dirty-rate but it is not prerequisite for set-dirty-limit.
Umm, I think "One should use ..." explanation make things complicated. I'll reconsider the comment next version.
Quoted 3 lines
[...]