xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Oleksandr Tyshchenko <olekstysh@gmail.com>
Cc: xen-devel@lists.xenproject.org,
	 Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	 Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	 Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	 Paul Durrant <paul@xen.org>, Julien Grall <julien.grall@arm.com>
Subject: Re: [PATCH V4 17/24] xen/ioreq: Introduce domain_has_ioreq_server()
Date: Thu, 14 Jan 2021 17:24:35 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.21.2101141723090.31265@sstabellini-ThinkPad-T480s> (raw)
In-Reply-To: <1610488352-18494-18-git-send-email-olekstysh@gmail.com>

On Tue, 12 Jan 2021, Oleksandr Tyshchenko wrote:
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> 
> This patch introduces a helper the main purpose of which is to check
> if a domain is using IOREQ server(s).
> 
> On Arm the current benefit is to avoid calling vcpu_ioreq_handle_completion()
> (which implies iterating over all possible IOREQ servers anyway)
> on every return in leave_hypervisor_to_guest() if there is no active
> servers for the particular domain.
> Also this helper will be used by one of the subsequent patches on Arm.
> 
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> CC: Julien Grall <julien.grall@arm.com>
> [On Arm only]
> Tested-by: Wei Chen <Wei.Chen@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> Please note, this is a split/cleanup/hardening of Julien's PoC:
> "Add support for Guest IO forwarding to a device emulator"
> 
> Changes RFC -> V1:
>    - new patch
> 
> Changes V1 -> V2:
>    - update patch description
>    - guard helper with CONFIG_IOREQ_SERVER
>    - remove "hvm" prefix
>    - modify helper to just return d->arch.hvm.ioreq_server.nr_servers
>    - put suitable ASSERT()s
>    - use ASSERT(d->ioreq_server.server[id] ? !s : !!s) in set_ioreq_server()
>    - remove d->ioreq_server.nr_servers = 0 from hvm_ioreq_init()
> 
> Changes V2 -> V3:
>    - update patch description
>    - remove ASSERT()s from the helper, add a comment
>    - use #ifdef CONFIG_IOREQ_SERVER inside function body
>    - use new ASSERT() construction in set_ioreq_server()
> 
> Changes V3 -> V4:
>    - update patch description
>    - drop per-domain variable "nr_servers"
>    - reimplement a helper to count the non-NULL entries
>    - make the helper out-of-line
> ---
>  xen/arch/arm/traps.c    | 15 +++++++++------
>  xen/common/ioreq.c      | 16 ++++++++++++++++
>  xen/include/xen/ioreq.h |  2 ++
>  3 files changed, 27 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 4a83e1e..35094d8 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -2262,14 +2262,17 @@ static bool check_for_vcpu_work(void)
>      struct vcpu *v = current;
>  
>  #ifdef CONFIG_IOREQ_SERVER
> -    bool handled;
> +    if ( domain_has_ioreq_server(v->domain) )
> +    {
> +        bool handled;
>  
> -    local_irq_enable();
> -    handled = vcpu_ioreq_handle_completion(v);
> -    local_irq_disable();
> +        local_irq_enable();
> +        handled = vcpu_ioreq_handle_completion(v);
> +        local_irq_disable();
>  
> -    if ( !handled )
> -        return true;
> +        if ( !handled )
> +            return true;
> +    }
>  #endif
>  
>      if ( likely(!v->arch.need_flush_to_ram) )
> diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c
> index d5f4dd3..59f4990 100644
> --- a/xen/common/ioreq.c
> +++ b/xen/common/ioreq.c
> @@ -80,6 +80,22 @@ static ioreq_t *get_ioreq(struct ioreq_server *s, struct vcpu *v)
>      return &p->vcpu_ioreq[v->vcpu_id];
>  }
>  
> +/*
> + * This should only be used when d == current->domain or when they're
> + * distinct and d is paused. Otherwise the result is stale before
> + * the caller can inspect it.
> + */
> +bool domain_has_ioreq_server(const struct domain *d)
> +{
> +    const struct ioreq_server *s;
> +    unsigned int id;
> +
> +    FOR_EACH_IOREQ_SERVER(d, id, s)
> +        return true;
> +
> +    return false;
> +}
> +
>  static struct ioreq_vcpu *get_pending_vcpu(const struct vcpu *v,
>                                             struct ioreq_server **srvp)
>  {
> diff --git a/xen/include/xen/ioreq.h b/xen/include/xen/ioreq.h
> index ec7e98d..f0908af 100644
> --- a/xen/include/xen/ioreq.h
> +++ b/xen/include/xen/ioreq.h
> @@ -81,6 +81,8 @@ static inline bool ioreq_needs_completion(const ioreq_t *ioreq)
>  #define HANDLE_BUFIOREQ(s) \
>      ((s)->bufioreq_handling != HVM_IOREQSRV_BUFIOREQ_OFF)
>  
> +bool domain_has_ioreq_server(const struct domain *d);
> +
>  bool vcpu_ioreq_pending(struct vcpu *v);
>  bool vcpu_ioreq_handle_completion(struct vcpu *v);
>  bool is_ioreq_server_page(struct domain *d, const struct page_info *page);
> -- 
> 2.7.4
> 


  reply	other threads:[~2021-01-15  1:24 UTC|newest]

Thread overview: 144+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 21:52 [PATCH V4 00/24] IOREQ feature (+ virtio-mmio) on Arm Oleksandr Tyshchenko
2021-01-12 21:52 ` [PATCH V4 01/24] x86/ioreq: Prepare IOREQ feature for making it common Oleksandr Tyshchenko
2021-01-15 15:16   ` Julien Grall
2021-01-15 16:41   ` Jan Beulich
2021-01-16  9:48     ` Oleksandr
2021-01-18  8:22   ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 02/24] x86/ioreq: Add IOREQ_STATUS_* #define-s and update code for moving Oleksandr Tyshchenko
2021-01-15 15:17   ` Julien Grall
2021-01-18  8:24   ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 03/24] x86/ioreq: Provide out-of-line wrapper for the handle_mmio() Oleksandr Tyshchenko
2021-01-15 14:48   ` Alex Bennée
2021-01-15 15:19   ` Julien Grall
2021-01-18  8:29   ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 04/24] xen/ioreq: Make x86's IOREQ feature common Oleksandr Tyshchenko
2021-01-15 14:55   ` Alex Bennée
2021-01-15 15:23   ` Julien Grall
2021-01-18  8:48   ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 05/24] xen/ioreq: Make x86's hvm_ioreq_needs_completion() common Oleksandr Tyshchenko
2021-01-15 15:25   ` Julien Grall
2021-01-20  8:48   ` Alex Bennée
2021-01-20  9:31     ` Julien Grall
2021-01-12 21:52 ` [PATCH V4 06/24] xen/ioreq: Make x86's hvm_mmio_first(last)_byte() common Oleksandr Tyshchenko
2021-01-15 15:34   ` Julien Grall
2021-01-20  8:57   ` Alex Bennée
2021-01-20 16:15   ` Jan Beulich
2021-01-20 20:47     ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 07/24] xen/ioreq: Make x86's hvm_ioreq_(page/vcpu/server) structs common Oleksandr Tyshchenko
2021-01-15 15:36   ` Julien Grall
2021-01-18  8:59   ` Paul Durrant
2021-01-20  8:58   ` Alex Bennée
2021-01-12 21:52 ` [PATCH V4 08/24] xen/ioreq: Move x86's ioreq_server to struct domain Oleksandr Tyshchenko
2021-01-15 15:44   ` Julien Grall
2021-01-18  9:09   ` Paul Durrant
2021-01-20  9:00   ` Alex Bennée
2021-01-12 21:52 ` [PATCH V4 09/24] xen/ioreq: Make x86's IOREQ related dm-op handling common Oleksandr Tyshchenko
2021-01-18  9:17   ` Paul Durrant
2021-01-18 10:19     ` Oleksandr
2021-01-18 10:34       ` Paul Durrant
2021-01-20 16:21   ` Jan Beulich
2021-01-21 10:23     ` Oleksandr
2021-01-21 10:27       ` Jan Beulich
2021-01-21 11:13         ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 10/24] xen/ioreq: Move x86's io_completion/io_req fields to struct vcpu Oleksandr Tyshchenko
2021-01-15 19:34   ` Julien Grall
2021-01-18  9:35   ` Paul Durrant
2021-01-20 16:24   ` Jan Beulich
2021-01-12 21:52 ` [PATCH V4 11/24] xen/mm: Make x86's XENMEM_resource_ioreq_server handling common Oleksandr Tyshchenko
2021-01-14  3:58   ` Wei Chen
2021-01-14 15:31     ` Oleksandr
2021-01-15 14:35       ` Alex Bennée
2021-01-18 17:42         ` Oleksandr
2021-01-18  9:38   ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 12/24] xen/ioreq: Remove "hvm" prefixes from involved function names Oleksandr Tyshchenko
2021-01-18  9:55   ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 13/24] xen/ioreq: Use guest_cmpxchg64() instead of cmpxchg() Oleksandr Tyshchenko
2021-01-15 19:37   ` Julien Grall
2021-01-17 11:32     ` Oleksandr
2021-01-18 10:00   ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 14/24] arm/ioreq: Introduce arch specific bits for IOREQ/DM features Oleksandr Tyshchenko
2021-01-15  0:55   ` Stefano Stabellini
2021-01-17 12:45     ` Oleksandr
2021-01-20  0:23       ` Stefano Stabellini
2021-01-21  9:51         ` Oleksandr
2021-01-15 20:26   ` Julien Grall
2021-01-17 17:11     ` Oleksandr
2021-01-17 18:07       ` Julien Grall
2021-01-17 18:52         ` Oleksandr
2021-01-18 19:17           ` Julien Grall
2021-01-19 15:20             ` Oleksandr
2021-01-20  0:50               ` Stefano Stabellini
2021-01-20 15:57                 ` Julien Grall
2021-01-20 19:47                   ` Stefano Stabellini
2021-01-21  9:31                     ` Oleksandr
2021-01-21 21:34                       ` Stefano Stabellini
2021-01-20 15:50           ` Julien Grall
2021-01-21  8:50             ` Oleksandr
2021-01-27 10:24               ` Jan Beulich
2021-01-27 12:22                 ` Oleksandr
2021-01-27 12:52                   ` Jan Beulich
2021-01-18 10:44       ` Jan Beulich
2021-01-18 15:52         ` Oleksandr
2021-01-18 16:00           ` Jan Beulich
2021-01-18 16:29             ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 15/24] xen/arm: Stick around in leave_hypervisor_to_guest until I/O has completed Oleksandr Tyshchenko
2021-01-15  1:12   ` Stefano Stabellini
2021-01-15 20:55   ` Julien Grall
2021-01-17 20:23     ` Oleksandr
2021-01-18 10:57       ` Julien Grall
2021-01-18 13:23         ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 16/24] xen/mm: Handle properly reference in set_foreign_p2m_entry() on Arm Oleksandr Tyshchenko
2021-01-15  1:19   ` Stefano Stabellini
2021-01-15 20:59   ` Julien Grall
2021-01-21 13:57   ` Jan Beulich
2021-01-21 18:42     ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 17/24] xen/ioreq: Introduce domain_has_ioreq_server() Oleksandr Tyshchenko
2021-01-15  1:24   ` Stefano Stabellini [this message]
2021-01-18 10:23   ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 18/24] xen/dm: Introduce xendevicemodel_set_irq_level DM op Oleksandr Tyshchenko
2021-01-15  1:32   ` Stefano Stabellini
2021-01-12 21:52 ` [PATCH V4 19/24] xen/arm: io: Abstract sign-extension Oleksandr Tyshchenko
2021-01-15  1:35   ` Stefano Stabellini
2021-01-12 21:52 ` [PATCH V4 20/24] xen/arm: io: Harden sign extension check Oleksandr Tyshchenko
2021-01-15  1:48   ` Stefano Stabellini
2021-01-22 10:15   ` Volodymyr Babchuk
2021-01-12 21:52 ` [PATCH V4 21/24] xen/ioreq: Make x86's send_invalidate_req() common Oleksandr Tyshchenko
2021-01-18 10:31   ` Paul Durrant
2021-01-21 14:02     ` Jan Beulich
2021-01-12 21:52 ` [PATCH V4 22/24] xen/arm: Add mapcache invalidation handling Oleksandr Tyshchenko
2021-01-15  2:11   ` Stefano Stabellini
2021-01-21 19:47     ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 23/24] libxl: Introduce basic virtio-mmio support on Arm Oleksandr Tyshchenko
2021-01-15 21:30   ` Julien Grall
2021-01-17 22:22     ` Oleksandr
2021-01-20 16:40       ` Julien Grall
2021-01-20 20:35         ` Stefano Stabellini
2021-02-09 21:04         ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 24/24] [RFC] libxl: Add support for virtio-disk configuration Oleksandr Tyshchenko
2021-01-14 17:20   ` Ian Jackson
2021-01-16  9:05     ` Oleksandr
2021-01-15 22:01   ` Julien Grall
2021-01-18  8:32     ` Oleksandr
2021-01-20 17:05       ` Julien Grall
2021-02-10  9:02         ` Oleksandr
2021-03-06 19:52           ` Julien Grall
2021-01-14  3:55 ` [PATCH V4 00/24] IOREQ feature (+ virtio-mmio) on Arm Wei Chen
2021-01-14 15:23   ` Oleksandr
2021-01-07 14:35     ` [ANNOUNCE] Xen 4.15 release schedule and feature tracking Ian Jackson
2021-01-07 15:45       ` Oleksandr
2021-01-14 16:11         ` [PATCH V4 00/24] IOREQ feature (+ virtio-mmio) on Arm Ian Jackson
2021-01-14 18:41           ` Oleksandr
2021-01-14 16:06       ` [ANNOUNCE] Xen 4.15 release schedule and feature tracking Ian Jackson
2021-01-14 19:02         ` Andrew Cooper
2021-01-15  9:57           ` Jan Beulich
2021-01-15 10:00             ` Julien Grall
2021-01-15 10:52             ` Andrew Cooper
2021-01-15 10:59               ` Andrew Cooper
2021-01-15 11:08                 ` Jan Beulich
2021-01-15 10:43           ` Bertrand Marquis
2021-01-15 15:14           ` Lengyel, Tamas
2021-01-28 22:55             ` Dario Faggioli
2021-01-28 18:26           ` Dario Faggioli
2021-01-28 22:15             ` Dario Faggioli
2021-01-29  8:38             ` Jan Beulich
2021-01-29  9:22               ` Dario Faggioli

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=alpine.DEB.2.21.2101141723090.31265@sstabellini-ThinkPad-T480s \
    --to=sstabellini@kernel.org \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=julien.grall@arm.com \
    --cc=julien@xen.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=olekstysh@gmail.com \
    --cc=paul@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).