diff options
author | Stefano Stabellini <Stefano.Stabellini@eu.citrix.com> | 2012-04-24 06:55:43 -0400 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-05-07 15:33:19 -0400 |
commit | f62805f1f30a40e354bd036b4cb799863a39be4b (patch) | |
tree | 8b2005ae7c4ba79c7b711a33da3b571d1f8c225e /drivers/xen | |
parent | 211063dc159695bd6072c5393e9bc729481c6ede (diff) |
xen: enter/exit lazy_mmu_mode around m2p_override calls
This patch is a significant performance improvement for the
m2p_override: about 6% using the gntdev device.
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.
If paravirt_lazy_mode is set PARAVIRT_LAZY_MMU, all these calls are
going to be batched together, otherwise they are issued one at a time.
Adding arch_enter_lazy_mmu_mode/arch_leave_lazy_mmu_mode around the
m2p_add/remove_override calls forces paravirt_lazy_mode to
PARAVIRT_LAZY_MMU, therefore makes sure that they are always batched.
However it is not safe to call arch_enter_lazy_mmu_mode if we are in
interrupt context or if we are already in PARAVIRT_LAZY_MMU mode, so
check for both conditions before doing so.
Changes in v4:
- rebased on 3.4-rc4: all the m2p_override users call gnttab_unmap_refs
and gnttab_map_refs;
- check whether we are in interrupt context and the lazy_mode we are in
before calling arch_enter/leave_lazy_mmu_mode.
Changes in v3:
- do not call arch_enter/leave_lazy_mmu_mode in xen_blkbk_unmap, that
can be called in interrupt context.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
[v5: s/int lazy/bool lazy/]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/grant-table.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 9f514bb561af..487e468f9ded 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/vmalloc.h> | 38 | #include <linux/vmalloc.h> |
39 | #include <linux/uaccess.h> | 39 | #include <linux/uaccess.h> |
40 | #include <linux/io.h> | 40 | #include <linux/io.h> |
41 | #include <linux/hardirq.h> | ||
41 | 42 | ||
42 | #include <xen/xen.h> | 43 | #include <xen/xen.h> |
43 | #include <xen/interface/xen.h> | 44 | #include <xen/interface/xen.h> |
@@ -827,6 +828,7 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | |||
827 | struct page **pages, unsigned int count) | 828 | struct page **pages, unsigned int count) |
828 | { | 829 | { |
829 | int i, ret; | 830 | int i, ret; |
831 | bool lazy = false; | ||
830 | pte_t *pte; | 832 | pte_t *pte; |
831 | unsigned long mfn; | 833 | unsigned long mfn; |
832 | 834 | ||
@@ -837,6 +839,11 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | |||
837 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 839 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
838 | return ret; | 840 | return ret; |
839 | 841 | ||
842 | if (!in_interrupt() && paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) { | ||
843 | arch_enter_lazy_mmu_mode(); | ||
844 | lazy = true; | ||
845 | } | ||
846 | |||
840 | for (i = 0; i < count; i++) { | 847 | for (i = 0; i < count; i++) { |
841 | /* Do not add to override if the map failed. */ | 848 | /* Do not add to override if the map failed. */ |
842 | if (map_ops[i].status) | 849 | if (map_ops[i].status) |
@@ -855,6 +862,9 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | |||
855 | return ret; | 862 | return ret; |
856 | } | 863 | } |
857 | 864 | ||
865 | if (lazy) | ||
866 | arch_leave_lazy_mmu_mode(); | ||
867 | |||
858 | return ret; | 868 | return ret; |
859 | } | 869 | } |
860 | EXPORT_SYMBOL_GPL(gnttab_map_refs); | 870 | EXPORT_SYMBOL_GPL(gnttab_map_refs); |
@@ -863,6 +873,7 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | |||
863 | struct page **pages, unsigned int count, bool clear_pte) | 873 | struct page **pages, unsigned int count, bool clear_pte) |
864 | { | 874 | { |
865 | int i, ret; | 875 | int i, ret; |
876 | bool lazy = false; | ||
866 | 877 | ||
867 | ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap_ops, count); | 878 | ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap_ops, count); |
868 | if (ret) | 879 | if (ret) |
@@ -871,12 +882,20 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | |||
871 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 882 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
872 | return ret; | 883 | return ret; |
873 | 884 | ||
885 | if (!in_interrupt() && paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) { | ||
886 | arch_enter_lazy_mmu_mode(); | ||
887 | lazy = true; | ||
888 | } | ||
889 | |||
874 | for (i = 0; i < count; i++) { | 890 | for (i = 0; i < count; i++) { |
875 | ret = m2p_remove_override(pages[i], clear_pte); | 891 | ret = m2p_remove_override(pages[i], clear_pte); |
876 | if (ret) | 892 | if (ret) |
877 | return ret; | 893 | return ret; |
878 | } | 894 | } |
879 | 895 | ||
896 | if (lazy) | ||
897 | arch_leave_lazy_mmu_mode(); | ||
898 | |||
880 | return ret; | 899 | return ret; |
881 | } | 900 | } |
882 | EXPORT_SYMBOL_GPL(gnttab_unmap_refs); | 901 | EXPORT_SYMBOL_GPL(gnttab_unmap_refs); |