public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Kai Huang <kai.huang@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"xuyun_xy.xy@linux.alibaba.com" <xuyun_xy.xy@linux.alibaba.com>,
	"zijie.wei@linux.alibaba.com" <zijie.wei@linux.alibaba.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 1/3] KVM: x86: Isolate edge vs. level check in userspace I/O APIC route scanning
Date: Fri, 11 Apr 2025 10:55:14 +1200	[thread overview]
Message-ID: <0abe7616-0ef4-4098-bf55-8003ab958067@intel.com> (raw)
In-Reply-To: <Z_hKP7iw_d3JgHbI@google.com>

On 11/04/25 10:46, Sean Christopherson wrote:
> On Tue, Mar 04, 2025, Kai Huang wrote:
>> On Mon, 2025-03-03 at 17:33 -0800, Sean Christopherson wrote:
>>> Extract and isolate the trigger mode check in kvm_scan_ioapic_routes() in
>>> anticipation of moving destination matching logic to a common helper (for
>>> userspace vs. in-kernel I/O APIC emulation).
>>>
>>> No functional change intended.
>>>
>>> Signed-off-by: Sean Christopherson <seanjc@google.com>
>>
>> Reviewed-by: Kai Huang <kai.huang@intel.com>
>>
>>> ---
>>>   arch/x86/kvm/irq_comm.c | 10 ++++++----
>>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
>>> index 8136695f7b96..866f84392797 100644
>>> --- a/arch/x86/kvm/irq_comm.c
>>> +++ b/arch/x86/kvm/irq_comm.c
>>> @@ -424,10 +424,12 @@ void kvm_scan_ioapic_routes(struct kvm_vcpu *vcpu,
>>>   
>>>   			kvm_set_msi_irq(vcpu->kvm, entry, &irq);
>>>   
>>> -			if (irq.trig_mode &&
>>> -			    (kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT,
>>> -						 irq.dest_id, irq.dest_mode) ||
>>> -			     kvm_apic_pending_eoi(vcpu, irq.vector)))
>>> +			if (!irq.trig_mode)
>>> +				continue;
>>
>> Perhaps take this chance to make it explicit?
>>
>> 			if (irq.trig_mode != IOAPIC_LEVEL_TRIG)
>> 				continue;
>>
>> kvm_ioapic_scan_entry() also checks against IOAPIC_LEVEL_TRIG explicitly.
> 
> Hmm, I'm leaning "no".  kvm_set_msi_irq() isn't I/O APIC specific (and obviously
> neither is "struct kvm_lapic_irq").  The fact that it sets irq.trig_mode to '0'
> or '1', and that the '1' value in particular happens to match IOAPIC_LEVEL_TRIG
> is somewhat of a coincidence.
> 
> kvm_ioapic_scan_entry() on the other operates on a "union kvm_ioapic_redirect_entry"
> object, in which case trig_mode is guaranteed to be '0' or '1', i.e. is exactly
> IOAPIC_EDGE_TRIG or IOAPIC_LEVEL_TRIG.
> 
> 	u8 trig_mode:1;

This makes sense.  Thanks for clarifying.

> 
> So as much as I advocate for consistency, I think in this case it makes sense to
> be consistent with __apic_accept_irq(), which only cares about zero vs. non-zero.

Yeah LGTM.


  reply	other threads:[~2025-04-10 22:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04  1:33 [PATCH v5 0/3] KVM: x86: Optimize "stale" EOI bitmap exiting Sean Christopherson
2025-03-04  1:33 ` [PATCH v5 1/3] KVM: x86: Isolate edge vs. level check in userspace I/O APIC route scanning Sean Christopherson
2025-03-04  9:42   ` Huang, Kai
2025-04-10 22:46     ` Sean Christopherson
2025-04-10 22:55       ` Kai Huang [this message]
2025-03-04  1:33 ` [PATCH v5 2/3] KVM: x86: Add a helper to deduplicate I/O APIC EOI interception logic Sean Christopherson
2025-03-04  9:45   ` Huang, Kai
2025-03-04  1:33 ` [PATCH v5 3/3] KVM: x86: Rescan I/O APIC routes after EOI interception for old routing Sean Christopherson
2025-03-04  9:54   ` Huang, Kai
2025-04-25 22:09 ` [PATCH v5 0/3] KVM: x86: Optimize "stale" EOI bitmap exiting Sean Christopherson

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=0abe7616-0ef4-4098-bf55-8003ab958067@intel.com \
    --to=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=xuyun_xy.xy@linux.alibaba.com \
    --cc=zijie.wei@linux.alibaba.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