cpu-throttle: Remove timer_mod() from cpu_throttle_set()
commit33c38f8ca1e09b9f77cf263404d423e076c19177
authorUtkarsh Tripathi <utkarsh.tripathi@nutanix.com>
Thu, 31 Dec 2020 13:13:04 +0000 (31 13:13 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 8 Feb 2021 14:15:32 +0000 (8 15:15 +0100)
tree3f0f5deb972986229070d0244e33c6fc643563bf
parent54550d886e5bb4148c0765c639fa04a44f3e5d8d
cpu-throttle: Remove timer_mod() from cpu_throttle_set()

During migrations, after each iteration, cpu_throttle_set() is called,
which irrespective of input, re-arms the timer according to value of
new_throttle_pct. This causes cpu_throttle_thread() to be delayed in
getting scheduled and consqeuntly lets guest run for more time than what
the throttle value should allow. This leads to spikes in guest throughput
at high cpu-throttle percentage whenever cpu_throttle_set() is called.

A solution would be not to modify the timer immediately in
cpu_throttle_set(), instead, only modify throttle_percentage so that the
throttle would automatically adjust to the required percentage when
cpu_throttle_timer_tick() is invoked.

Manually tested the patch using following configuration:

Guest:
Centos7 (3.10.0-123.el7.x86_64)
Total Memory - 64GB , CPUs - 16
Tool used - stress (1.0.4)
Workload - stress --vm 32 --vm-bytes 1G --vm-keep

Migration Parameters:
Network Bandwidth - 500MBPS
cpu-throttle-initial - 99

Results:
With timer_mod(): fails to converge, continues indefinitely
Without timer_mod(): converges in 249 sec

Signed-off-by: Utkarsh Tripathi <utkarsh.tripathi@nutanix.com>
Message-Id: <1609420384-119407-1-git-send-email-utkarsh.tripathi@nutanix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
softmmu/cpu-throttle.c