mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: <xen-devel@lists.xen.org>, <linux-kernel@vger.kernel.org>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	David Vrabel <david.vrabel@citrix.com>
Subject: Re: [PATCH v1] p2m: use GNTTABOP_unmap_and_duplicate if available
Date: Sun, 4 Aug 2013 15:56:37 +0100	[thread overview]
Message-ID: <alpine.DEB.2.02.1308041552360.4893@kaball.uk.xensource.com> (raw)
In-Reply-To: <1375357597-6186-1-git-send-email-roger.pau@citrix.com>

[-- Attachment #1: Type: text/plain, Size: 4480 bytes --]

On Thu, 1 Aug 2013, Roger Pau Monne wrote:
> The new GNTTABOP_unmap_and_duplicate operation doesn't zero the
> mapping passed in new_addr, allowing us to perform batch unmaps in p2m
> code without requiring the use of a multicall.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: David Vrabel <david.vrabel@citrix.com>

It looks pretty good overall.


> Changes since RFC:
>  * Move shared code between _single and _batch to helper
>    functions.
> ---
> I don't currently have a NFS server (the one I had is currently not
> working due to SD card corruption) and I cannot set up one right now,
> so I've only tested this with a raw image stored in a local disk.
> ---
>  arch/x86/include/asm/xen/page.h     |    4 +-
>  arch/x86/xen/p2m.c                  |  154 +++++++++++++++++++++++++++++++----
>  drivers/xen/grant-table.c           |   24 ++----
>  include/xen/interface/grant_table.h |   22 +++++
>  4 files changed, 169 insertions(+), 35 deletions(-)
> 
> diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
> index 6aef9fb..ea1dce6 100644
> --- a/arch/x86/include/asm/xen/page.h
> +++ b/arch/x86/include/asm/xen/page.h
> @@ -51,8 +51,8 @@ extern unsigned long set_phys_range_identity(unsigned long pfn_s,
>  
>  extern int m2p_add_override(unsigned long mfn, struct page *page,
>  			    struct gnttab_map_grant_ref *kmap_op);
> -extern int m2p_remove_override(struct page *page,
> -				struct gnttab_map_grant_ref *kmap_op);
> +extern int m2p_remove_override(struct page **pages,
> +				struct gnttab_map_grant_ref *kmap_ops, int count);
>  extern struct page *m2p_find_override(unsigned long mfn);
>  extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
>  
> diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
> index 0d4ec35..e92636c 100644
> --- a/arch/x86/xen/p2m.c
> +++ b/arch/x86/xen/p2m.c
> @@ -154,6 +154,8 @@
>  #include <linux/hash.h>
>  #include <linux/sched.h>
>  #include <linux/seq_file.h>
> +#include <linux/slab.h>
> +#include <linux/hardirq.h>
>  
>  #include <asm/cache.h>
>  #include <asm/setup.h>
> @@ -853,6 +855,7 @@ bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
>  
>  static RESERVE_BRK_ARRAY(struct list_head, m2p_overrides, M2P_OVERRIDE_HASH);
>  static DEFINE_SPINLOCK(m2p_override_lock);
> +extern bool gnttab_supports_duplicate;

If you only use gnttab_supports_duplicate in the m2p, you might as well
make the variable static and initialize it from m2p_override_init.


>  static void __init m2p_override_init(void)
>  {
> @@ -933,8 +936,8 @@ int m2p_add_override(unsigned long mfn, struct page *page,
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(m2p_add_override);
> -int m2p_remove_override(struct page *page,
> -		struct gnttab_map_grant_ref *kmap_op)
> +
> +static inline int remove_page_override(struct page *page)
>  {
>  	unsigned long flags;
>  	unsigned long mfn;
> @@ -965,6 +968,49 @@ int m2p_remove_override(struct page *page,
>  	ClearPagePrivate(page);
>  
>  	set_phys_to_machine(pfn, page->index);
> +
> +	return 0;
> +}
> +
> +static inline int check_duplicate_mfn(struct page *page, unsigned long mfn)
> +{
> +	unsigned long pfn;
> +	int ret = 0;
> +
> +	/*
> +	 * p2m(m2p(mfn)) == FOREIGN_FRAME(mfn): the mfn is already present
> +	 * somewhere in this domain, even before being added to the
> +	 * m2p_override (see comment above in m2p_add_override).
> +	 * If there are no other entries in the m2p_override corresponding
> +	 * to this mfn, then remove the FOREIGN_FRAME_BIT from the p2m for
> +	 * the original pfn (the one shared by the frontend): the backend
> +	 * cannot do any IO on this page anymore because it has been
> +	 * unshared. Removing the FOREIGN_FRAME_BIT from the p2m entry of
> +	 * the original pfn causes mfn_to_pfn(mfn) to return the frontend
> +	 * pfn again.
> +	 */
> +	mfn &= ~FOREIGN_FRAME_BIT;
> +	ret = __get_user(pfn, &machine_to_phys_mapping[mfn]);
> +	if (ret == 0 && get_phys_to_machine(pfn) == FOREIGN_FRAME(mfn) &&
> +			m2p_find_override(mfn) == NULL)
> +		set_phys_to_machine(pfn, mfn);
> +
> +	return ret;
> +}

There is no need to keep check_duplicate_mfn separate from
remove_page_override, you can just "append" this code at the end of
remove_page_override.

  reply	other threads:[~2013-08-04 14:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01 11:46 Roger Pau Monne
2013-08-04 14:56 ` Stefano Stabellini [this message]
2013-08-27 10:10   ` Roger Pau Monné

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.02.1308041552360.4893@kaball.uk.xensource.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xen.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

all inboxes | Powered by JetHome®