From: Alex Williamson <alex.williamson@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Yunhong Jiang <yunhong.jiang@linux.intel.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] VFIO: Add a parameter to force nonthread IRQ
Date: Wed, 28 Oct 2015 10:00:28 -0600 [thread overview]
Message-ID: <1446048028.8018.387.camel@redhat.com> (raw)
In-Reply-To: <56301A87.9030907@redhat.com>
On Wed, 2015-10-28 at 01:44 +0100, Paolo Bonzini wrote:
>
> On 27/10/2015 22:26, Yunhong Jiang wrote:
> >> > On RT kernels however can you call eventfd_signal from interrupt
> >> > context? You cannot call spin_lock_irqsave (which can sleep) from a
> >> > non-threaded interrupt handler, can you? You would need a raw spin lock.
> > Thanks for pointing this out. Yes, we can't call spin_lock_irqsave on RT
> > kernel. Will do this way on next patch. But not sure if it's overkill to use
> > raw_spinlock there since the eventfd_signal is used by other caller also.
>
> No, I don't think you can use raw_spinlock there. The problem is not
> just eventfd_signal, it is especially wake_up_locked_poll. You cannot
> convert the whole workqueue infrastructure to use raw_spinlock.
>
> Alex, would it make sense to use the IRQ bypass infrastructure always,
> not just for VT-d, to do the MSI injection directly from the VFIO
> interrupt handler and bypass the eventfd? Basically this would add an
> RCU-protected list of consumers matching the token to struct
> irq_bypass_producer, and a
>
> int (*inject)(struct irq_bypass_consumer *);
>
> callback to struct irq_bypass_consumer. If any callback returns true,
> the eventfd is not signaled. The KVM implementation would be like this
> (compare with virt/kvm/eventfd.c):
>
> /* Extracted out of irqfd_wakeup */
> static int
> irqfd_wakeup_pollin(struct kvm_kernel_irqfd *irqfd)
> {
> ...
> }
>
> /* Extracted out of irqfd_wakeup */
> static int
> irqfd_wakeup_pollhup(struct kvm_kernel_irqfd *irqfd)
> {
> ...
> }
>
> static int
> irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync,
> void *key)
> {
> struct _irqfd *irqfd = container_of(wait,
> struct _irqfd, wait);
> unsigned long flags = (unsigned long)key;
>
> if (flags & POLLIN)
> irqfd_wakeup_pollin(irqfd);
> if (flags & POLLHUP)
> irqfd_wakeup_pollhup(irqfd);
>
> return 0;
> }
>
> static int kvm_arch_irq_bypass_inject(
> struct irq_bypass_consumer *cons)
> {
> struct kvm_kernel_irqfd *irqfd =
> container_of(cons, struct kvm_kernel_irqfd,
> consumer);
>
> irqfd_wakeup_pollin(irqfd);
> }
>
> Or do you think it would be a hack? The latency improvement might
> actually be even better than what Yunhong is already reporting.
Yeah, that might be a good idea, it's probably more plausible than
making the eventfd_signal() code friendly to call from hard interrupt
context. On the vfio side can we use request_threaded_irq() directly
for this? Making the hard irq handler return IRQ_HANDLED if we can use
the irq bypass manager or IRQ_WAKE_THREAD if we need to use the eventfd.
I think we need some way to get back to irq thread context to use
eventfd_signal(). Would we ever not want to use the direct bypass
manager path if available? Thanks,
Alex
next prev parent reply other threads:[~2015-10-28 16:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 1:20 [RFC PATCH] VFIO: Add a parameter to force nonthread IRQ Yunhong Jiang
2015-10-27 3:37 ` Alex Williamson
2015-10-27 6:35 ` Yunhong Jiang
2015-10-27 9:29 ` Paolo Bonzini
2015-10-27 21:26 ` Yunhong Jiang
2015-10-28 0:44 ` Paolo Bonzini
2015-10-28 16:00 ` Alex Williamson [this message]
2015-10-28 17:05 ` Paolo Bonzini
2015-10-28 23:54 ` Marcelo Tosatti
2015-10-29 3:11 ` Alex Williamson
2015-10-29 9:45 ` Paolo Bonzini
2015-10-30 6:16 ` Yunhong Jiang
2015-11-02 9:17 ` Paolo Bonzini
2015-10-28 17:50 ` Yunhong Jiang
2015-10-28 18:18 ` Alex Williamson
2015-10-28 21:46 ` Yunhong Jiang
2015-10-28 18:28 ` Paolo Bonzini
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=1446048028.8018.387.camel@redhat.com \
--to=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yunhong.jiang@linux.intel.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;
as well as URLs for NNTP newsgroup(s).