From: Paolo Bonzini <pbonzini@redhat.com>
To: "Longpeng (Mike)" <longpeng2@huawei.com>
Cc: rkrcmar@redhat.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, weidong.huang@huawei.com,
arei.gonglei@huawei.com, wangxinxin.wang@huawei.com,
longpeng.mike@gmail.com
Subject: Re: [PATCH] KVM: X86: expand ->arch.apic_arb_prio to u64
Date: Tue, 8 Aug 2017 15:57:34 +0200 [thread overview]
Message-ID: <09780c43-df1f-1f10-bb01-1fc7913910e4@redhat.com> (raw)
In-Reply-To: <5989C1B5.5090308@huawei.com>
On 08/08/2017 15:50, Longpeng (Mike) wrote:
>
>
> On 2017/8/8 21:08, Paolo Bonzini wrote:
>
>> On 08/08/2017 13:37, Longpeng(Mike) wrote:
>>> Currently 'apic_arb_prio' is int32_t, it's too short for long
>>> time running. In our environment, it overflowed and then the
>>> UBSAN was angry:
>>>
>>> signed integer overflow:
>>> 2147483647 + 1 cannot be represented in type 'int'
>>> CPU: 22 PID: 31237 Comm: qemu-kvm Tainted: ...
>>> ...
>>> Call Trace:
>>> [<ffffffff81f030b6>] dump_stack+0x1e/0x20
>>> [<ffffffff81f03173>] ubsan_epilogue+0x12/0x55
>>> [<ffffffff81f04658>] handle_overflow+0x1ba/0x215
>>> [<ffffffff81f046dd>] __ubsan_handle_add_overflow+0x2a/0x31
>>> [<ffffffffa126cb1a>] __apic_accept_irq+0x57a/0x5d0 [kvm]
>>> [<ffffffffa126d14f>] kvm_apic_set_irq+0x9f/0xf0 [kvm]
>>> [<ffffffffa126db20>] kvm_irq_delivery_to_apic_fast+0x450/0x910 [kvm]
>>> [<ffffffffa127d8ea>] kvm_irq_delivery_to_apic+0xfa/0x7a0 [kvm]
>>> [<ffffffffa127e039>] kvm_set_msi+0xa9/0x100 [kvm]
>>> [<ffffffffa12871ed>] kvm_send_userspace_msi+0x14d/0x1f0 [kvm]
>>> [<ffffffffa11ed56e>] kvm_vm_ioctl+0x4ee/0xdd0 [kvm]
>>> ...
>>>
>>> We expand it to u64, this is large enough. Suppose the vcpu receives
>>> 1000 irqs per second, then it won't overflow in 584942417 years.
>>> ( 18446744073709551615/1000/3600/24/365 = 584942417 )
>>
>> Since you only look at the difference, changing it to uint32_t should be
>> enough.
>
>
> Hi Paolo,
>
> I'm afraid uint32_t isn't enough. For 1000 irqs per second, it can only holds
> 49 days ( although the overflow won't cause any corruption ).
What matters is only the difference across 2 vCPUs.
And in fact even 32 bits are probably too many, 16 or even 8 should be
enough because overflowing arb_prio is a good thing. If you have
delivered millions IRQs to VCPU0 (let's say for a day), and then switch
the interrupt to VCPU1, you don't want to the next day to have
interrupts going to VCPU1 only. A short warm-up time (a few seconds?)
is acceptable, but then you should have interrupts distributed equally
between VCPU0 and VCPU1. This can only happen if arb_prio overflows.
Paolo
> 4294967295/1000/3600/24 = 49
>
>>
>> Paolo
>>
>
>> .
>>
>
>
next prev parent reply other threads:[~2017-08-08 13:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-08 11:37 Longpeng(Mike)
2017-08-08 13:08 ` Paolo Bonzini
2017-08-08 13:50 ` Longpeng (Mike)
2017-08-08 13:57 ` Paolo Bonzini [this message]
2017-08-09 0:59 ` Longpeng (Mike)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=09780c43-df1f-1f10-bb01-1fc7913910e4@redhat.com \
--to=pbonzini@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longpeng.mike@gmail.com \
--cc=longpeng2@huawei.com \
--cc=rkrcmar@redhat.com \
--cc=wangxinxin.wang@huawei.com \
--cc=weidong.huang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®