linux/lib/test_objpool.c

// SPDX-License-Identifier: GPL-2.0

/*
 * Test module for lockless object pool
 *
 * Copyright: [email protected]
 */

#include <linux/errno.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/completion.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
#include <linux/hrtimer.h>
#include <linux/objpool.h>

#define OT_NR_MAX_BULK

/* memory usage */
struct ot_mem_stat {};

/* object allocation results */
struct ot_obj_stat {};

/* control & results per testcase */
struct ot_data {};

/* testcase */
struct ot_test {};

/* per-cpu worker */
struct ot_item {};

/*
 * memory leakage checking
 */

static void *ot_kzalloc(struct ot_test *test, long size)
{}

static void ot_kfree(struct ot_test *test, void *ptr, long size)
{}

static void ot_mem_report(struct ot_test *test)
{}

/* user object instance */
struct ot_node {};

/* user objpool manager */
struct ot_context {};

static DEFINE_PER_CPU(struct ot_item, ot_pcup_items);

static int ot_init_data(struct ot_data *data)
{}

static int ot_init_node(void *nod, void *context)
{}

static enum hrtimer_restart ot_hrtimer_handler(struct hrtimer *hrt)
{}

static void ot_start_hrtimer(struct ot_item *item)
{}

static void ot_stop_hrtimer(struct ot_item *item)
{}

static int ot_init_hrtimer(struct ot_item *item, unsigned long hrtimer)
{}

static int ot_init_cpu_item(struct ot_item *item,
			struct ot_test *test,
			struct objpool_head *pool,
			void (*worker)(struct ot_item *, int))
{}

static int ot_thread_worker(void *arg)
{}

static void ot_perf_report(struct ot_test *test, u64 duration)
{}

/*
 * synchronous test cases for objpool manipulation
 */

/* objpool manipulation for synchronous mode (percpu objpool) */
static struct ot_context *ot_init_sync_m0(struct ot_test *test)
{}

static void ot_fini_sync(struct ot_context *sop)
{}

static struct {} g_ot_sync_ops[] =;

/*
 * synchronous test cases: performance mode
 */

static void ot_bulk_sync(struct ot_item *item, int irq)
{}

static int ot_start_sync(struct ot_test *test)
{}

/*
 * asynchronous test cases: pool lifecycle controlled by refcount
 */

static void ot_fini_async_rcu(struct rcu_head *rcu)
{}

static void ot_fini_async(struct ot_context *sop)
{}

static int ot_objpool_release(struct objpool_head *head, void *context)
{}

static struct ot_context *ot_init_async_m0(struct ot_test *test)
{}

static struct {} g_ot_async_ops[] =;

static void ot_nod_recycle(struct ot_node *on, struct objpool_head *pool,
			int release)
{}

static void ot_bulk_async(struct ot_item *item, int irq)
{}

static int ot_start_async(struct ot_test *test)
{}

/*
 * predefined testing cases:
 *   synchronous case / overrun case / async case
 *
 * async: synchronous or asynchronous testing
 * mode: only mode 0 supported
 * objsz: object size
 * duration: int, total test time in ms
 * delay: int, delay (in ms) between each iteration
 * bulk_normal: int, repeat times for thread worker
 * bulk_irq: int, repeat times for irq consumer
 * hrtimer: unsigned long, hrtimer intervnal in ms
 * name: char *, tag for current test ot_item
 */

#define NODE_COMPACT
#define NODE_VMALLOC

static struct ot_test g_testcases[] =;

static int __init ot_mod_init(void)
{}

static void __exit ot_mod_exit(void)
{}

module_init(ot_mod_init);
module_exit(ot_mod_exit);

MODULE_LICENSE();