[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 06/30] softmmu/dirtylimit: Implement virtual CPU throttle
From: |
Peter Maydell |
Subject: |
Re: [PULL 06/30] softmmu/dirtylimit: Implement virtual CPU throttle |
Date: |
Fri, 29 Jul 2022 14:31:05 +0100 |
On Wed, 20 Jul 2022 at 12:30, Dr. David Alan Gilbert (git)
<dgilbert@redhat.com> wrote:
>
> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>
> Setup a negative feedback system when vCPU thread
> handling KVM_EXIT_DIRTY_RING_FULL exit by introducing
> throttle_us_per_full field in struct CPUState. Sleep
> throttle_us_per_full microseconds to throttle vCPU
> if dirtylimit is in service.
>
> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
> Reviewed-by: Peter Xu <peterx@redhat.com>
> Message-Id:
> <977e808e03a1cef5151cae75984658b6821be618.1656177590.git.huangy81@chinatelecom.cn>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Hi; Coverity points out a problem with this code (CID 1490787):
> +static inline int64_t dirtylimit_dirty_ring_full_time(uint64_t dirtyrate)
> +{
> + static uint64_t max_dirtyrate;
> + uint32_t dirty_ring_size = kvm_dirty_ring_size();
> + uint64_t dirty_ring_size_meory_MB =
> + dirty_ring_size * TARGET_PAGE_SIZE >> 20;
Because dirty_ring_size and TARGET_PAGE_SIZE are both 32 bits,
this multiplication will be done as a 32-bit operation,
which could overflow. You should cast one of the operands
to uint64_t to ensure that the operation is done as a 64 bit
multiplication.
Side note: typo in the variable name: should be 'memory'.
> + if (max_dirtyrate < dirtyrate) {
> + max_dirtyrate = dirtyrate;
> + }
> +
> + return dirty_ring_size_meory_MB * 1000000 / max_dirtyrate;
> +}
thanks
-- PMM
- [PULL 00/30] migration queue, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 01/30] accel/kvm/kvm-all: Refactor per-vcpu dirty ring reaping, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 03/30] migration/dirtyrate: Refactor dirty page rate calculation, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 04/30] softmmu/dirtylimit: Implement vCPU dirtyrate calculation periodically, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 08/30] tests: Add dirty page rate limit test, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 05/30] accel/kvm/kvm-all: Introduce kvm_dirty_ring_size function, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 02/30] cpus: Introduce cpu_list_generation_id, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 06/30] softmmu/dirtylimit: Implement virtual CPU throttle, Dr. David Alan Gilbert (git), 2022/07/20
- Re: [PULL 06/30] softmmu/dirtylimit: Implement virtual CPU throttle,
Peter Maydell <=
- [PULL 13/30] migration: Postcopy recover with preempt enabled, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 10/30] migration: Add postcopy-preempt capability, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 07/30] softmmu/dirtylimit: Implement dirty page rate limit, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 12/30] migration: Postcopy preemption enablement, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 14/30] migration: Create the postcopy preempt channel asynchronously, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 11/30] migration: Postcopy preemption preparation on channel creation, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 16/30] migration: Add helpers to detect TLS capability, Dr. David Alan Gilbert (git), 2022/07/20
- [PULL 15/30] migration: Add property x-postcopy-preempt-break-huge, Dr. David Alan Gilbert (git), 2022/07/20