]> www.infradead.org Git - users/willy/xarray.git/commitdiff
XArray: Test two more things about xa_cmpxchg
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 31 Mar 2020 18:23:59 +0000 (14:23 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 22 Jul 2020 13:58:35 +0000 (09:58 -0400)
1. If we xa_cmpxchg() an entry in, it marks the index as not free.
2. If we xa_cmpxchg() NULL in, it marks the index as free.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
lib/test_xarray.c

index d4f97925dbd8d6cc5a3b56db7b38da9fd05d2313..9fc3da430aba16842cefae29499dc3f74b438d4b 100644 (file)
@@ -393,6 +393,9 @@ static noinline void check_cmpxchg(struct xarray *xa)
        XA_BUG_ON(xa, xa_cmpxchg(xa, 12345678, FIVE, LOTS, GFP_KERNEL) != FIVE);
        XA_BUG_ON(xa, xa_cmpxchg(xa, 5, FIVE, NULL, GFP_KERNEL) != NULL);
        XA_BUG_ON(xa, xa_cmpxchg(xa, 5, NULL, FIVE, GFP_KERNEL) != NULL);
+       XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) != -EBUSY);
+       XA_BUG_ON(xa, xa_cmpxchg(xa, 5, FIVE, NULL, GFP_KERNEL) != FIVE);
+       XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) == -EBUSY);
        xa_erase_index(xa, 12345678);
        xa_erase_index(xa, 5);
        XA_BUG_ON(xa, !xa_empty(xa));