diff options
author | David Vrabel <david.vrabel@citrix.com> | 2015-01-05 09:13:41 -0500 |
---|---|---|
committer | David Vrabel <david.vrabel@citrix.com> | 2015-01-28 09:03:10 -0500 |
commit | 853d0289340026b30f93fd0e768340221d4e605c (patch) | |
tree | 17d52ad1d7ae43007d8b664bbdba2a50db7dbb81 /arch/x86/xen | |
parent | d8ac3dd41aea245f65465449efc35dd3ac71e91d (diff) |
xen/grant-table: pre-populate kernel unmap ops for xen_gnttab_unmap_refs()
When unmapping grants, instead of converting the kernel map ops to
unmap ops on the fly, pre-populate the set of unmap ops.
This allows the grant unmap for the kernel mappings to be trivially
batched in the future.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Diffstat (limited to 'arch/x86/xen')
-rw-r--r-- | arch/x86/xen/p2m.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c index 70fb5075c901..df40b2888eae 100644 --- a/arch/x86/xen/p2m.c +++ b/arch/x86/xen/p2m.c | |||
@@ -816,7 +816,7 @@ static struct page *m2p_find_override(unsigned long mfn) | |||
816 | } | 816 | } |
817 | 817 | ||
818 | static int m2p_remove_override(struct page *page, | 818 | static int m2p_remove_override(struct page *page, |
819 | struct gnttab_map_grant_ref *kmap_op, | 819 | struct gnttab_unmap_grant_ref *kunmap_op, |
820 | unsigned long mfn) | 820 | unsigned long mfn) |
821 | { | 821 | { |
822 | unsigned long flags; | 822 | unsigned long flags; |
@@ -840,7 +840,7 @@ static int m2p_remove_override(struct page *page, | |||
840 | list_del(&page->lru); | 840 | list_del(&page->lru); |
841 | spin_unlock_irqrestore(&m2p_override_lock, flags); | 841 | spin_unlock_irqrestore(&m2p_override_lock, flags); |
842 | 842 | ||
843 | if (kmap_op != NULL) { | 843 | if (kunmap_op != NULL) { |
844 | if (!PageHighMem(page)) { | 844 | if (!PageHighMem(page)) { |
845 | struct multicall_space mcs; | 845 | struct multicall_space mcs; |
846 | struct gnttab_unmap_and_replace *unmap_op; | 846 | struct gnttab_unmap_and_replace *unmap_op; |
@@ -855,13 +855,13 @@ static int m2p_remove_override(struct page *page, | |||
855 | * issued. In this case handle is going to -1 because | 855 | * issued. In this case handle is going to -1 because |
856 | * it hasn't been modified yet. | 856 | * it hasn't been modified yet. |
857 | */ | 857 | */ |
858 | if (kmap_op->handle == -1) | 858 | if (kunmap_op->handle == -1) |
859 | xen_mc_flush(); | 859 | xen_mc_flush(); |
860 | /* | 860 | /* |
861 | * Now if kmap_op->handle is negative it means that the | 861 | * Now if kmap_op->handle is negative it means that the |
862 | * hypercall actually returned an error. | 862 | * hypercall actually returned an error. |
863 | */ | 863 | */ |
864 | if (kmap_op->handle == GNTST_general_error) { | 864 | if (kunmap_op->handle == GNTST_general_error) { |
865 | pr_warn("m2p_remove_override: pfn %lx mfn %lx, failed to modify kernel mappings", | 865 | pr_warn("m2p_remove_override: pfn %lx mfn %lx, failed to modify kernel mappings", |
866 | pfn, mfn); | 866 | pfn, mfn); |
867 | put_balloon_scratch_page(); | 867 | put_balloon_scratch_page(); |
@@ -873,9 +873,9 @@ static int m2p_remove_override(struct page *page, | |||
873 | mcs = __xen_mc_entry( | 873 | mcs = __xen_mc_entry( |
874 | sizeof(struct gnttab_unmap_and_replace)); | 874 | sizeof(struct gnttab_unmap_and_replace)); |
875 | unmap_op = mcs.args; | 875 | unmap_op = mcs.args; |
876 | unmap_op->host_addr = kmap_op->host_addr; | 876 | unmap_op->host_addr = kunmap_op->host_addr; |
877 | unmap_op->new_addr = scratch_page_address; | 877 | unmap_op->new_addr = scratch_page_address; |
878 | unmap_op->handle = kmap_op->handle; | 878 | unmap_op->handle = kunmap_op->handle; |
879 | 879 | ||
880 | MULTI_grant_table_op(mcs.mc, | 880 | MULTI_grant_table_op(mcs.mc, |
881 | GNTTABOP_unmap_and_replace, unmap_op, 1); | 881 | GNTTABOP_unmap_and_replace, unmap_op, 1); |
@@ -887,7 +887,6 @@ static int m2p_remove_override(struct page *page, | |||
887 | 887 | ||
888 | xen_mc_issue(PARAVIRT_LAZY_MMU); | 888 | xen_mc_issue(PARAVIRT_LAZY_MMU); |
889 | 889 | ||
890 | kmap_op->host_addr = 0; | ||
891 | put_balloon_scratch_page(); | 890 | put_balloon_scratch_page(); |
892 | } | 891 | } |
893 | } | 892 | } |
@@ -912,7 +911,7 @@ static int m2p_remove_override(struct page *page, | |||
912 | } | 911 | } |
913 | 912 | ||
914 | int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops, | 913 | int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops, |
915 | struct gnttab_map_grant_ref *kmap_ops, | 914 | struct gnttab_unmap_grant_ref *kunmap_ops, |
916 | struct page **pages, unsigned int count) | 915 | struct page **pages, unsigned int count) |
917 | { | 916 | { |
918 | int i, ret = 0; | 917 | int i, ret = 0; |
@@ -921,7 +920,7 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops, | |||
921 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 920 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
922 | return 0; | 921 | return 0; |
923 | 922 | ||
924 | if (kmap_ops && | 923 | if (kunmap_ops && |
925 | !in_interrupt() && | 924 | !in_interrupt() && |
926 | paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) { | 925 | paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) { |
927 | arch_enter_lazy_mmu_mode(); | 926 | arch_enter_lazy_mmu_mode(); |
@@ -942,8 +941,8 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops, | |||
942 | ClearPagePrivate(pages[i]); | 941 | ClearPagePrivate(pages[i]); |
943 | set_phys_to_machine(pfn, pages[i]->index); | 942 | set_phys_to_machine(pfn, pages[i]->index); |
944 | 943 | ||
945 | if (kmap_ops) | 944 | if (kunmap_ops) |
946 | ret = m2p_remove_override(pages[i], &kmap_ops[i], mfn); | 945 | ret = m2p_remove_override(pages[i], &kunmap_ops[i], mfn); |
947 | if (ret) | 946 | if (ret) |
948 | goto out; | 947 | goto out; |
949 | } | 948 | } |