linux/lib/test_xarray.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * test_xarray.c: Test the XArray API
 * Copyright (c) 2017-2018 Microsoft Corporation
 * Copyright (c) 2019-2020 Oracle
 * Author: Matthew Wilcox <[email protected]>
 */

#include <linux/xarray.h>
#include <linux/module.h>

static unsigned int tests_run;
static unsigned int tests_passed;

static const unsigned int order_limit =;

#ifndef XA_DEBUG
# ifdef __KERNEL__
void xa_dump(const struct xarray *xa) {}
# endif
#undef XA_BUG_ON
#define XA_BUG_ON(xa, x)
#endif

static void *xa_mk_index(unsigned long index)
{}

static void *xa_store_index(struct xarray *xa, unsigned long index, gfp_t gfp)
{}

static void xa_insert_index(struct xarray *xa, unsigned long index)
{}

static void xa_alloc_index(struct xarray *xa, unsigned long index, gfp_t gfp)
{}

static void xa_erase_index(struct xarray *xa, unsigned long index)
{}

/*
 * If anyone needs this, please move it to xarray.c.  We have no current
 * users outside the test suite because all current multislot users want
 * to use the advanced API.
 */
static void *xa_store_order(struct xarray *xa, unsigned long index,
		unsigned order, void *entry, gfp_t gfp)
{}

static noinline void check_xa_err(struct xarray *xa)
{}

static noinline void check_xas_retry(struct xarray *xa)
{}

static noinline void check_xa_load(struct xarray *xa)
{}

static noinline void check_xa_mark_1(struct xarray *xa, unsigned long index)
{}

static noinline void check_xa_mark_2(struct xarray *xa)
{}

static noinline void check_xa_mark_3(struct xarray *xa)
{}

static noinline void check_xa_mark(struct xarray *xa)
{}

static noinline void check_xa_shrink(struct xarray *xa)
{}

static noinline void check_insert(struct xarray *xa)
{}

static noinline void check_cmpxchg(struct xarray *xa)
{}

static noinline void check_cmpxchg_order(struct xarray *xa)
{}

static noinline void check_reserve(struct xarray *xa)
{}

static noinline void check_xas_erase(struct xarray *xa)
{}

#ifdef CONFIG_XARRAY_MULTI
static noinline void check_multi_store_1(struct xarray *xa, unsigned long index,
		unsigned int order)
{}

static noinline void check_multi_store_2(struct xarray *xa, unsigned long index,
		unsigned int order)
{}

static noinline void check_multi_store_3(struct xarray *xa, unsigned long index,
		unsigned int order)
{}
#endif

static noinline void check_multi_store(struct xarray *xa)
{}

#ifdef CONFIG_XARRAY_MULTI
/* mimics page cache __filemap_add_folio() */
static noinline void check_xa_multi_store_adv_add(struct xarray *xa,
						  unsigned long index,
						  unsigned int order,
						  void *p)
{}

/* mimics page_cache_delete() */
static noinline void check_xa_multi_store_adv_del_entry(struct xarray *xa,
							unsigned long index,
							unsigned int order)
{}

static noinline void check_xa_multi_store_adv_delete(struct xarray *xa,
						     unsigned long index,
						     unsigned int order)
{}

/* mimics page cache filemap_get_entry() */
static noinline void *test_get_entry(struct xarray *xa, unsigned long index)
{}

static unsigned long some_val =;
static unsigned long some_val_2 =;

/* mimics the page cache usage */
static noinline void check_xa_multi_store_adv(struct xarray *xa,
					      unsigned long pos,
					      unsigned int order)
{}
#endif

static noinline void check_multi_store_advanced(struct xarray *xa)
{}

static noinline void check_xa_alloc_1(struct xarray *xa, unsigned int base)
{}

static noinline void check_xa_alloc_2(struct xarray *xa, unsigned int base)
{}

static noinline void check_xa_alloc_3(struct xarray *xa, unsigned int base)
{}

static DEFINE_XARRAY_ALLOC(xa0);
static DEFINE_XARRAY_ALLOC1(xa1);

static noinline void check_xa_alloc(void)
{}

static noinline void __check_store_iter(struct xarray *xa, unsigned long start,
			unsigned int order, unsigned int present)
{}

static noinline void check_store_iter(struct xarray *xa)
{}

static noinline void check_multi_find_1(struct xarray *xa, unsigned order)
{}

static noinline void check_multi_find_2(struct xarray *xa)
{}

static noinline void check_multi_find_3(struct xarray *xa)
{}

static noinline void check_find_1(struct xarray *xa)
{}

static noinline void check_find_2(struct xarray *xa)
{}

static noinline void check_find_3(struct xarray *xa)
{}

static noinline void check_find_4(struct xarray *xa)
{}

static noinline void check_find(struct xarray *xa)
{}

/* See find_swap_entry() in mm/shmem.c */
static noinline unsigned long xa_find_entry(struct xarray *xa, void *item)
{}

static noinline void check_find_entry(struct xarray *xa)
{}

static noinline void check_pause(struct xarray *xa)
{}

static noinline void check_move_tiny(struct xarray *xa)
{}

static noinline void check_move_max(struct xarray *xa)
{}

static noinline void check_move_small(struct xarray *xa, unsigned long idx)
{}

static noinline void check_move(struct xarray *xa)
{}

static noinline void xa_store_many_order(struct xarray *xa,
		unsigned long index, unsigned order)
{}

static noinline void check_create_range_1(struct xarray *xa,
		unsigned long index, unsigned order)
{}

static noinline void check_create_range_2(struct xarray *xa, unsigned order)
{}

static noinline void check_create_range_3(void)
{}

static noinline void check_create_range_4(struct xarray *xa,
		unsigned long index, unsigned order)
{}

static noinline void check_create_range_5(struct xarray *xa,
		unsigned long index, unsigned int order)
{}

static noinline void check_create_range(struct xarray *xa)
{}

static noinline void __check_store_range(struct xarray *xa, unsigned long first,
		unsigned long last)
{}

static noinline void check_store_range(struct xarray *xa)
{}

#ifdef CONFIG_XARRAY_MULTI
static void check_split_1(struct xarray *xa, unsigned long index,
				unsigned int order, unsigned int new_order)
{}

static noinline void check_split(struct xarray *xa)
{}
#else
static void check_split(struct xarray *xa) { }
#endif

static void check_align_1(struct xarray *xa, char *name)
{}

/*
 * We should always be able to store without allocating memory after
 * reserving a slot.
 */
static void check_align_2(struct xarray *xa, char *name)
{}

static noinline void check_align(struct xarray *xa)
{}

static LIST_HEAD(shadow_nodes);

static void test_update_node(struct xa_node *node)
{}

static noinline void shadow_remove(struct xarray *xa)
{}

static noinline void check_workingset(struct xarray *xa, unsigned long index)
{}

/*
 * Check that the pointer / value / sibling entries are accounted the
 * way we expect them to be.
 */
static noinline void check_account(struct xarray *xa)
{}

static noinline void check_get_order(struct xarray *xa)
{}

static noinline void check_xas_get_order(struct xarray *xa)
{}

static noinline void check_xas_conflict_get_order(struct xarray *xa)
{}


static noinline void check_destroy(struct xarray *xa)
{}

static DEFINE_XARRAY(array);

static int xarray_checks(void)
{}

static void xarray_exit(void)
{}

module_init();
module_exit(xarray_exit);
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();