]> www.infradead.org Git - users/willy/xarray.git/commitdiff
s390: Convert vsie to XArray
authorMatthew Wilcox <willy@infradead.org>
Wed, 24 Oct 2018 13:32:01 +0000 (09:32 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 8 Aug 2019 18:01:05 +0000 (14:01 -0400)
No locking conversion, just using the new API.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
arch/s390/include/asm/kvm_host.h
arch/s390/kvm/vsie.c

index abe60268335d2027df8a36b0517755d25e1789fa..64127d4721067b0ae4a7bc8cc73288daa21913b6 100644 (file)
@@ -820,7 +820,7 @@ struct sie_page2 {
 
 struct kvm_s390_vsie {
        struct mutex mutex;
-       struct radix_tree_root addr_to_page;
+       struct xarray addr_to_page;
        int page_count;
        int next;
        struct page *pages[KVM_MAX_VCPUS];
index 076090f9e666c56139c70f02e59d41b598ef4773..c008b4064b72d7b55591e7448f6e4075db5e8585 100644 (file)
@@ -1219,9 +1219,7 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr)
        struct page *page;
        int nr_vcpus;
 
-       rcu_read_lock();
-       page = radix_tree_lookup(&kvm->arch.vsie.addr_to_page, addr >> 9);
-       rcu_read_unlock();
+       page = xa_load(&kvm->arch.vsie.addr_to_page, addr >> 9);
        if (page) {
                if (page_ref_inc_return(page) == 2)
                        return page_to_virt(page);
@@ -1254,11 +1252,12 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr)
                        kvm->arch.vsie.next++;
                        kvm->arch.vsie.next %= nr_vcpus;
                }
-               radix_tree_delete(&kvm->arch.vsie.addr_to_page, page->index >> 9);
+               xa_erase(&kvm->arch.vsie.addr_to_page, page->index >> 9);
        }
        page->index = addr;
        /* double use of the same address */
-       if (radix_tree_insert(&kvm->arch.vsie.addr_to_page, addr >> 9, page)) {
+       if (xa_insert(&kvm->arch.vsie.addr_to_page, addr >> 9, page,
+                               GFP_KERNEL)) {
                page_ref_dec(page);
                mutex_unlock(&kvm->arch.vsie.mutex);
                return NULL;
@@ -1338,7 +1337,7 @@ out_put:
 void kvm_s390_vsie_init(struct kvm *kvm)
 {
        mutex_init(&kvm->arch.vsie.mutex);
-       INIT_RADIX_TREE(&kvm->arch.vsie.addr_to_page, GFP_KERNEL);
+       xa_init(&kvm->arch.vsie.addr_to_page);
 }
 
 /* Destroy the vsie data structures. To be called when a vm is destroyed. */
@@ -1354,8 +1353,7 @@ void kvm_s390_vsie_destroy(struct kvm *kvm)
                kvm->arch.vsie.pages[i] = NULL;
                vsie_page = page_to_virt(page);
                release_gmap_shadow(vsie_page);
-               /* free the radix tree entry */
-               radix_tree_delete(&kvm->arch.vsie.addr_to_page, page->index >> 9);
+               xa_erase(&kvm->arch.vsie.addr_to_page, page->index >> 9);
                __free_page(page);
        }
        kvm->arch.vsie.page_count = 0;