diff options
author | Matthew Wilcox <willy@infradead.org> | 2018-08-28 16:13:16 -0400 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-10-21 10:46:46 -0400 |
commit | d6427f8179b5dd65eb468c61fc8cc24657c336c9 (patch) | |
tree | be783289bf2c41109ad5386fc62cc7973a0e770e /lib/test_xarray.c | |
parent | 47e0fab2b15155e33fdff777c791bebfd5855bbc (diff) |
xarray: Move multiorder account test in-kernel
Move this test to the in-kernel test suite, and enhance it to test
several different orders.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'lib/test_xarray.c')
-rw-r--r-- | lib/test_xarray.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/test_xarray.c b/lib/test_xarray.c index ca86141641cb..38cab4ccb24e 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c | |||
@@ -1019,6 +1019,37 @@ static noinline void check_workingset(struct xarray *xa, unsigned long index) | |||
1019 | XA_BUG_ON(xa, !xa_empty(xa)); | 1019 | XA_BUG_ON(xa, !xa_empty(xa)); |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | /* | ||
1023 | * Check that the pointer / value / sibling entries are accounted the | ||
1024 | * way we expect them to be. | ||
1025 | */ | ||
1026 | static noinline void check_account(struct xarray *xa) | ||
1027 | { | ||
1028 | #ifdef CONFIG_XARRAY_MULTI | ||
1029 | unsigned int order; | ||
1030 | |||
1031 | for (order = 1; order < 12; order++) { | ||
1032 | XA_STATE(xas, xa, 1 << order); | ||
1033 | |||
1034 | xa_store_order(xa, 0, order, xa, GFP_KERNEL); | ||
1035 | xas_load(&xas); | ||
1036 | XA_BUG_ON(xa, xas.xa_node->count == 0); | ||
1037 | XA_BUG_ON(xa, xas.xa_node->count > (1 << order)); | ||
1038 | XA_BUG_ON(xa, xas.xa_node->nr_values != 0); | ||
1039 | |||
1040 | xa_store_order(xa, 1 << order, order, xa_mk_value(1 << order), | ||
1041 | GFP_KERNEL); | ||
1042 | XA_BUG_ON(xa, xas.xa_node->count != xas.xa_node->nr_values * 2); | ||
1043 | |||
1044 | xa_erase(xa, 1 << order); | ||
1045 | XA_BUG_ON(xa, xas.xa_node->nr_values != 0); | ||
1046 | |||
1047 | xa_erase(xa, 0); | ||
1048 | XA_BUG_ON(xa, !xa_empty(xa)); | ||
1049 | } | ||
1050 | #endif | ||
1051 | } | ||
1052 | |||
1022 | static noinline void check_destroy(struct xarray *xa) | 1053 | static noinline void check_destroy(struct xarray *xa) |
1023 | { | 1054 | { |
1024 | unsigned long index; | 1055 | unsigned long index; |
@@ -1068,6 +1099,7 @@ static int xarray_checks(void) | |||
1068 | check_xa_alloc(); | 1099 | check_xa_alloc(); |
1069 | check_find(&array); | 1100 | check_find(&array); |
1070 | check_find_entry(&array); | 1101 | check_find_entry(&array); |
1102 | check_account(&array); | ||
1071 | check_destroy(&array); | 1103 | check_destroy(&array); |
1072 | check_move(&array); | 1104 | check_move(&array); |
1073 | check_create_range(&array); | 1105 | check_create_range(&array); |