All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls
@ 2012-03-27 13:52 Stefano Stabellini
  2012-03-27 13:52 ` [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe Stefano Stabellini
  2012-03-27 14:31 ` [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls Konrad Rzeszutek Wilk
  0 siblings, 2 replies; 8+ messages in thread
From: Stefano Stabellini @ 2012-03-27 13:52 UTC (permalink / raw)
  To: konrad.wilk
  Cc: Stefano.Stabellini, linux-kernel, xen-devel, Stefano Stabellini

This patch is a significant performance improvement for the
m2p_override.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 drivers/block/xen-blkback/blkback.c |    4 ++++
 drivers/xen/grant-table.c           |    8 ++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 0088bf6..60abff6 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -342,6 +342,7 @@ static void xen_blkbk_unmap(struct pending_req *req)
 	 * Note, we use invcount, so nr->pages, so we can't index
 	 * using vaddr(req, i).
 	 */
+	arch_enter_lazy_mmu_mode();
 	for (i = 0; i < invcount; i++) {
 		ret = m2p_remove_override(
 			virt_to_page(unmap[i].host_addr), false);
@@ -351,6 +352,7 @@ static void xen_blkbk_unmap(struct pending_req *req)
 			continue;
 		}
 	}
+	arch_leave_lazy_mmu_mode();
 }
 
 static int xen_blkbk_map(struct blkif_request *req,
@@ -386,6 +388,7 @@ static int xen_blkbk_map(struct blkif_request *req,
 	 * so that when we access vaddr(pending_req,i) it has the contents of
 	 * the page from the other domain.
 	 */
+	arch_enter_lazy_mmu_mode();
 	for (i = 0; i < nseg; i++) {
 		if (unlikely(map[i].status != 0)) {
 			pr_debug(DRV_PFX "invalid buffer -- could not remap it\n");
@@ -410,6 +413,7 @@ static int xen_blkbk_map(struct blkif_request *req,
 		seg[i].buf  = map[i].dev_bus_addr |
 			(req->u.rw.seg[i].first_sect << 9);
 	}
+	arch_leave_lazy_mmu_mode();
 	return ret;
 }
 
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index b4d4eac..c7dc2d6 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -751,6 +751,8 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return ret;
 
+	arch_enter_lazy_mmu_mode();
+
 	for (i = 0; i < count; i++) {
 		/* Do not add to override if the map failed. */
 		if (map_ops[i].status)
@@ -769,6 +771,8 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 			return ret;
 	}
 
+	arch_leave_lazy_mmu_mode();
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(gnttab_map_refs);
@@ -785,12 +789,16 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return ret;
 
+	arch_enter_lazy_mmu_mode();
+
 	for (i = 0; i < count; i++) {
 		ret = m2p_remove_override(pages[i], clear_pte);
 		if (ret)
 			return ret;
 	}
 
+	arch_leave_lazy_mmu_mode();
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(gnttab_unmap_refs);
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe
  2012-03-27 13:52 [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls Stefano Stabellini
@ 2012-03-27 13:52 ` Stefano Stabellini
  2012-03-27 14:26   ` Konrad Rzeszutek Wilk
  2012-03-27 14:31 ` [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls Konrad Rzeszutek Wilk
  1 sibling, 1 reply; 8+ messages in thread
From: Stefano Stabellini @ 2012-03-27 13:52 UTC (permalink / raw)
  To: konrad.wilk
  Cc: Stefano.Stabellini, linux-kernel, xen-devel, Stefano Stabellini

Use list_for_each_entry_safe and remove the spin_lock acquisition in
m2p_find_override.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/x86/xen/p2m.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 1b267e7..7ed8cc3 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -809,21 +809,17 @@ struct page *m2p_find_override(unsigned long mfn)
 {
 	unsigned long flags;
 	struct list_head *bucket = &m2p_overrides[mfn_hash(mfn)];
-	struct page *p, *ret;
+	struct page *p, *t, *ret;
 
 	ret = NULL;
 
-	spin_lock_irqsave(&m2p_override_lock, flags);
-
-	list_for_each_entry(p, bucket, lru) {
+	list_for_each_entry_safe(p, t, bucket, lru) {
 		if (page_private(p) == mfn) {
 			ret = p;
 			break;
 		}
 	}
 
-	spin_unlock_irqrestore(&m2p_override_lock, flags);
-
 	return ret;
 }
 
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe
  2012-03-27 13:52 ` [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe Stefano Stabellini
@ 2012-03-27 14:26   ` Konrad Rzeszutek Wilk
  2012-03-27 16:37     ` Stefano Stabellini
  0 siblings, 1 reply; 8+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-03-27 14:26 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: linux-kernel, xen-devel

On Tue, Mar 27, 2012 at 02:52:44PM +0100, Stefano Stabellini wrote:
> Use list_for_each_entry_safe and remove the spin_lock acquisition in
> m2p_find_override.

So this would allow us to get stale entries. Is that OK?

> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
>  arch/x86/xen/p2m.c |    8 ++------
>  1 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
> index 1b267e7..7ed8cc3 100644
> --- a/arch/x86/xen/p2m.c
> +++ b/arch/x86/xen/p2m.c
> @@ -809,21 +809,17 @@ struct page *m2p_find_override(unsigned long mfn)
>  {
>  	unsigned long flags;
>  	struct list_head *bucket = &m2p_overrides[mfn_hash(mfn)];
> -	struct page *p, *ret;
> +	struct page *p, *t, *ret;
>  
>  	ret = NULL;
>  
> -	spin_lock_irqsave(&m2p_override_lock, flags);
> -
> -	list_for_each_entry(p, bucket, lru) {
> +	list_for_each_entry_safe(p, t, bucket, lru) {
>  		if (page_private(p) == mfn) {
>  			ret = p;
>  			break;
>  		}
>  	}
>  
> -	spin_unlock_irqrestore(&m2p_override_lock, flags);
> -
>  	return ret;
>  }
>  
> -- 
> 1.7.2.5

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls
  2012-03-27 13:52 [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls Stefano Stabellini
  2012-03-27 13:52 ` [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe Stefano Stabellini
@ 2012-03-27 14:31 ` Konrad Rzeszutek Wilk
  2012-03-27 16:56   ` Stefano Stabellini
  1 sibling, 1 reply; 8+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-03-27 14:31 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: linux-kernel, xen-devel

On Tue, Mar 27, 2012 at 02:52:43PM +0100, Stefano Stabellini wrote:
> This patch is a significant performance improvement for the

How much? 10%? 90%?

> m2p_override.

Can you explain what those calls do in the git commit description please?

> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
>  drivers/block/xen-blkback/blkback.c |    4 ++++
>  drivers/xen/grant-table.c           |    8 ++++++++
>  2 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
> index 0088bf6..60abff6 100644
> --- a/drivers/block/xen-blkback/blkback.c
> +++ b/drivers/block/xen-blkback/blkback.c
> @@ -342,6 +342,7 @@ static void xen_blkbk_unmap(struct pending_req *req)
>  	 * Note, we use invcount, so nr->pages, so we can't index
>  	 * using vaddr(req, i).
>  	 */
> +	arch_enter_lazy_mmu_mode();
>  	for (i = 0; i < invcount; i++) {
>  		ret = m2p_remove_override(
>  			virt_to_page(unmap[i].host_addr), false);
> @@ -351,6 +352,7 @@ static void xen_blkbk_unmap(struct pending_req *req)
>  			continue;
>  		}
>  	}
> +	arch_leave_lazy_mmu_mode();
>  }
>  
>  static int xen_blkbk_map(struct blkif_request *req,
> @@ -386,6 +388,7 @@ static int xen_blkbk_map(struct blkif_request *req,
>  	 * so that when we access vaddr(pending_req,i) it has the contents of
>  	 * the page from the other domain.
>  	 */
> +	arch_enter_lazy_mmu_mode();
>  	for (i = 0; i < nseg; i++) {
>  		if (unlikely(map[i].status != 0)) {
>  			pr_debug(DRV_PFX "invalid buffer -- could not remap it\n");
> @@ -410,6 +413,7 @@ static int xen_blkbk_map(struct blkif_request *req,
>  		seg[i].buf  = map[i].dev_bus_addr |
>  			(req->u.rw.seg[i].first_sect << 9);
>  	}
> +	arch_leave_lazy_mmu_mode();
>  	return ret;
>  }
>  
> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
> index b4d4eac..c7dc2d6 100644
> --- a/drivers/xen/grant-table.c
> +++ b/drivers/xen/grant-table.c
> @@ -751,6 +751,8 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
>  	if (xen_feature(XENFEAT_auto_translated_physmap))
>  		return ret;
>  
> +	arch_enter_lazy_mmu_mode();
> +
>  	for (i = 0; i < count; i++) {
>  		/* Do not add to override if the map failed. */
>  		if (map_ops[i].status)
> @@ -769,6 +771,8 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
>  			return ret;
>  	}
>  
> +	arch_leave_lazy_mmu_mode();
> +
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(gnttab_map_refs);
> @@ -785,12 +789,16 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
>  	if (xen_feature(XENFEAT_auto_translated_physmap))
>  		return ret;
>  
> +	arch_enter_lazy_mmu_mode();
> +
>  	for (i = 0; i < count; i++) {
>  		ret = m2p_remove_override(pages[i], clear_pte);
>  		if (ret)
>  			return ret;
>  	}
>  
> +	arch_leave_lazy_mmu_mode();
> +
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(gnttab_unmap_refs);
> -- 
> 1.7.2.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe
  2012-03-27 14:26   ` Konrad Rzeszutek Wilk
@ 2012-03-27 16:37     ` Stefano Stabellini
  2012-03-27 17:59       ` [Xen-devel] " Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 8+ messages in thread
From: Stefano Stabellini @ 2012-03-27 16:37 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: Stefano Stabellini, linux-kernel, xen-devel

On Tue, 27 Mar 2012, Konrad Rzeszutek Wilk wrote:
> On Tue, Mar 27, 2012 at 02:52:44PM +0100, Stefano Stabellini wrote:
> > Use list_for_each_entry_safe and remove the spin_lock acquisition in
> > m2p_find_override.
> 
> So this would allow us to get stale entries. Is that OK?

I think it is reasonable.
In practice we should never get an m2p_find_override call looking for an
entry that we are about to add/delete.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls
  2012-03-27 14:31 ` [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls Konrad Rzeszutek Wilk
@ 2012-03-27 16:56   ` Stefano Stabellini
  0 siblings, 0 replies; 8+ messages in thread
From: Stefano Stabellini @ 2012-03-27 16:56 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: Stefano Stabellini, linux-kernel, xen-devel

On Tue, 27 Mar 2012, Konrad Rzeszutek Wilk wrote:
> On Tue, Mar 27, 2012 at 02:52:43PM +0100, Stefano Stabellini wrote:
> > This patch is a significant performance improvement for the
> 
> How much? 10%? 90%?

I think you are overestimating the meaning of "significant" :)

It is about 6% using grant_table and 2% using blkback.


> > m2p_override.
> 
> Can you explain what those calls do in the git commit description please?

Right, I have been way too concise.

Each m2p_add/remove_override call issues a MULTI_grant_table_op and a
__flush_tlb_single if kmap_op != NULL.
Batching all the calls together is a great performance benefit because
it means issuing one hypercall total rather than two hypercall per page.

I'll resend with a proper commit message.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe
  2012-03-27 16:37     ` Stefano Stabellini
@ 2012-03-27 17:59       ` Konrad Rzeszutek Wilk
  2012-03-29 14:03         ` Stefano Stabellini
  0 siblings, 1 reply; 8+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-03-27 17:59 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: Konrad Rzeszutek Wilk, xen-devel, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 862 bytes --]

On Tue, Mar 27, 2012 at 05:37:07PM +0100, Stefano Stabellini wrote:
> On Tue, 27 Mar 2012, Konrad Rzeszutek Wilk wrote:
> > On Tue, Mar 27, 2012 at 02:52:44PM +0100, Stefano Stabellini wrote:
> > > Use list_for_each_entry_safe and remove the spin_lock acquisition in
> > > m2p_find_override.
> > 
> > So this would allow us to get stale entries. Is that OK?
> 
> I think it is reasonable.
> In practice we should never get an m2p_find_override call looking for an
> entry that we are about to add/delete.

Why don't you add that in the comment and also fix:

/home/konrad/ssd/linux/arch/x86/xen/p2m.c: In function
‘m2p_find_override’:
/home/konrad/ssd/linux/arch/x86/xen/p2m.c:810: warning: unused variable
‘flags’


> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe
  2012-03-27 17:59       ` [Xen-devel] " Konrad Rzeszutek Wilk
@ 2012-03-29 14:03         ` Stefano Stabellini
  0 siblings, 0 replies; 8+ messages in thread
From: Stefano Stabellini @ 2012-03-29 14:03 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Stefano Stabellini, Konrad Rzeszutek Wilk, xen-devel, linux-kernel

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

On Tue, 27 Mar 2012, Konrad Rzeszutek Wilk wrote:
> On Tue, Mar 27, 2012 at 05:37:07PM +0100, Stefano Stabellini wrote:
> > On Tue, 27 Mar 2012, Konrad Rzeszutek Wilk wrote:
> > > On Tue, Mar 27, 2012 at 02:52:44PM +0100, Stefano Stabellini wrote:
> > > > Use list_for_each_entry_safe and remove the spin_lock acquisition in
> > > > m2p_find_override.
> > > 
> > > So this would allow us to get stale entries. Is that OK?
> > 
> > I think it is reasonable.
> > In practice we should never get an m2p_find_override call looking for an
> > entry that we are about to add/delete.
> 
> Why don't you add that in the comment and also fix:
> 
> /home/konrad/ssd/linux/arch/x86/xen/p2m.c: In function
> ‘m2p_find_override’:
> /home/konrad/ssd/linux/arch/x86/xen/p2m.c:810: warning: unused variable
> ‘flags’

Ooops. I'll do that.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-03-29 14:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-27 13:52 [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls Stefano Stabellini
2012-03-27 13:52 ` [PATCH 2/2] m2p_find_override: use list_for_each_entry_safe Stefano Stabellini
2012-03-27 14:26   ` Konrad Rzeszutek Wilk
2012-03-27 16:37     ` Stefano Stabellini
2012-03-27 17:59       ` [Xen-devel] " Konrad Rzeszutek Wilk
2012-03-29 14:03         ` Stefano Stabellini
2012-03-27 14:31 ` [PATCH 1/2] xen: enter/exit lazy_mmu_mode around m2p_override calls Konrad Rzeszutek Wilk
2012-03-27 16:56   ` Stefano Stabellini

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.