All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yuan ZhaoXiong <yuanzhaoxiong@baidu.com>
Cc: pbonzini@redhat.com, vkuznets@redhat.com, wanpengli@tencent.com,
	jmattson@google.com, joro@8bytes.org, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	hpa@zytor.com, lirongqing@baidu.com, kvm@vger.kernel.org,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] KVM: X86: Introduce vfio_intr_stat per-vm debugfs file
Date: Mon, 7 Feb 2022 18:59:47 +0000	[thread overview]
Message-ID: <YgFsIyxauHVeepqJ@google.com> (raw)
In-Reply-To: <1642593015-28729-1-git-send-email-yuanzhaoxiong@baidu.com>

On Wed, Jan 19, 2022, Yuan ZhaoXiong wrote:
> +#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS

This is pointless, KVM x86 unconditionally selects HAVE_KVM_IRQ_BYPASS.

> +#include <linux/kvm_irqfd.h>
> +#include <asm/irq_remapping.h>
> +#endif
> +
>  static int vcpu_get_timer_advance_ns(void *data, u64 *val)
>  {
>  	struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
> @@ -181,9 +186,94 @@ static int kvm_mmu_rmaps_stat_release(struct inode *inode, struct file *file)
>  	.release	= kvm_mmu_rmaps_stat_release,
>  };
>  
> +#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
> +static int kvm_vfio_intr_stat_show(struct seq_file *m, void *v)
> +{
> +	struct kvm_kernel_irq_routing_entry *e;
> +	struct kvm_irq_routing_table *irq_rt;
> +	unsigned int host_irq, guest_irq;
> +	struct kvm_kernel_irqfd *irqfd;
> +	struct kvm *kvm = m->private;
> +	struct kvm_lapic_irq irq;
> +	struct kvm_vcpu *vcpu;
> +	int idx;
> +
> +	if (!kvm_arch_has_assigned_device(kvm) ||
> +			!irq_remapping_cap(IRQ_POSTING_CAP)) {

Bad indentation and unnecessary curly braces.

	if (!kvm_arch_has_assigned_device(kvm) ||
	    !irq_remapping_cap(IRQ_POSTING_CAP))
		return 0;


> +		return 0;
> +	}
> +
> +	seq_printf(m, "%12s %12s %12s %12s\n",
> +			"guest_irq", "host_irq", "vector", "vcpu");

Bad indentation.  Ditto for many cases below.


	seq_printf(m, "%12s %12s %12s %12s\n",
		   "guest_irq", "host_irq", "vector", "vcpu");
	   
> +
> +	spin_lock_irq(&kvm->irqfds.lock);
> +	idx = srcu_read_lock(&kvm->irq_srcu);
> +	irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu);
> +
> +	list_for_each_entry(irqfd, &kvm->irqfds.items, list) {
> +		if (!irqfd->producer)
> +			continue;
> +
> +		host_irq = irqfd->producer->irq;
> +		guest_irq = irqfd->gsi;
> +
> +		if (guest_irq >= irq_rt->nr_rt_entries ||
> +				hlist_empty(&irq_rt->map[guest_irq])) {

Indentation.

> +			pr_warn_once("no route for guest_irq %u/%u (broken user space?)\n",
> +					guest_irq, irq_rt->nr_rt_entries);

Indentation, though I personally don't see much point of duplicating the message
from vmx_pi_update_irte(), just continue on.

> +			continue;
> +		}
> +
> +		hlist_for_each_entry(e, &irq_rt->map[guest_irq], link) {
> +			if (e->type != KVM_IRQ_ROUTING_MSI)
> +				continue;
> +
> +			kvm_set_msi_irq(kvm, e, &irq);
> +			if (kvm_intr_is_single_vcpu(kvm, &irq, &vcpu)) {

Unnecessary curly braces (though this one is debatable).

> +				seq_printf(m, "%12u %12u %12u %12u\n",
> +						guest_irq, host_irq, irq.vector, vcpu->vcpu_id);

Indentation.

> +			}
> +		}
> +	}
> +	srcu_read_unlock(&kvm->irq_srcu, idx);
> +	spin_unlock_irq(&kvm->irqfds.lock);
> +	return 0;
> +}
> +

  reply	other threads:[~2022-02-07 19:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-19 11:50 [PATCH v1] KVM: X86: Introduce vfio_intr_stat per-vm debugfs file Yuan ZhaoXiong
2022-02-07 18:59 ` Sean Christopherson [this message]
2022-01-19 13:14 Yuan ZhaoXiong

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=YgFsIyxauHVeepqJ@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    --cc=yuanzhaoxiong@baidu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.