xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	"Tim \(Xen.org\)" <tim@xen.org>,
	George Dunlap <George.Dunlap@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>,
	Ian Jackson <Ian.Jackson@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [Xen-devel] [PATCH v2 11/11] ioreq: provide support for long-running operations...
Date: Tue, 10 Sep 2019 14:40:47 +0000	[thread overview]
Message-ID: <fccf7ba8098942e6b67f305ecaebad8b@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <20190910142800.rhndl6azi6y6uuc4@Air-de-Roger>

> -----Original Message-----
> From: Roger Pau Monne <roger.pau@citrix.com>
> Sent: 10 September 2019 15:28
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; Jan Beulich <jbeulich@suse.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Wei Liu <wl@xen.org>; George Dunlap <George.Dunlap@citrix.com>; Ian
> Jackson <Ian.Jackson@citrix.com>; Julien Grall <julien.grall@arm.com>; Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com>; Stefano Stabellini <sstabellini@kernel.org>; Tim (Xen.org) <tim@xen.org>
> Subject: Re: [PATCH v2 11/11] ioreq: provide support for long-running operations...
> 
> On Tue, Sep 10, 2019 at 04:14:18PM +0200, Paul Durrant wrote:
> > > -----Original Message-----
> > > From: Roger Pau Monne <roger.pau@citrix.com>
> > > Sent: 03 September 2019 17:14
> > > To: xen-devel@lists.xenproject.org
> > > Cc: Roger Pau Monne <roger.pau@citrix.com>; Paul Durrant <Paul.Durrant@citrix.com>; Jan Beulich
> > > <jbeulich@suse.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Wei Liu <wl@xen.org>; George
> Dunlap
> > > <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Julien Grall
> <julien.grall@arm.com>;
> > > Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>; Stefano Stabellini <sstabellini@kernel.org>; Tim
> > > (Xen.org) <tim@xen.org>
> > > Subject: [PATCH v2 11/11] ioreq: provide support for long-running operations...
> > >
> > > ...and switch vPCI to use this infrastructure for long running
> > > physmap modification operations.
> > >
> > > This allows to get rid of the vPCI specific modifications done to
> > > handle_hvm_io_completion and allows generalizing the support for
> > > long-running operations to other internal ioreq servers. Such support
> > > is implemented as a specific handler that can be registers by internal
> > > ioreq servers and that will be called to check for pending work.
> > > Returning true from this handler will prevent the vcpu from running
> > > until the handler returns false.
> > >
> > > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > > ---
> > >  xen/arch/x86/hvm/ioreq.c       | 55 +++++++++++++++++++++++++-----
> > >  xen/drivers/vpci/header.c      | 61 ++++++++++++++++++----------------
> > >  xen/drivers/vpci/vpci.c        |  8 ++++-
> > >  xen/include/asm-x86/hvm/vcpu.h |  3 +-
> > >  xen/include/xen/vpci.h         |  6 ----
> > >  5 files changed, 89 insertions(+), 44 deletions(-)
> > >
> > > diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c
> > > index 33c56b880c..caa53dfa84 100644
> > > --- a/xen/arch/x86/hvm/ioreq.c
> > > +++ b/xen/arch/x86/hvm/ioreq.c
> > > @@ -239,16 +239,48 @@ bool handle_hvm_io_completion(struct vcpu *v)
> > >      enum hvm_io_completion io_completion;
> > >      unsigned int id;
> > >
> > > -    if ( has_vpci(d) && vpci_process_pending(v) )
> > > -    {
> > > -        raise_softirq(SCHEDULE_SOFTIRQ);
> > > -        return false;
> > > -    }
> > > -
> > > -    FOR_EACH_EXTERNAL_IOREQ_SERVER(d, id, s)
> > > +    FOR_EACH_IOREQ_SERVER(d, id, s)
> > >      {
> > >          struct hvm_ioreq_vcpu *sv;
> > >
> > > +        if ( hvm_ioreq_is_internal(id) )
> > > +        {
> >
> > I wonder whether it would be neater by saying:
> >
> >            if ( !hvm_ioreq_is_internal(id) )
> >                continue;
> >
> > here to avoid the indentation below.
> 
> I'm not sure I follow. This loop does work for both the internal and
> the external ioreq servers, and hence skipping external servers would
> prevent the iteration over ioreq_vcpu_list done below for external
> servers.

Sorry, I got my nesting mixed up. What I actually mean is:

+    FOR_EACH_IOREQ_SERVER(d, id, s)
     {
         struct hvm_ioreq_vcpu *sv;

+        if ( hvm_ioreq_is_internal(id) )
+        {
+            ioreq_t req = vio->io_req;
+
+            if ( vio->io_req.state != STATE_IOREQ_INPROCESS )
+                continue;
+
+            /*
+             * Check and convert the PIO/MMIO ioreq to a PCI config space
+             * access.
+             */
+            convert_pci_ioreq(d, &req);
+
+            if ( s->handler(v, &req, s->data) == X86EMUL_RETRY )
+            {
+                /*
+                 * Need to raise a scheduler irq in order to prevent the
+                 * guest vcpu from resuming execution.
+                 *
+                 * Note this is not required for external ioreq operations
+                 * because in that case the vcpu is marked as blocked, but
+                 * this cannot be done for long-running internal
+                 * operations, since it would prevent the vcpu from being
+                 * scheduled and thus the long running operation from
+                 * finishing.
+                 */
+                raise_softirq(SCHEDULE_SOFTIRQ);
+                return false;
+            }
+
+            /* Finished processing the ioreq. */
+            vio->io_req.state = hvm_ioreq_needs_completion(&vio->io_req) ?
+                                STATE_IORESP_READY : STATE_IOREQ_NONE;
+            continue;
+        }
+

  Paul

> 
> >
> > > +            if ( vio->io_req.state == STATE_IOREQ_INPROCESS )
> > > +            {
> > > +                ioreq_t req = vio->io_req;
> > > +
> > > +                /*
> > > +                 * Check and convert the PIO/MMIO ioreq to a PCI config space
> > > +                 * access.
> > > +                 */
> > > +                convert_pci_ioreq(d, &req);
> > > +
> > > +                if ( s->handler(v, &req, s->data) == X86EMUL_RETRY )
> > > +                {
> > > +                    /*
> > > +                     * Need to raise a scheduler irq in order to prevent the
> > > +                     * guest vcpu from resuming execution.
> > > +                     *
> > > +                     * Note this is not required for external ioreq operations
> > > +                     * because in that case the vcpu is marked as blocked, but
> > > +                     * this cannot be done for long-running internal
> > > +                     * operations, since it would prevent the vcpu from being
> > > +                     * scheduled and thus the long running operation from
> > > +                     * finishing.
> > > +                     */
> > > +                    raise_softirq(SCHEDULE_SOFTIRQ);
> > > +                    return false;
> > > +                }
> > > +
> > > +                /* Finished processing the ioreq. */
> > > +                if ( hvm_ioreq_needs_completion(&vio->io_req) )
> > > +                    vio->io_req.state = STATE_IORESP_READY;
> > > +                else
> > > +                    vio->io_req.state = STATE_IOREQ_NONE;
> >
> > IMO the above is also neater as:
> >
> >     vio->io_req.state = hvm_ioreq_needs_completion(&vio->io_req) ?
> >                         STATE_IORESP_READY : STATE_IOREQ_NONE;
> >
> > > +            }
> > > +            continue;
> > > +        }
> > > +
> > >          list_for_each_entry ( sv,
> > >                                &s->ioreq_vcpu_list,
> > >                                list_entry )
> 
> Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

      reply	other threads:[~2019-09-10 14:42 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-03 16:14 [Xen-devel] [PATCH v2 00/11] ioreq: add support for internal servers Roger Pau Monne
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 01/11] ioreq: fix hvm_all_ioreq_servers_add_vcpu fail path cleanup Roger Pau Monne
2019-09-10 10:44   ` Paul Durrant
2019-09-10 13:28   ` Jan Beulich
2019-09-10 13:33     ` Roger Pau Monné
2019-09-10 13:35       ` Jan Beulich
2019-09-10 13:42         ` Roger Pau Monné
2019-09-10 13:53           ` Paul Durrant
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 02/11] ioreq: terminate cf8 handling at hypervisor level Roger Pau Monne
2019-09-03 17:13   ` Andrew Cooper
2019-09-04  7:49     ` Roger Pau Monné
2019-09-04  8:00       ` Roger Pau Monné
2019-09-04  8:04       ` Jan Beulich
2019-09-04  9:46       ` Paul Durrant
2019-09-04 13:39         ` Roger Pau Monné
2019-09-04 13:56           ` Paul Durrant
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 03/11] ioreq: switch selection and forwarding to use ioservid_t Roger Pau Monne
2019-09-10 12:31   ` Paul Durrant
2019-09-20 10:47     ` Jan Beulich
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 04/11] ioreq: add fields to allow internal ioreq servers Roger Pau Monne
2019-09-10 12:34   ` Paul Durrant
2019-09-20 10:53   ` Jan Beulich
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 05/11] ioreq: add internal ioreq initialization support Roger Pau Monne
2019-09-10 12:59   ` Paul Durrant
2019-09-26 10:49     ` Roger Pau Monné
2019-09-26 10:58       ` Paul Durrant
2019-09-20 11:15   ` Jan Beulich
2019-09-26 10:51     ` Roger Pau Monné
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 06/11] ioreq: allow dispatching ioreqs to internal servers Roger Pau Monne
2019-09-10 13:06   ` Paul Durrant
2019-09-20 11:35   ` Jan Beulich
2019-09-26 11:14     ` Roger Pau Monné
2019-09-26 13:17       ` Jan Beulich
2019-09-26 13:46         ` Roger Pau Monné
2019-09-26 15:13           ` Jan Beulich
2019-09-26 15:59             ` Roger Pau Monné
2019-09-27  8:17               ` Paul Durrant
2019-09-26 16:36       ` Roger Pau Monné
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 07/11] ioreq: allow registering internal ioreq server handler Roger Pau Monne
2019-09-10 13:12   ` Paul Durrant
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 08/11] ioreq: allow decoding accesses to MMCFG regions Roger Pau Monne
2019-09-10 13:37   ` Paul Durrant
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 09/11] vpci: register as an internal ioreq server Roger Pau Monne
2019-09-10 13:49   ` Paul Durrant
2019-09-26 15:07     ` Roger Pau Monné
2019-09-27  8:29       ` Paul Durrant
2019-09-27  8:45         ` Roger Pau Monné
2019-09-27  9:01           ` Paul Durrant
2019-09-27 10:46             ` Roger Pau Monné
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 10/11] ioreq: split the code to detect PCI config space accesses Roger Pau Monne
2019-09-10 14:06   ` Paul Durrant
2019-09-26 16:05     ` Roger Pau Monné
2019-09-03 16:14 ` [Xen-devel] [PATCH v2 11/11] ioreq: provide support for long-running operations Roger Pau Monne
2019-09-10 14:14   ` Paul Durrant
2019-09-10 14:28     ` Roger Pau Monné
2019-09-10 14:40       ` Paul Durrant [this message]

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=fccf7ba8098942e6b67f305ecaebad8b@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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).