Эх сурвалжийг харах

shmem: Convert shmem_free_swap to XArray

Since we are conditionally storing NULL in the XArray, we do not need
to allocate memory and the GFP flags will be unused.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
Matthew Wilcox 7 жил өмнө
parent
commit
c121d3bb71
1 өөрчлөгдсөн 2 нэмэгдсэн , 2 устгасан
  1. 2 2
      mm/shmem.c

+ 2 - 2
mm/shmem.c

@@ -650,7 +650,7 @@ static void shmem_delete_from_page_cache(struct page *page, void *radswap)
 }
 }
 
 
 /*
 /*
- * Remove swap entry from radix tree, free the swap and its page cache.
+ * Remove swap entry from page cache, free the swap and its page cache.
  */
  */
 static int shmem_free_swap(struct address_space *mapping,
 static int shmem_free_swap(struct address_space *mapping,
 			   pgoff_t index, void *radswap)
 			   pgoff_t index, void *radswap)
@@ -658,7 +658,7 @@ static int shmem_free_swap(struct address_space *mapping,
 	void *old;
 	void *old;
 
 
 	xa_lock_irq(&mapping->i_pages);
 	xa_lock_irq(&mapping->i_pages);
-	old = radix_tree_delete_item(&mapping->i_pages, index, radswap);
+	old = __xa_cmpxchg(&mapping->i_pages, index, radswap, NULL, 0);
 	xa_unlock_irq(&mapping->i_pages);
 	xa_unlock_irq(&mapping->i_pages);
 	if (old != radswap)
 	if (old != radswap)
 		return -ENOENT;
 		return -ENOENT;